From fd43db9469ccc28a9b0b3cc174e1f6656114b984 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 2 Apr 2022 17:58:34 +0000 Subject: [PATCH 001/117] Auto-generated commit f7eb8b111db8bc017df9bbfe8859ea1e63c9a86f --- CONTRIBUTORS | 28 + LICENSE | 481 +++++++++ NOTICE | 1 + README.md | 336 ++++++ index.d.ts | 427 ++++++++ index.mjs | 4 + index.mjs.map | 1 + package.json | 75 ++ stats.html | 2689 +++++++++++++++++++++++++++++++++++++++++++++++++ 9 files changed, 4042 insertions(+) create mode 100644 CONTRIBUTORS create mode 100644 LICENSE create mode 100644 NOTICE create mode 100644 README.md create mode 100644 index.d.ts create mode 100644 index.mjs create mode 100644 index.mjs.map create mode 100644 package.json create mode 100644 stats.html diff --git a/CONTRIBUTORS b/CONTRIBUTORS new file mode 100644 index 0000000..e5c896d --- /dev/null +++ b/CONTRIBUTORS @@ -0,0 +1,28 @@ +# This file is generated by tools/scripts/update_contributors. +# +# Contributors listed in alphabetical order. + +Ali Salesi +Athan Reines +Brendan Graetz +Bruno Fenzl +Christopher Dambamuromo +Dominik Moritz +Frank Kovacs +James +Jithin KS +Joey Reed +Joris Labie +Justin Dennison +Marcus +Matt Cochrane +Milan Raj +Momtchil Momtchev +Ognjen Jevremović +Philipp Burckhardt +Ricky Reusser +Ryan Seal +Seyyed Parsa Neshaei +Shraddheya Shendre +dorrin-sot <59933477+dorrin-sot@users.noreply.github.com> +rei2hu diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..fcc9934 --- /dev/null +++ b/LICENSE @@ -0,0 +1,481 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + + +Boost Software License - Version 1.0 - August 17th, 2003 + +Permission is hereby granted, free of charge, to any person or organization +obtaining a copy of the software and accompanying documentation covered by this +license (the "Software") to use, reproduce, display, distribute, execute, and +transmit the Software, and to prepare derivative works of the Software, and to +permit third-parties to whom the Software is furnished to do so, all subject to +the following: + +The copyright notices in the Software and this entire statement, including the +above license grant, this restriction and the following disclaimer, must be +included in all copies of the Software, in whole or in part, and all derivative +works of the Software, unless such copies or derivative works are solely in the +form of machine-executable object code generated by a source language processor. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE +COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE FOR ANY DAMAGES +OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF +OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + + + +DEPENDENCIES + +The library links against the following external libraries, which have their own +licenses: + +* OpenBLAS + +Copyright (c) 2011-2014, The OpenBLAS Project +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + 3. Neither the name of the OpenBLAS project nor the names of + its contributors may be used to endorse or promote products + derived from this software without specific prior written + permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF +THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +* Electron + +Copyright (c) 2013-2017 GitHub Inc. + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + +* Boost + +Boost Software License - Version 1.0 - August 17th, 2003 + +Permission is hereby granted, free of charge, to any person or organization +obtaining a copy of the software and accompanying documentation covered by +this license (the "Software") to use, reproduce, display, distribute, +execute, and transmit the Software, and to prepare derivative works of the +Software, and to permit third-parties to whom the Software is furnished to +do so, all subject to the following: + +The copyright notices in the Software and this entire statement, including +the above license grant, this restriction and the following disclaimer, +must be included in all copies of the Software, in whole or in part, and +all derivative works of the Software, unless such copies or derivative +works are solely in the form of machine-executable object code generated by +a source language processor. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT +SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE +FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. + + +* Cephes + +Copyright (c) 1984-2000 Stephen L. Moshier + +Some software in this archive may be from the book _Methods and Programs for +Mathematical Functions_ (Prentice-Hall or Simon & Schuster International, 1989) +or from the Cephes Mathematical Library, a commercial product. In either event, +it is copyrighted by the author. What you see here may be used freely but it +comes with no support or guarantee. + +Stephen L. Moshier +moshier@na-net.ornl.gov + + + +ATTRIBUTION + +The library contains implementations from the following external libraries, +which have their own licenses: + +* FreeBSD + +Copyright (C) 1993-2004 by Sun Microsystems, Inc. All rights reserved. + +Developed at SunPro, a Sun Microsystems, Inc. business. +Permission to use, copy, modify, and distribute this +software is freely granted, provided that this notice +is preserved. + + +* FDLIBM + +Copyright (C) 2004 by Sun Microsystems, Inc. All rights reserved. + +Developed at SunPro, a Sun Microsystems, Inc. business. +Permission to use, copy, modify, and distribute this +software is freely granted, provided that this notice +is preserved. + + +* Go + +Copyright (c) 2009 The Go Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +* SLATEC Common Mathematical Library + +Public domain. + + +* ESLint + +Copyright JS Foundation and other contributors, https://js.foundation + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + + +* StatsFuns.jl + +Copyright (c) 2015: Dahua Lin. + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + +* SpecialFunctions.jl + +The MIT License (MIT) + +Copyright (c) 2017 Jeff Bezanson, Stefan Karpinski, Viral B. Shah, and others: + +https://github.com/JuliaMath/SpecialFunctions.jl/graphs/contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + + +* MT19937 + +Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura, +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + 3. The names of its contributors may not be used to endorse or promote + products derived from this software without specific prior written + permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/NOTICE b/NOTICE new file mode 100644 index 0000000..10e6ba1 --- /dev/null +++ b/NOTICE @@ -0,0 +1 @@ +Copyright (c) 2016-2022 The Stdlib Authors. diff --git a/README.md b/README.md new file mode 100644 index 0000000..096e6e8 --- /dev/null +++ b/README.md @@ -0,0 +1,336 @@ + + +# filledarrayBy + +[![NPM version][npm-image]][npm-url] [![Build Status][test-image]][test-url] [![Coverage Status][coverage-image]][coverage-url] + +> Create a filled array according to a provided callback function. + + + +
+ +
+ + + + + + + +
+ +## Usage + +```javascript +import filledarrayBy from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-filled-by@esm/index.mjs'; +``` + +#### filledarrayBy( \[dtype] ) + +Creates a filled array having a specified data type `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. + +```javascript +var arr = filledarrayBy( 'int32' ); +// returns +``` + +#### filledarrayBy( length\[, dtype], clbk\[, thisArg] ) + +Returns a filled array according to a provided callback function and having a specified `length`. + +```javascript +function constant() { + return 1.0; +} + +var arr1 = filledarrayBy( 5, constant ); +// returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] + +var arr2 = filledarrayBy( 5, 'uint8', constant ); +// returns [ 1, 1, 1, 1, 1 ] +``` + +#### filledarrayBy( array\[, dtype], clbk\[, thisArg] ) + +Creates a filled array from another array (or array-like object) according to a provided callback function. + +```javascript +var arr0 = { + '0': 0.5, + '1': 0.5, + '2': 0.5, + 'length': 3 +}; + +function clbk1() { + return 1.0; +} +var arr1 = filledarrayBy( arr0, clbk1 ); +// returns [ 1.0, 1.0, 1.0 ] + +function clbk2() { + return 2.0; +} +var arr2 = filledarrayBy( arr1, clbk2 ); +// returns [ 2.0, 2.0, 2.0 ] + +function clbk3() { + return 3.0; +} +var arr3 = filledarrayBy( arr1, 'int32', clbk3 ); +// returns [ 3, 3, 3 ] +``` + +#### filledarrayBy( iterable\[, dtype], clbk\[, thisArg] ) + +Creates a filled array from an iterable according to a provided callback function. + +```javascript +import iterConstant from 'https://cdn.jsdelivr.net/gh/stdlib-js/iter-constant@esm/index.mjs'; + +function clbk() { + return 1.0; +} + +var it = iterConstant( 3.0, { + 'iter': 3 +}); + +var arr1 = filledarrayBy( it, clbk ); +// returns [ 1.0, 1.0, 1.0 ] + +var arr2 = filledarrayBy( it, 'float32', clbk ); +// returns [ 1.0, 1.0, 1.0 ] +``` + +#### filledarrayBy( buffer\[, byteOffset\[, length]]\[, dtype], clbk\[, thisArg] ) + +Returns a filled [typed array][mdn-typed-array] view of an [`ArrayBuffer`][mdn-arraybuffer] according to a provided callback function. + +```javascript +import ArrayBuffer from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@esm/index.mjs'; + +function clbk() { + return 1.0; +} + +var buf = new ArrayBuffer( 32 ); +var arr = filledarrayBy( buf, clbk ); +// returns [ 1.0, 1.0, 1.0, 1.0 ] + +buf = new ArrayBuffer( 32 ); +arr = filledarrayBy( buf, 'float32', clbk ); +// returns [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] + +buf = new ArrayBuffer( 32 ); +arr = filledarrayBy( buf, 16, clbk ); +// returns [ 1.0, 1.0 ] + +buf = new ArrayBuffer( 32 ); +arr = filledarrayBy( buf, 16, 'float32', clbk ); +// returns [ 1.0, 1.0, 1.0, 1.0 ] + +buf = new ArrayBuffer( 32 ); +arr = filledarrayBy( buf, 16, 1, clbk ); +// returns [ 1.0 ] + +buf = new ArrayBuffer( 32 ); +arr = filledarrayBy( buf, 10, 4, 'int16', clbk ); +// returns [ 1, 1, 1, 1 ] +``` + +
+ + + + + +
+ +## Notes + +- Creating a generic [array][mdn-array] from an [`ArrayBuffer`][mdn-arraybuffer] is **not** supported. + +- A callback function is provided a single argument: + + - **index**: the current array index. + +
+ + + + + +
+ +## Examples + + + +```html + + + + + + +``` + +
+ + + + + +
+ +
+ + + + + + + + + + + + +
+ +* * * + +## Notice + +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. + +For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. + +#### Community + +[![Chat][chat-image]][chat-url] + +--- + +## License + +See [LICENSE][stdlib-license]. + + +## Copyright + +Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. + +
+ + + + + + + + diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 0000000..2156674 --- /dev/null +++ b/index.d.ts @@ -0,0 +1,427 @@ +/* +* @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. +*/ + +// TypeScript Version: 2.0 + +/// + +import { RealOrComplexTypedArray, DataType } from '@stdlib/types/array'; +import { Collection } from '@stdlib/types/object'; +import { IterableIterator } from '@stdlib/types/iter'; + +/** +* Array or typed array. +*/ +type ArrayOrTypedArray = Array | RealOrComplexTypedArray; + +/** +* Nullary callback function. +* +* @returns fill value +*/ +type Nullary = () => any; + +/** +* Unary callback function. +* +* @param i - current array index +* @returns fill value +*/ +type Unary = ( i: number ) => any; + +/** +* Callback function. +* +* @param i - current array index +* @returns fill value +*/ +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 +* +* @example +* var arr = filledarrayBy(); +* // returns +* +* @example +* var arr = filledarrayBy( 'float32' ); +* // returns +*/ +declare function filledarrayBy( dtype?: DataType ): ArrayOrTypedArray; // tslint:disable-line:unified-signatures + +/** +* Creates a filled array according to a provided callback function and having a specified `length`. +* +* @param length - array length +* @param clbk - callback function +* @param thisArg - callback function execution context +* @returns filled array +* +* @example +* var constantFunction = require( `@stdlib/utils/constant-function` ); +* +* var arr = filledarrayBy( 5, constantFunction( 1.0 ) ); +* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] +*/ +declare function filledarrayBy( length: number, clbk: Callback, thisArg?: any ): ArrayOrTypedArray; // tslint:disable-line:max-line-length unified-signatures + +/** +* 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 +* @param thisArg - callback function execution context +* @returns filled array +* +* @example +* var constantFunction = require( `@stdlib/utils/constant-function` ); +* +* var arr = filledarrayBy( 5, 'float64', constantFunction( 1.0 ) ); +* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] +*/ +declare function filledarrayBy( length: number, dtype: DataType, clbk: Callback, thisArg?: any ): ArrayOrTypedArray; // tslint:disable-line:max-line-length unified-signatures + +/** +* Creates a filled array from another `array` according to a provided callback function. +* +* @param array - typed array or array-like object +* @param clbk - callback function +* @param thisArg - callback function execution context +* @returns filled array +* +* @example +* var constantFunction = require( `@stdlib/utils/constant-function` ); +* +* 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; // tslint:disable-line:max-line-length 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 +* @param thisArg - callback function execution context +* @returns filled array +* +* @example +* var constantFunction = require( `@stdlib/utils/constant-function` ); +* +* 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; // tslint:disable-line:max-line-length unified-signatures + +/** +* Creates a filled array from an iterable according to a callback function. +* +* @param iterable - iterable +* @param clbk - callback function +* @param thisArg - callback function execution context +* @returns filled array +* +* @example +* var constantFunction = require( `@stdlib/utils/constant-function` ); +* var iterConstant = require( `@stdlib/iter/constant` ); +* +* var it = iterConstant( 3.0, { +* 'iter': 3 +* }); +* var arr = filledarrayBy( it, constantFunction( 1.0 ) ); +* // returns [ 1.0, 1.0, 1.0 ] +*/ +declare function filledarrayBy( iterable: IterableIterator, callback: Callback, thisArg?: any ): ArrayOrTypedArray; // tslint:disable-line:max-line-length 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 +* @param thisArg - callback function execution context +* @returns filled array +* +* @example +* var constantFunction = require( `@stdlib/utils/constant-function` ); +* var iterConstant = require( `@stdlib/iter/constant` ); +* +* var it = iterConstant( 3.0, { +* 'iter': 3 +* }); +* 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; // tslint:disable-line:max-line-length unified-signatures + +/** +* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. +* +* ## Notes +* +* - Creating a generic array from an `ArrayBuffer` is **not** supported. +* +* @param buffer - `ArrayBuffer` +* @param byteOffset - byte offset +* @param length - view length +* @param clbk - callback function +* @param thisArg - callback function execution context +* @returns filled array +* +* @example +* var constantFunction = require( `@stdlib/utils/constant-function` ); +* var ArrayBuffer = require( `@stdlib/array/buffer` ); +* +* var buf = new ArrayBuffer( 32 ); +* 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; // tslint:disable-line:max-line-length + +/** +* 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. +* +* @param buffer - `ArrayBuffer` +* @param byteOffset - byte offset +* @param length - view length +* @param dtype - data type +* @param clbk - callback function +* @param thisArg - callback function execution context +* @returns filled array +* +* @example +* var constantFunction = require( `@stdlib/utils/constant-function` ); +* var ArrayBuffer = require( `@stdlib/array/buffer` ); +* +* var buf = new ArrayBuffer( 32 ); +* 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; // tslint:disable-line:max-line-length unified-signatures + +/** +* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. +* +* ## Notes +* +* - Creating a generic array from an `ArrayBuffer` is **not** supported. +* +* @param buffer - `ArrayBuffer` +* @param byteOffset - byte offset +* @param clbk - callback function +* @param thisArg - callback function execution context +* @returns filled array +* +* @example +* var constantFunction = require( `@stdlib/utils/constant-function` ); +* var ArrayBuffer = require( `@stdlib/array/buffer` ); +* +* var buf = new ArrayBuffer( 32 ); +* 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; // tslint:disable-line:max-line-length + +/** +* 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. +* +* @param buffer - `ArrayBuffer` +* @param byteOffset - byte offset +* @param dtype - data type +* @param clbk - callback function +* @param thisArg - callback function execution context +* @returns filled array +* +* @example +* var constantFunction = require( `@stdlib/utils/constant-function` ); +* var ArrayBuffer = require( `@stdlib/array/buffer` ); +* +* var buf = new ArrayBuffer( 32 ); +* 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; // tslint:disable-line:max-line-length unified-signatures + +/** +* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. +* +* ## Notes +* +* - Creating a generic array from an `ArrayBuffer` is **not** supported. +* +* @param buffer - `ArrayBuffer` +* @param clbk - callback function +* @param thisArg - callback function execution context +* @returns filled array +* +* @example +* var constantFunction = require( `@stdlib/utils/constant-function` ); +* var ArrayBuffer = require( `@stdlib/array/buffer` ); +* +* var buf = new ArrayBuffer( 32 ); +* 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; // tslint:disable-line:max-line-length 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. +* +* @param buffer - `ArrayBuffer` +* @param dtype - data type +* @param clbk - callback function +* @param thisArg - callback function execution context +* @returns filled array +* +* @example +* var constantFunction = require( `@stdlib/utils/constant-function` ); +* var ArrayBuffer = require( `@stdlib/array/buffer` ); +* +* var buf = new ArrayBuffer( 32 ); +* 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; // tslint:disable-line:max-line-length unified-signatures + + +// EXPORTS // + +export = filledarrayBy; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..76ae662 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-ctors@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill-by@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled-by@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@esm/index.mjs";var y=r.isPrimitive,h=e.isPrimitive,g=t,f=i,v=a,j=n,b=s,c=o,w=l,E=p,x=m,k=u,T=d();function M(r,e,t){var i,a;for(i=[],a=-1;!r.next().done;)a+=1,i.push(e.call(t,a));return i}function V(r,e,t){var i;for(i=0;i1)throw new TypeError("invalid arguments. Must provide a length, typed array, array-like object, or an iterable.");if(null===(a=b(t)))throw new TypeError(k("invalid argument. Must provide a recognized data type. Value: `%s`.",t));return new a(0)}if(e<2)throw new TypeError("invalid arguments. Must provide a length, typed array, array-like object, or an iterable.");if(j(arguments[e-=1]))if(j(arguments[e-1])){if(r=arguments[e],i=arguments[e-=1],0===e)throw new TypeError("invalid arguments. Must provide a length, typed array, array-like object, or an iterable.")}else i=arguments[e];else{if(!(e>=2))throw new TypeError("invalid arguments. Must provide a length, typed array, array-like object, or an iterable.");if(r=arguments[e],!j(i=arguments[e-=1]))throw new TypeError(k("invalid argument. Callback argument must be a function. Value: `%s`.",i))}if((e-=1)>=0&&y(arguments[e])?(t=arguments[e],e-=1):t="float64",null===(a=b(t)))throw new TypeError(k("invalid argument. Must provide a recognized data type. Value: `%s`.",t));if("generic"===t){if(o=arguments[0],0===e){if(h(o)?s=o:g(o)&&(s=o.length),void 0!==s)return w(s,i,r);if(f(o))throw new Error("invalid arguments. Creating a generic array from an ArrayBuffer is not supported.");if(v(o)){if(!1===T)throw new TypeError(k("invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.",o));if(!j(o[E]))throw new TypeError(k("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",o));if(o=o[E](),!j(o.next))throw new TypeError(k("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",o));return M(o,i,r)}throw new TypeError(k("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",o))}if(f(o))throw new Error("invalid arguments. Creating a generic array from an ArrayBuffer is not supported.");throw new TypeError(k("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",o))}if(0===e)if(g(o=arguments[0]))n=new a(o.length);else if(f(o))n=new a(o);else if(h(o))n=new a(o);else{if(!v(o))throw new TypeError(k("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",o));if(!1===T)throw new TypeError(k("invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.",o));if(!j(o[E]))throw new TypeError(k("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",o));if(o=o[E](),!j(o.next))throw new TypeError(k("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",o));n=new a(x(o))}else n=1===e?new a(arguments[0],arguments[1]):new a(arguments[0],arguments[1],arguments[2]);return n.length>0&&(/^complex/.test(t)?V(n,i,r):c(n.length,n,1,l)),n;function l(e,t){return i.call(r,t)}};export{C as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..3fc6a31 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","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 format = require( '@stdlib/string-format' );\n\n\n// VARIABLES //\n\nvar HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport();\nvar DEFAULT_DTYPE = 'float64';\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"],"names":["isString","require$$0","isPrimitive","isNonNegativeInteger","require$$1","isCollection","require$$2","isArrayBuffer","require$$3","isObject","require$$4","isFunction","require$$5","ctors","require$$6","gfillBy","require$$7","filledArray","require$$8","ITERATOR_SYMBOL","require$$10","iterLength","require$$11","format","require$$12","HAS_ITERATOR_SYMBOL","require$$9","filledArrayIterator","it","clbk","thisArg","arr","i","next","done","push","call","filledAccessors","length","set","lib","nargs","dtype","ctor","len","arg","arguments","TypeError","Error","test","callback","value","aidx"],"mappings":";;0mCAsBA,IAAIA,EAAWC,EAAsCC,YACjDC,EAAuBC,EAAmDF,YAC1EG,EAAeC,EACfC,EAAgBC,EAChBC,EAAWC,EACXC,EAAaC,EACbC,EAAQC,EACRC,EAAUC,EACVC,EAAcC,EAEdC,EAAkBC,EAClBC,EAAaC,EACbC,EAASC,EAKTC,EAR2BC,IAuB/B,SAASC,EAAqBC,EAAIC,EAAMC,GACvC,IAAIC,EACAC,EAKJ,IAFAD,EAAM,GACNC,GAAK,GAEAJ,EAAGK,OACAC,MAGPF,GAAK,EACLD,EAAII,KAAMN,EAAKO,KAAMN,EAASE,IAE/B,OAAOD,EAYR,SAASM,EAAiBN,EAAKF,EAAMC,GACpC,IAAIE,EACJ,IAAMA,EAAI,EAAGA,EAAID,EAAIO,OAAQN,IAC5BD,EAAIQ,IAAKV,EAAKO,KAAMN,EAASE,GAAKA,GAEnC,OAAOD,EAsUR,IC7NAS,EDoDA,WACC,IAAIV,EACAW,EACAC,EACAb,EACAc,EACAZ,EACAa,EACAC,EAKJ,GAAe,KAHfJ,EAAQK,UAAUR,QAKjB,OAAO,IADPK,EAAO9B,EAzNW,YA0ND,GAIlB,GAAKb,EADL0C,EAAQI,UAAW,IACM,CAExB,GAAKL,EAAQ,EACZ,MAAM,IAAIM,UAAW,6FAGtB,GAAc,QADdJ,EAAO9B,EAAO6B,IAEb,MAAM,IAAIK,UAAWxB,EAAQ,sEAAuEmB,IAGrG,OAAO,IAAIC,EAAM,GAGlB,GAAKF,EAAQ,EACZ,MAAM,IAAIM,UAAW,6FAMtB,GAAKpC,EAAYmC,UAHjBL,GAAS,IAKR,GAAK9B,EAAYmC,UAAWL,EAAM,KAMjC,GALAX,EAAUgB,UAAWL,GAErBZ,EAAOiB,UADPL,GAAS,GAIM,IAAVA,EACJ,MAAM,IAAIM,UAAW,kGAItBlB,EAAOiB,UAAWL,OAIf,CAAA,KAAKA,GAAS,GAUlB,MAAM,IAAIM,UAAW,6FANrB,GAHAjB,EAAUgB,UAAWL,IAGf9B,EADNkB,EAAOiB,UADPL,GAAS,IAGR,MAAM,IAAIM,UAAWxB,EAAQ,uEAAwEM,IAgBvG,IARAY,GAAS,IACK,GAAKzC,EAAU8C,UAAWL,KACvCC,EAAQI,UAAWL,GACnBA,GAAS,GAETC,EArRkB,UAwRL,QADdC,EAAO9B,EAAO6B,IAEb,MAAM,IAAIK,UAAWxB,EAAQ,sEAAuEmB,IAGrG,GAAe,YAAVA,EAAsB,CAE1B,GADAG,EAAMC,UAAW,GACF,IAAVL,EAAc,CAMlB,GALKtC,EAAsB0C,GAC1BD,EAAMC,EACKxC,EAAcwC,KACzBD,EAAMC,EAAIP,aAEE,IAARM,EACJ,OAAO3B,EAAa2B,EAAKf,EAAMC,GAEhC,GAAKvB,EAAesC,GACnB,MAAM,IAAIG,MAAO,qFAElB,GAAKvC,EAAUoC,GAAQ,CACtB,IAA6B,IAAxBpB,EACJ,MAAM,IAAIsB,UAAWxB,EAAQ,sIAAuIsB,IAErK,IAAMlC,EAAYkC,EAAK1B,IACtB,MAAM,IAAI4B,UAAWxB,EAAQ,wGAAyGsB,IAGvI,GADAA,EAAMA,EAAK1B,MACLR,EAAYkC,EAAIZ,MACrB,MAAM,IAAIc,UAAWxB,EAAQ,wGAAyGsB,IAEvI,OAAOlB,EAAqBkB,EAAKhB,EAAMC,GAExC,MAAM,IAAIiB,UAAWxB,EAAQ,wGAAyGsB,IAChI,GAAKtC,EAAesC,GAC1B,MAAM,IAAIG,MAAO,qFAElB,MAAM,IAAID,UAAWxB,EAAQ,wGAAyGsB,IAEvI,GAAe,IAAVJ,EAEJ,GAAKpC,EADLwC,EAAMC,UAAW,IAEhBf,EAAM,IAAIY,EAAME,EAAIP,aACd,GAAK/B,EAAesC,GAC1Bd,EAAM,IAAIY,EAAME,QACV,GAAK1C,EAAsB0C,GACjCd,EAAM,IAAIY,EAAME,OACV,CAAA,IAAKpC,EAAUoC,GAarB,MAAM,IAAIE,UAAWxB,EAAQ,wGAAyGsB,IAZtI,IAA6B,IAAxBpB,EACJ,MAAM,IAAIsB,UAAWxB,EAAQ,sIAAuIsB,IAErK,IAAMlC,EAAYkC,EAAK1B,IACtB,MAAM,IAAI4B,UAAWxB,EAAQ,wGAAyGsB,IAGvI,GADAA,EAAMA,EAAK1B,MACLR,EAAYkC,EAAIZ,MACrB,MAAM,IAAIc,UAAWxB,EAAQ,wGAAyGsB,IAEvId,EAAM,IAAIY,EAAMtB,EAAYwB,SAK7Bd,EADqB,IAAVU,EACL,IAAIE,EAAMG,UAAU,GAAIA,UAAU,IAElC,IAAIH,EAAMG,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKf,EAAIO,OAAS,IACZ,WAAWW,KAAMP,GACrBL,EAAiBN,EAAKF,EAAMC,GAE5Bf,EAASgB,EAAIO,OAAQP,EAAK,EAAGmB,IAGxBnB,EAYP,SAASmB,EAAUC,EAAOC,GACzB,OAAOvB,EAAKO,KAAMN,EAASsB"} \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..cd3fd4b --- /dev/null +++ b/package.json @@ -0,0 +1,75 @@ +{ + "name": "@stdlib/array-filled-by", + "version": "0.0.0", + "description": "Create a filled array according to a provided callback function.", + "license": "Apache-2.0", + "type": "module", + "main": "./index.mjs", + "homepage": "https://stdlib.io", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/array-filled-by.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "keywords": [ + "stdlib", + "stdtypes", + "types", + "data", + "structure", + "typed", + "array", + "typed array", + "typed-array", + "vector", + "ndarray", + "matrix", + "float64array", + "float32array", + "int32array", + "uint32array", + "int16array", + "uint16array", + "int8array", + "uint8array", + "uint8clampedarray", + "float64", + "double", + "precision", + "double-precision", + "single", + "float", + "single-precision", + "float32", + "ieee754", + "integer", + "int32", + "signed", + "unsigned", + "uint32", + "int16", + "uint16", + "int8", + "uint8", + "uint8c", + "complex64", + "complex128", + "complex", + "cmplx", + "clamped", + "short", + "long", + "generic", + "fill", + "filled", + "map", + "foreach", + "callback" + ], + "funding": { + "type": "patreon", + "url": "https://www.patreon.com/athan" + } +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..9bf7cc5 --- /dev/null +++ b/stats.html @@ -0,0 +1,2689 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + From d5e7c364782e9215f83e51a82e283edfd510e5c9 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Jul 2022 01:33:15 +0000 Subject: [PATCH 002/117] Transform error messages --- lib/main.js | 38 +++++++++++++++++++------------------- package.json | 2 +- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/lib/main.js b/lib/main.js index d27b055..d6fbe5e 100644 --- a/lib/main.js +++ b/lib/main.js @@ -32,7 +32,7 @@ var filledArray = require( '@stdlib/array-base-filled-by' ); var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); var iterLength = require( '@stdlib/iter-length' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -263,18 +263,18 @@ function filledarrayBy() { if ( isString( dtype ) ) { // Invoking this function with arguments `f( dtype, clbk[, thisArg] )` is not allowed (otherwise, we'd need to also allow `f( clbk[, thisArg] )`)... if ( nargs > 1 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format( '00L05' ) ); } ctor = ctors( dtype ); if ( ctor === null ) { - throw new TypeError( format( 'invalid argument. Must provide a recognized data type. Value: `%s`.', dtype ) ); + throw new TypeError( format( '00L2k', dtype ) ); } // Return an empty array having the specified dtype: return new ctor( 0 ); } // For all other supported invocations, we need at least two arguments... if ( nargs < 2 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format( '00L05' ) ); } // At this point, we need to do some argument juggling... nargs -= 1; // henceforth, the number of available arguments is `nargs+1` @@ -289,7 +289,7 @@ function filledarrayBy() { // Check if we were provided only a callback and a "this" context.. if ( nargs === 0 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format( '00L05' ) ); } } else { // "this" context is left undefined... @@ -302,12 +302,12 @@ function filledarrayBy() { nargs -= 1; clbk = arguments[ nargs ]; if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '00L2n', clbk ) ); } } // If were were only provided 2 arguments and the last argument was not a function, we've been provided an insufficient number of arguments... else { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format( '00L05' ) ); } // Now that we've processed the callback arguments, let's continue working backward to see if we've been provided a `dtype` argument... nargs -= 1; @@ -319,7 +319,7 @@ function filledarrayBy() { } ctor = ctors( dtype ); if ( ctor === null ) { - throw new TypeError( format( 'invalid argument. Must provide a recognized data type. Value: `%s`.', dtype ) ); + throw new TypeError( format( '00L2k', dtype ) ); } // At this point, we've resolved the output array data type, and now we can actually create the output array... if ( dtype === 'generic' ) { @@ -334,26 +334,26 @@ function filledarrayBy() { return filledArray( len, clbk, thisArg ); } if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format( '00L04' ) ); } if ( isObject( arg ) ) { if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.', arg ) ); + throw new TypeError( format( '00L2l', arg ) ); } if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00L2m', arg ) ); } arg = arg[ ITERATOR_SYMBOL ](); if ( !isFunction( arg.next ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00L2m', arg ) ); } return filledArrayIterator( arg, clbk, thisArg ); } - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00L2m', arg ) ); } else if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format( '00L04' ) ); } - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00L2m', arg ) ); } if ( nargs === 0 ) { // length || array-like || ArrayBuffer || iterable arg = arguments[ 0 ]; @@ -365,18 +365,18 @@ function filledarrayBy() { arr = new ctor( arg ); } else if ( isObject( arg ) ) { if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.', arg ) ); + throw new TypeError( format( '00L2l', arg ) ); } if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00L2m', arg ) ); } arg = arg[ ITERATOR_SYMBOL ](); if ( !isFunction( arg.next ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00L2m', arg ) ); } arr = new ctor( iterLength( arg ) ); } else { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00L2m', arg ) ); } } else if ( nargs === 1 ) { arr = new ctor( arguments[0], arguments[1] ); // (ArrayBuffer, byteOffset) diff --git a/package.json b/package.json index b974a7b..6511a88 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "@stdlib/assert-is-string": "^0.0.x", "@stdlib/blas-ext-base-gfill-by": "^0.0.x", "@stdlib/iter-length": "^0.0.x", - "@stdlib/string-format": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x", "@stdlib/symbol-iterator": "^0.0.x", "@stdlib/types": "^0.0.x" }, From 83b0fdd0973112e8440643db8b44853b56fe54b0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Jul 2022 10:23:34 +0000 Subject: [PATCH 003/117] Remove files --- index.d.ts | 427 -------- index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 3121 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 2156674..0000000 --- a/index.d.ts +++ /dev/null @@ -1,427 +0,0 @@ -/* -* @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. -*/ - -// TypeScript Version: 2.0 - -/// - -import { RealOrComplexTypedArray, DataType } from '@stdlib/types/array'; -import { Collection } from '@stdlib/types/object'; -import { IterableIterator } from '@stdlib/types/iter'; - -/** -* Array or typed array. -*/ -type ArrayOrTypedArray = Array | RealOrComplexTypedArray; - -/** -* Nullary callback function. -* -* @returns fill value -*/ -type Nullary = () => any; - -/** -* Unary callback function. -* -* @param i - current array index -* @returns fill value -*/ -type Unary = ( i: number ) => any; - -/** -* Callback function. -* -* @param i - current array index -* @returns fill value -*/ -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 -* -* @example -* var arr = filledarrayBy(); -* // returns -* -* @example -* var arr = filledarrayBy( 'float32' ); -* // returns -*/ -declare function filledarrayBy( dtype?: DataType ): ArrayOrTypedArray; // tslint:disable-line:unified-signatures - -/** -* Creates a filled array according to a provided callback function and having a specified `length`. -* -* @param length - array length -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* -* var arr = filledarrayBy( 5, constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( length: number, clbk: Callback, thisArg?: any ): ArrayOrTypedArray; // tslint:disable-line:max-line-length unified-signatures - -/** -* 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 -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* -* var arr = filledarrayBy( 5, 'float64', constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( length: number, dtype: DataType, clbk: Callback, thisArg?: any ): ArrayOrTypedArray; // tslint:disable-line:max-line-length unified-signatures - -/** -* Creates a filled array from another `array` according to a provided callback function. -* -* @param array - typed array or array-like object -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* -* 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; // tslint:disable-line:max-line-length 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 -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* -* 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; // tslint:disable-line:max-line-length unified-signatures - -/** -* Creates a filled array from an iterable according to a callback function. -* -* @param iterable - iterable -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* var iterConstant = require( `@stdlib/iter/constant` ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarrayBy( it, constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( iterable: IterableIterator, callback: Callback, thisArg?: any ): ArrayOrTypedArray; // tslint:disable-line:max-line-length 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 -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* var iterConstant = require( `@stdlib/iter/constant` ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* 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; // tslint:disable-line:max-line-length unified-signatures - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; // tslint:disable-line:max-line-length - -/** -* 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. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; // tslint:disable-line:max-line-length unified-signatures - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; // tslint:disable-line:max-line-length - -/** -* 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. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; // tslint:disable-line:max-line-length unified-signatures - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; // tslint:disable-line:max-line-length 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. -* -* @param buffer - `ArrayBuffer` -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; // tslint:disable-line:max-line-length unified-signatures - - -// EXPORTS // - -export = filledarrayBy; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 76ae662..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-ctors@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill-by@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled-by@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@esm/index.mjs";var y=r.isPrimitive,h=e.isPrimitive,g=t,f=i,v=a,j=n,b=s,c=o,w=l,E=p,x=m,k=u,T=d();function M(r,e,t){var i,a;for(i=[],a=-1;!r.next().done;)a+=1,i.push(e.call(t,a));return i}function V(r,e,t){var i;for(i=0;i1)throw new TypeError("invalid arguments. Must provide a length, typed array, array-like object, or an iterable.");if(null===(a=b(t)))throw new TypeError(k("invalid argument. Must provide a recognized data type. Value: `%s`.",t));return new a(0)}if(e<2)throw new TypeError("invalid arguments. Must provide a length, typed array, array-like object, or an iterable.");if(j(arguments[e-=1]))if(j(arguments[e-1])){if(r=arguments[e],i=arguments[e-=1],0===e)throw new TypeError("invalid arguments. Must provide a length, typed array, array-like object, or an iterable.")}else i=arguments[e];else{if(!(e>=2))throw new TypeError("invalid arguments. Must provide a length, typed array, array-like object, or an iterable.");if(r=arguments[e],!j(i=arguments[e-=1]))throw new TypeError(k("invalid argument. Callback argument must be a function. Value: `%s`.",i))}if((e-=1)>=0&&y(arguments[e])?(t=arguments[e],e-=1):t="float64",null===(a=b(t)))throw new TypeError(k("invalid argument. Must provide a recognized data type. Value: `%s`.",t));if("generic"===t){if(o=arguments[0],0===e){if(h(o)?s=o:g(o)&&(s=o.length),void 0!==s)return w(s,i,r);if(f(o))throw new Error("invalid arguments. Creating a generic array from an ArrayBuffer is not supported.");if(v(o)){if(!1===T)throw new TypeError(k("invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.",o));if(!j(o[E]))throw new TypeError(k("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",o));if(o=o[E](),!j(o.next))throw new TypeError(k("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",o));return M(o,i,r)}throw new TypeError(k("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",o))}if(f(o))throw new Error("invalid arguments. Creating a generic array from an ArrayBuffer is not supported.");throw new TypeError(k("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",o))}if(0===e)if(g(o=arguments[0]))n=new a(o.length);else if(f(o))n=new a(o);else if(h(o))n=new a(o);else{if(!v(o))throw new TypeError(k("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",o));if(!1===T)throw new TypeError(k("invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.",o));if(!j(o[E]))throw new TypeError(k("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",o));if(o=o[E](),!j(o.next))throw new TypeError(k("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",o));n=new a(x(o))}else n=1===e?new a(arguments[0],arguments[1]):new a(arguments[0],arguments[1],arguments[2]);return n.length>0&&(/^complex/.test(t)?V(n,i,r):c(n.length,n,1,l)),n;function l(e,t){return i.call(r,t)}};export{C as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 3fc6a31..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","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 format = require( '@stdlib/string-format' );\n\n\n// VARIABLES //\n\nvar HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport();\nvar DEFAULT_DTYPE = 'float64';\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"],"names":["isString","require$$0","isPrimitive","isNonNegativeInteger","require$$1","isCollection","require$$2","isArrayBuffer","require$$3","isObject","require$$4","isFunction","require$$5","ctors","require$$6","gfillBy","require$$7","filledArray","require$$8","ITERATOR_SYMBOL","require$$10","iterLength","require$$11","format","require$$12","HAS_ITERATOR_SYMBOL","require$$9","filledArrayIterator","it","clbk","thisArg","arr","i","next","done","push","call","filledAccessors","length","set","lib","nargs","dtype","ctor","len","arg","arguments","TypeError","Error","test","callback","value","aidx"],"mappings":";;0mCAsBA,IAAIA,EAAWC,EAAsCC,YACjDC,EAAuBC,EAAmDF,YAC1EG,EAAeC,EACfC,EAAgBC,EAChBC,EAAWC,EACXC,EAAaC,EACbC,EAAQC,EACRC,EAAUC,EACVC,EAAcC,EAEdC,EAAkBC,EAClBC,EAAaC,EACbC,EAASC,EAKTC,EAR2BC,IAuB/B,SAASC,EAAqBC,EAAIC,EAAMC,GACvC,IAAIC,EACAC,EAKJ,IAFAD,EAAM,GACNC,GAAK,GAEAJ,EAAGK,OACAC,MAGPF,GAAK,EACLD,EAAII,KAAMN,EAAKO,KAAMN,EAASE,IAE/B,OAAOD,EAYR,SAASM,EAAiBN,EAAKF,EAAMC,GACpC,IAAIE,EACJ,IAAMA,EAAI,EAAGA,EAAID,EAAIO,OAAQN,IAC5BD,EAAIQ,IAAKV,EAAKO,KAAMN,EAASE,GAAKA,GAEnC,OAAOD,EAsUR,IC7NAS,EDoDA,WACC,IAAIV,EACAW,EACAC,EACAb,EACAc,EACAZ,EACAa,EACAC,EAKJ,GAAe,KAHfJ,EAAQK,UAAUR,QAKjB,OAAO,IADPK,EAAO9B,EAzNW,YA0ND,GAIlB,GAAKb,EADL0C,EAAQI,UAAW,IACM,CAExB,GAAKL,EAAQ,EACZ,MAAM,IAAIM,UAAW,6FAGtB,GAAc,QADdJ,EAAO9B,EAAO6B,IAEb,MAAM,IAAIK,UAAWxB,EAAQ,sEAAuEmB,IAGrG,OAAO,IAAIC,EAAM,GAGlB,GAAKF,EAAQ,EACZ,MAAM,IAAIM,UAAW,6FAMtB,GAAKpC,EAAYmC,UAHjBL,GAAS,IAKR,GAAK9B,EAAYmC,UAAWL,EAAM,KAMjC,GALAX,EAAUgB,UAAWL,GAErBZ,EAAOiB,UADPL,GAAS,GAIM,IAAVA,EACJ,MAAM,IAAIM,UAAW,kGAItBlB,EAAOiB,UAAWL,OAIf,CAAA,KAAKA,GAAS,GAUlB,MAAM,IAAIM,UAAW,6FANrB,GAHAjB,EAAUgB,UAAWL,IAGf9B,EADNkB,EAAOiB,UADPL,GAAS,IAGR,MAAM,IAAIM,UAAWxB,EAAQ,uEAAwEM,IAgBvG,IARAY,GAAS,IACK,GAAKzC,EAAU8C,UAAWL,KACvCC,EAAQI,UAAWL,GACnBA,GAAS,GAETC,EArRkB,UAwRL,QADdC,EAAO9B,EAAO6B,IAEb,MAAM,IAAIK,UAAWxB,EAAQ,sEAAuEmB,IAGrG,GAAe,YAAVA,EAAsB,CAE1B,GADAG,EAAMC,UAAW,GACF,IAAVL,EAAc,CAMlB,GALKtC,EAAsB0C,GAC1BD,EAAMC,EACKxC,EAAcwC,KACzBD,EAAMC,EAAIP,aAEE,IAARM,EACJ,OAAO3B,EAAa2B,EAAKf,EAAMC,GAEhC,GAAKvB,EAAesC,GACnB,MAAM,IAAIG,MAAO,qFAElB,GAAKvC,EAAUoC,GAAQ,CACtB,IAA6B,IAAxBpB,EACJ,MAAM,IAAIsB,UAAWxB,EAAQ,sIAAuIsB,IAErK,IAAMlC,EAAYkC,EAAK1B,IACtB,MAAM,IAAI4B,UAAWxB,EAAQ,wGAAyGsB,IAGvI,GADAA,EAAMA,EAAK1B,MACLR,EAAYkC,EAAIZ,MACrB,MAAM,IAAIc,UAAWxB,EAAQ,wGAAyGsB,IAEvI,OAAOlB,EAAqBkB,EAAKhB,EAAMC,GAExC,MAAM,IAAIiB,UAAWxB,EAAQ,wGAAyGsB,IAChI,GAAKtC,EAAesC,GAC1B,MAAM,IAAIG,MAAO,qFAElB,MAAM,IAAID,UAAWxB,EAAQ,wGAAyGsB,IAEvI,GAAe,IAAVJ,EAEJ,GAAKpC,EADLwC,EAAMC,UAAW,IAEhBf,EAAM,IAAIY,EAAME,EAAIP,aACd,GAAK/B,EAAesC,GAC1Bd,EAAM,IAAIY,EAAME,QACV,GAAK1C,EAAsB0C,GACjCd,EAAM,IAAIY,EAAME,OACV,CAAA,IAAKpC,EAAUoC,GAarB,MAAM,IAAIE,UAAWxB,EAAQ,wGAAyGsB,IAZtI,IAA6B,IAAxBpB,EACJ,MAAM,IAAIsB,UAAWxB,EAAQ,sIAAuIsB,IAErK,IAAMlC,EAAYkC,EAAK1B,IACtB,MAAM,IAAI4B,UAAWxB,EAAQ,wGAAyGsB,IAGvI,GADAA,EAAMA,EAAK1B,MACLR,EAAYkC,EAAIZ,MACrB,MAAM,IAAIc,UAAWxB,EAAQ,wGAAyGsB,IAEvId,EAAM,IAAIY,EAAMtB,EAAYwB,SAK7Bd,EADqB,IAAVU,EACL,IAAIE,EAAMG,UAAU,GAAIA,UAAU,IAElC,IAAIH,EAAMG,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKf,EAAIO,OAAS,IACZ,WAAWW,KAAMP,GACrBL,EAAiBN,EAAKF,EAAMC,GAE5Bf,EAASgB,EAAIO,OAAQP,EAAK,EAAGmB,IAGxBnB,EAYP,SAASmB,EAAUC,EAAOC,GACzB,OAAOvB,EAAKO,KAAMN,EAASsB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 9bf7cc5..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 4b336257e478e29fb6bc20c6036dca299b179502 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Jul 2022 10:24:21 +0000 Subject: [PATCH 004/117] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 33 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 681 ---- .github/workflows/publish.yml | 157 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 178 - .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 41 +- benchmark/benchmark.js | 319 -- benchmark/benchmark.length.complex128.js | 98 - benchmark/benchmark.length.complex64.js | 98 - benchmark/benchmark.length.float32.js | 97 - benchmark/benchmark.length.float64.js | 97 - benchmark/benchmark.length.generic.js | 97 - benchmark/benchmark.length.int16.js | 97 - benchmark/benchmark.length.int32.js | 97 - benchmark/benchmark.length.int8.js | 97 - benchmark/benchmark.length.uint16.js | 97 - benchmark/benchmark.length.uint32.js | 97 - benchmark/benchmark.length.uint8.js | 97 - benchmark/benchmark.length.uint8c.js | 97 - branches.md | 53 - docs/repl.txt | 174 - docs/types/test.ts | 606 --- examples/index.js | 37 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 192 - lib/main.js | 413 -- package.json | 90 +- stats.html | 2689 +++++++++++++ test/test.js | 4248 --------------------- 49 files changed, 2714 insertions(+), 10170 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.length.complex128.js delete mode 100644 benchmark/benchmark.length.complex64.js delete mode 100644 benchmark/benchmark.length.float32.js delete mode 100644 benchmark/benchmark.length.float64.js delete mode 100644 benchmark/benchmark.length.generic.js delete mode 100644 benchmark/benchmark.length.int16.js delete mode 100644 benchmark/benchmark.length.int32.js delete mode 100644 benchmark/benchmark.length.int8.js delete mode 100644 benchmark/benchmark.length.uint16.js delete mode 100644 benchmark/benchmark.length.uint32.js delete mode 100644 benchmark/benchmark.length.uint8.js delete mode 100644 benchmark/benchmark.length.uint8c.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 7212d81..0000000 --- a/.gitattributes +++ /dev/null @@ -1,33 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 5034361..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-06-30T23:01:48.794Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 8be0b82..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 29bf533..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index a7a7f51..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.9.0 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index df9d9d7..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 39b1613..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 7ca169c..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '0 8 * * 6' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "::set-output name=package_name::$name" - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "::set-output name=data::$data" - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v2 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v2 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 128c22e..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,681 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the repository: - push: - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs rm -rf - - git add -A - git commit -m "Remove files" - - git merge -s recursive -X theirs origin/production --allow-unrelated-histories - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch or create new branch tag: - - name: 'Push changes to `deno` branch or create new branch tag' - run: | - SLUG=${{ github.repository }} - VERSION=$(echo ${{ github.ref }} | sed -E -n 's/refs\/tags\/?(v[0-9]+.[0-9]+.[0-9]+).*/\1/p') - if [ -z "$VERSION" ]; then - echo "Workflow job was not triggered by a new tag...." - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - else - echo "Workflow job was triggered by a new tag: $VERSION" - echo "Creating new bundle branch tag of the form $VERSION-deno" - git tag -a $VERSION-deno -m "$VERSION-deno" - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" $VERSION-deno - fi - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs rm -rf - - git add -A - git commit -m "Remove files" - - git merge -s recursive -X theirs origin/production --allow-unrelated-histories - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "::set-output name=alias::${alias}" - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -273,7 +266,7 @@ for ( i = 0; i < dt.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 421b48e..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,319 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); -var isArray = require( '@stdlib/assert-is-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var pkg = require( './../package.json' ).name; -var filledarrayBy = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 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=float64', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'float64', 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=float32', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'float32', 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; - var i; - - clbk = constantFunction( new Complex128( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'complex128', 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=complex64', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( new Complex64( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'complex64', 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=int32', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int32', 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=uint32', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint32', 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=int16', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int16', 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=uint16', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint16', 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=int8', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int8', 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=uint8', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint8', 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=uint8c', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint8c', 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=generic', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'generic', clbk ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.length.complex128.js b/benchmark/benchmark.length.complex128.js deleted file mode 100644 index 671de86..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var Complex128 = require( '@stdlib/complex-float64' ); -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( new Complex128( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'complex128', 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=complex128,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.complex64.js b/benchmark/benchmark.length.complex64.js deleted file mode 100644 index 52da4e3..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var Complex64 = require( '@stdlib/complex-float32' ); -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( new Complex64( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'complex64', 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=complex64,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.float32.js b/benchmark/benchmark.length.float32.js deleted file mode 100644 index 9b4ef9b..0000000 --- a/benchmark/benchmark.length.float32.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'float32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=float32,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.float64.js b/benchmark/benchmark.length.float64.js deleted file mode 100644 index 66cb6b6..0000000 --- a/benchmark/benchmark.length.float64.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'float64', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=float64,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.generic.js b/benchmark/benchmark.length.generic.js deleted file mode 100644 index 5194c1b..0000000 --- a/benchmark/benchmark.length.generic.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isArray = require( '@stdlib/assert-is-array' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'generic', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isArray( 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=generic,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int16.js b/benchmark/benchmark.length.int16.js deleted file mode 100644 index 6669b28..0000000 --- a/benchmark/benchmark.length.int16.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int16', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=int16,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int32.js b/benchmark/benchmark.length.int32.js deleted file mode 100644 index e9c5c88..0000000 --- a/benchmark/benchmark.length.int32.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=int32,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int8.js b/benchmark/benchmark.length.int8.js deleted file mode 100644 index 14bbadf..0000000 --- a/benchmark/benchmark.length.int8.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int8', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=int8,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint16.js b/benchmark/benchmark.length.uint16.js deleted file mode 100644 index d03b23e..0000000 --- a/benchmark/benchmark.length.uint16.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint16', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint16,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint32.js b/benchmark/benchmark.length.uint32.js deleted file mode 100644 index 1382134..0000000 --- a/benchmark/benchmark.length.uint32.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint32,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint8.js b/benchmark/benchmark.length.uint8.js deleted file mode 100644 index c135d6c..0000000 --- a/benchmark/benchmark.length.uint8.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint8', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint8,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint8c.js b/benchmark/benchmark.length.uint8c.js deleted file mode 100644 index 2f7523a..0000000 --- a/benchmark/benchmark.length.uint8c.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint8c', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint8c,len='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 18101fd..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by" -click B href "https://github.com/stdlib-js/array-filled-by/tree/main" -click C href "https://github.com/stdlib-js/array-filled-by/tree/production" -click D href "https://github.com/stdlib-js/array-filled-by/tree/esm" -click E href "https://github.com/stdlib-js/array-filled-by/tree/deno" -click F href "https://github.com/stdlib-js/array-filled-by/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by -[production-url]: https://github.com/stdlib-js/array-filled-by/tree/production -[deno-url]: https://github.com/stdlib-js/array-filled-by/tree/deno -[umd-url]: https://github.com/stdlib-js/array-filled-by/tree/umd -[esm-url]: https://github.com/stdlib-js/array-filled-by/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 5a68984..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,174 +0,0 @@ - -{{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) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr = {{alias}}() - - > arr = {{alias}}( 'float32' ) - - - -{{alias}}( length[, dtype], clbk[, thisArg] ) - Returns a filled array according to a provided callback function and having - a specified length. - - Parameters - ---------- - length: integer - Array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > function clbk() { return 1.0; }; - > var arr = {{alias}}( 5, clbk ) - [ 1.0, 1.0, 1.0, 1.0, 1.0 ] - > arr = {{alias}}( 5, 'int32', clbk ) - [ 1, 1, 1, 1, 1 ] - - -{{alias}}( array[, dtype], clbk[, thisArg] ) - Creates a filled array from another array (or array-like object) according - to a provided callback function. - - Parameters - ---------- - array: ArrayLikeObject - Array from which to generate another array. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias}}( [ 0.5, 0.5, 0.5 ], {{alias:@stdlib/utils/constant-function}}( 2.0 ) ) - [ 2.0, 2.0, 2.0 ] - > var arr2 = {{alias}}( arr1, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( iterable[, dtype], clbk[, thisArg] ) - Creates a filled array from an iterable according to a provided callback - function. - - Parameters - ---------- - iterable: Iterable - Iterable from which to generate an array. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias:@stdlib/iter/constant}}( 3.0, {'iter': 3} ); - > var arr2 = {{alias}}( arr1, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( buffer[, byteOffset[, length]][, dtype], clbk[, thisArg] ) - Returns a filled typed array view of an ArrayBuffer according to a provided - callback function. - - The 'generic' array data type is *not* supported. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( buf, 0, 4, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0, 1.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 394ac49..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,606 +0,0 @@ -/* -* @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. -*/ - -/// - -import { IterableIterator } from '@stdlib/types/iter'; -import filledarrayBy = require( './index' ); - - -/** -* Returns an iterator protocol-compliant object. -* -* @returns iterator protocol-compliant object -*/ -function iterator(): IterableIterator { - const obj: IterableIterator = { - [Symbol.iterator]: iterator, - 'next': next - }; - return obj; -} - -/** -* Implements the iterator protocol `next` method. -* -* @returns iterator protocol-compliant object -*/ -function next(): any { - return { - 'value': 1.0, - 'done': false - }; -} - -/** -* Callback function. -* -* @param i - current array index -* @returns return value -*/ -function clbk( i: number ): number { - return i; -} - - -// TESTS // - -// The function returns an array or typed array... -{ - filledarrayBy(); // $ExpectType ArrayOrTypedArray - filledarrayBy( 'float32' ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( 10, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( 10, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( 10, 'int32', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( 10, 'int32', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const x = new Float64Array( 10 ); - filledarrayBy( x, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( x, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( x, 'uint8', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( x, 'uint8', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const y = [ 2.0, 2.0, 2.0 ]; - filledarrayBy( y, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( y, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( y, 'float64', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( y, 'float64', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const it = iterator(); - filledarrayBy( it, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( it, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( it, 'uint8c', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( it, 'uint8c', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const buf = new ArrayBuffer( 32 ); - filledarrayBy( buf, clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 'uint32', clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 'uint32', clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 8, clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 8, clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 8, 'uint16', clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 8, 'uint16', clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 8, 2, clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 8, 2, clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 8, 2, 'int16', clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 8, 2, 'int16', clbk, {} ); // $ExpectType RealOrComplexTypedArray -} - -// The compiler throws an error if a callback function argument is not a function... -{ - filledarrayBy( 'float64', '5' ); // $ExpectError - filledarrayBy( 'float64', 1.0 ); // $ExpectError - filledarrayBy( 'float64', false ); // $ExpectError - filledarrayBy( 'float64', true ); // $ExpectError - filledarrayBy( 'float64', null ); // $ExpectError - filledarrayBy( 'float64', undefined ); // $ExpectError - filledarrayBy( 'float64', [] ); // $ExpectError - filledarrayBy( 'float64', {} ); // $ExpectError - - filledarrayBy( 'float64', '5', {} ); // $ExpectError - filledarrayBy( 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( 'float64', false, {} ); // $ExpectError - filledarrayBy( 'float64', true, {} ); // $ExpectError - filledarrayBy( 'float64', null, {} ); // $ExpectError - filledarrayBy( 'float64', undefined, {} ); // $ExpectError - filledarrayBy( 'float64', [], {} ); // $ExpectError - filledarrayBy( 'float64', {}, {} ); // $ExpectError - - filledarrayBy( 10, '5' ); // $ExpectError - filledarrayBy( 10, 1.0 ); // $ExpectError - filledarrayBy( 10, false ); // $ExpectError - filledarrayBy( 10, true ); // $ExpectError - filledarrayBy( 10, null ); // $ExpectError - filledarrayBy( 10, undefined ); // $ExpectError - filledarrayBy( 10, [] ); // $ExpectError - filledarrayBy( 10, {} ); // $ExpectError - - filledarrayBy( 10, '5', {} ); // $ExpectError - filledarrayBy( 10, 1.0, {} ); // $ExpectError - filledarrayBy( 10, false, {} ); // $ExpectError - filledarrayBy( 10, true, {} ); // $ExpectError - filledarrayBy( 10, null, {} ); // $ExpectError - filledarrayBy( 10, undefined, {} ); // $ExpectError - filledarrayBy( 10, [], {} ); // $ExpectError - filledarrayBy( 10, {}, {} ); // $ExpectError - - filledarrayBy( 10, 'float64', '5' ); // $ExpectError - filledarrayBy( 10, 'float64', 1.0 ); // $ExpectError - filledarrayBy( 10, 'float64', false ); // $ExpectError - filledarrayBy( 10, 'float64', true ); // $ExpectError - filledarrayBy( 10, 'float64', null ); // $ExpectError - filledarrayBy( 10, 'float64', undefined ); // $ExpectError - filledarrayBy( 10, 'float64', [] ); // $ExpectError - filledarrayBy( 10, 'float64', {} ); // $ExpectError - - filledarrayBy( 10, 'float64', '5', {} ); // $ExpectError - filledarrayBy( 10, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( 10, 'float64', false, {} ); // $ExpectError - filledarrayBy( 10, 'float64', true, {} ); // $ExpectError - filledarrayBy( 10, 'float64', null, {} ); // $ExpectError - filledarrayBy( 10, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( 10, 'float64', [], {} ); // $ExpectError - filledarrayBy( 10, 'float64', {}, {} ); // $ExpectError - - const x = new Float64Array( 10 ); - filledarrayBy( x, '5' ); // $ExpectError - filledarrayBy( x, 1.0 ); // $ExpectError - filledarrayBy( x, false ); // $ExpectError - filledarrayBy( x, true ); // $ExpectError - filledarrayBy( x, null ); // $ExpectError - filledarrayBy( x, undefined ); // $ExpectError - filledarrayBy( x, [] ); // $ExpectError - filledarrayBy( x, {} ); // $ExpectError - - filledarrayBy( x, '5', {} ); // $ExpectError - filledarrayBy( x, 1.0, {} ); // $ExpectError - filledarrayBy( x, false, {} ); // $ExpectError - filledarrayBy( x, true, {} ); // $ExpectError - filledarrayBy( x, null, {} ); // $ExpectError - filledarrayBy( x, undefined, {} ); // $ExpectError - filledarrayBy( x, [], {} ); // $ExpectError - filledarrayBy( x, {}, {} ); // $ExpectError - - filledarrayBy( x, 'float64', '5' ); // $ExpectError - filledarrayBy( x, 'float64', 1.0 ); // $ExpectError - filledarrayBy( x, 'float64', false ); // $ExpectError - filledarrayBy( x, 'float64', true ); // $ExpectError - filledarrayBy( x, 'float64', null ); // $ExpectError - filledarrayBy( x, 'float64', undefined ); // $ExpectError - filledarrayBy( x, 'float64', [] ); // $ExpectError - filledarrayBy( x, 'float64', {} ); // $ExpectError - - filledarrayBy( x, 'float64', '5', {} ); // $ExpectError - filledarrayBy( x, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( x, 'float64', false, {} ); // $ExpectError - filledarrayBy( x, 'float64', true, {} ); // $ExpectError - filledarrayBy( x, 'float64', null, {} ); // $ExpectError - filledarrayBy( x, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( x, 'float64', [], {} ); // $ExpectError - filledarrayBy( x, 'float64', {}, {} ); // $ExpectError - - const y = [ 2.0, 2.0, 2.0 ]; - filledarrayBy( y, '5' ); // $ExpectError - filledarrayBy( y, 1.0 ); // $ExpectError - filledarrayBy( y, false ); // $ExpectError - filledarrayBy( y, true ); // $ExpectError - filledarrayBy( y, null ); // $ExpectError - filledarrayBy( y, undefined ); // $ExpectError - filledarrayBy( y, [] ); // $ExpectError - filledarrayBy( y, {} ); // $ExpectError - - filledarrayBy( y, '5', {} ); // $ExpectError - filledarrayBy( y, 1.0, {} ); // $ExpectError - filledarrayBy( y, false, {} ); // $ExpectError - filledarrayBy( y, true, {} ); // $ExpectError - filledarrayBy( y, null, {} ); // $ExpectError - filledarrayBy( y, undefined, {} ); // $ExpectError - filledarrayBy( y, [], {} ); // $ExpectError - filledarrayBy( y, {}, {} ); // $ExpectError - - filledarrayBy( y, 'float64', '5' ); // $ExpectError - filledarrayBy( y, 'float64', 1.0 ); // $ExpectError - filledarrayBy( y, 'float64', false ); // $ExpectError - filledarrayBy( y, 'float64', true ); // $ExpectError - filledarrayBy( y, 'float64', null ); // $ExpectError - filledarrayBy( y, 'float64', undefined ); // $ExpectError - filledarrayBy( y, 'float64', [] ); // $ExpectError - filledarrayBy( y, 'float64', {} ); // $ExpectError - - filledarrayBy( y, 'float64', '5', {} ); // $ExpectError - filledarrayBy( y, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( y, 'float64', false, {} ); // $ExpectError - filledarrayBy( y, 'float64', true, {} ); // $ExpectError - filledarrayBy( y, 'float64', null, {} ); // $ExpectError - filledarrayBy( y, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( y, 'float64', [], {} ); // $ExpectError - filledarrayBy( y, 'float64', {}, {} ); // $ExpectError - - const it = iterator(); - filledarrayBy( it, '5' ); // $ExpectError - filledarrayBy( it, 1.0 ); // $ExpectError - filledarrayBy( it, false ); // $ExpectError - filledarrayBy( it, true ); // $ExpectError - filledarrayBy( it, null ); // $ExpectError - filledarrayBy( it, undefined ); // $ExpectError - filledarrayBy( it, [] ); // $ExpectError - filledarrayBy( it, {} ); // $ExpectError - - filledarrayBy( it, '5', {} ); // $ExpectError - filledarrayBy( it, 1.0, {} ); // $ExpectError - filledarrayBy( it, false, {} ); // $ExpectError - filledarrayBy( it, true, {} ); // $ExpectError - filledarrayBy( it, null, {} ); // $ExpectError - filledarrayBy( it, undefined, {} ); // $ExpectError - filledarrayBy( it, [], {} ); // $ExpectError - filledarrayBy( it, {}, {} ); // $ExpectError - - filledarrayBy( it, 'float64', '5' ); // $ExpectError - filledarrayBy( it, 'float64', 1.0 ); // $ExpectError - filledarrayBy( it, 'float64', false ); // $ExpectError - filledarrayBy( it, 'float64', true ); // $ExpectError - filledarrayBy( it, 'float64', null ); // $ExpectError - filledarrayBy( it, 'float64', undefined ); // $ExpectError - filledarrayBy( it, 'float64', [] ); // $ExpectError - filledarrayBy( it, 'float64', {} ); // $ExpectError - - filledarrayBy( it, 'float64', '5', {} ); // $ExpectError - filledarrayBy( it, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( it, 'float64', false, {} ); // $ExpectError - filledarrayBy( it, 'float64', true, {} ); // $ExpectError - filledarrayBy( it, 'float64', null, {} ); // $ExpectError - filledarrayBy( it, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( it, 'float64', [], {} ); // $ExpectError - filledarrayBy( it, 'float64', {}, {} ); // $ExpectError - - const buf = new ArrayBuffer( 32 ); - filledarrayBy( buf, '5' ); // $ExpectError - filledarrayBy( buf, 1.0 ); // $ExpectError - filledarrayBy( buf, false ); // $ExpectError - filledarrayBy( buf, true ); // $ExpectError - filledarrayBy( buf, null ); // $ExpectError - filledarrayBy( buf, undefined ); // $ExpectError - filledarrayBy( buf, [] ); // $ExpectError - filledarrayBy( buf, {} ); // $ExpectError - - filledarrayBy( buf, '5', {} ); // $ExpectError - filledarrayBy( buf, 1.0, {} ); // $ExpectError - filledarrayBy( buf, false, {} ); // $ExpectError - filledarrayBy( buf, true, {} ); // $ExpectError - filledarrayBy( buf, null, {} ); // $ExpectError - filledarrayBy( buf, undefined, {} ); // $ExpectError - filledarrayBy( buf, [], {} ); // $ExpectError - filledarrayBy( buf, {}, {} ); // $ExpectError - - filledarrayBy( buf, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 'float64', false ); // $ExpectError - filledarrayBy( buf, 'float64', true ); // $ExpectError - filledarrayBy( buf, 'float64', null ); // $ExpectError - filledarrayBy( buf, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 'float64', {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5' ); // $ExpectError - filledarrayBy( buf, 8, 1.0 ); // $ExpectError - filledarrayBy( buf, 8, false ); // $ExpectError - filledarrayBy( buf, 8, true ); // $ExpectError - filledarrayBy( buf, 8, null ); // $ExpectError - filledarrayBy( buf, 8, undefined ); // $ExpectError - filledarrayBy( buf, 8, [] ); // $ExpectError - filledarrayBy( buf, 8, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, false, {} ); // $ExpectError - filledarrayBy( buf, 8, true, {} ); // $ExpectError - filledarrayBy( buf, 8, null, {} ); // $ExpectError - filledarrayBy( buf, 8, undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, [], {} ); // $ExpectError - filledarrayBy( buf, 8, {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 8, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 'float64', false ); // $ExpectError - filledarrayBy( buf, 8, 'float64', true ); // $ExpectError - filledarrayBy( buf, 8, 'float64', null ); // $ExpectError - filledarrayBy( buf, 8, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 8, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 8, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 8, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, '5' ); // $ExpectError - filledarrayBy( buf, 8, 2, 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 2, false ); // $ExpectError - filledarrayBy( buf, 8, 2, true ); // $ExpectError - filledarrayBy( buf, 8, 2, null ); // $ExpectError - filledarrayBy( buf, 8, 2, undefined ); // $ExpectError - filledarrayBy( buf, 8, 2, [] ); // $ExpectError - filledarrayBy( buf, 8, 2, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, false, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, true, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, null, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, [], {} ); // $ExpectError - filledarrayBy( buf, 8, 2, {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', false ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', true ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', null ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', {}, {} ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid length, typed array, array-like object, `ArrayBuffer`, or iterable argument... -{ - filledarrayBy( false, clbk ); // $ExpectError - filledarrayBy( true, clbk ); // $ExpectError - filledarrayBy( null, clbk ); // $ExpectError - filledarrayBy( {}, clbk ); // $ExpectError - - filledarrayBy( false, clbk, {} ); // $ExpectError - filledarrayBy( true, clbk, {} ); // $ExpectError - filledarrayBy( null, clbk, {} ); // $ExpectError - filledarrayBy( {}, clbk, {} ); // $ExpectError - - filledarrayBy( false, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 'float64', clbk ); // $ExpectError - - filledarrayBy( false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, clbk ); // $ExpectError - filledarrayBy( 1.0, 8, clbk ); // $ExpectError - filledarrayBy( false, 8, clbk ); // $ExpectError - filledarrayBy( true, 8, clbk ); // $ExpectError - filledarrayBy( null, 8, clbk ); // $ExpectError - filledarrayBy( undefined, 8, clbk ); // $ExpectError - filledarrayBy( [], 8, clbk ); // $ExpectError - filledarrayBy( {}, 8, clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, clbk ); // $ExpectError - - filledarrayBy( '5', 8, clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, clbk, {} ); // $ExpectError - filledarrayBy( false, 8, clbk, {} ); // $ExpectError - filledarrayBy( true, 8, clbk, {} ); // $ExpectError - filledarrayBy( null, 8, clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, clbk, {} ); // $ExpectError - filledarrayBy( [], 8, clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 'float64', clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( false, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( [], 8, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 'float64', clbk ); // $ExpectError - - filledarrayBy( '5', 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 2, clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 2, clbk ); // $ExpectError - filledarrayBy( false, 8, 2, clbk ); // $ExpectError - filledarrayBy( true, 8, 2, clbk ); // $ExpectError - filledarrayBy( null, 8, 2, clbk ); // $ExpectError - filledarrayBy( undefined, 8, 2, clbk ); // $ExpectError - filledarrayBy( [], 8, 2, clbk ); // $ExpectError - filledarrayBy( {}, 8, 2, clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, clbk ); // $ExpectError - - filledarrayBy( '5', 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( false, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( [], 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, 'float64', clbk ); // $ExpectError - - filledarrayBy( '5', 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a byte offset argument which is not a number... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, false, clbk ); // $ExpectError - filledarrayBy( buf, true, clbk ); // $ExpectError - filledarrayBy( buf, null, clbk ); // $ExpectError - filledarrayBy( buf, [], clbk ); // $ExpectError - filledarrayBy( buf, {}, clbk ); // $ExpectError - - filledarrayBy( buf, false, clbk, {} ); // $ExpectError - filledarrayBy( buf, true, clbk, {} ); // $ExpectError - filledarrayBy( buf, null, clbk, {} ); // $ExpectError - filledarrayBy( buf, [], clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, clbk, {} ); // $ExpectError - - filledarrayBy( buf, '5', 'float64', clbk ); // $ExpectError - filledarrayBy( buf, false, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, true, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, null, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, [], 'float64', clbk ); // $ExpectError - filledarrayBy( buf, {}, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, '5', 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( buf, false, 2, clbk ); // $ExpectError - filledarrayBy( buf, true, 2, clbk ); // $ExpectError - filledarrayBy( buf, null, 2, clbk ); // $ExpectError - filledarrayBy( buf, [], 2, clbk ); // $ExpectError - filledarrayBy( buf, {}, 2, clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, clbk ); // $ExpectError - - filledarrayBy( buf, false, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, clbk, {} ); // $ExpectError - - filledarrayBy( buf, '5', 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, false, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, true, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, null, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, undefined, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, [], 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, {}, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, '5', 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, false, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, undefined, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a view length argument which is not a number... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, 8, false, clbk ); // $ExpectError - filledarrayBy( buf, 8, true, clbk ); // $ExpectError - filledarrayBy( buf, 8, null, clbk ); // $ExpectError - filledarrayBy( buf, 8, [], clbk ); // $ExpectError - filledarrayBy( buf, 8, {}, clbk ); // $ExpectError - - filledarrayBy( buf, 8, false, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, true, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, null, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, [], clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, {}, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, clbk, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5', 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, false, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, true, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, null, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, [], 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, {}, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, 8, '5', 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, [], 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, {}, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided too many arguments... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, 8, 2, 'float64', 1, clbk, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 997a381..0000000 --- a/examples/index.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ).factory; -var dtypes = require( '@stdlib/array-typed-real-dtypes' ); -var filledarrayBy = require( './../lib' ); - -// Create a pseudorandom number generator: -var rand = discreteUniform( 0, 100 ); - -// Get a list of array data types: -var dt = dtypes(); - -// Generate filled arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = filledarrayBy( 10, dt[ i ], rand ); - console.log( arr ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 3fc2784..2156674 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { RealOrComplexTypedArray, DataType } from '@stdlib/types/array'; import { Collection } from '@stdlib/types/object'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..ea454f9 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-ctors@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill-by@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled-by@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";var w=d();function j(r,e,t){var s,i;for(s=[],i=-1;!r.next().done;)i+=1,s.push(e.call(t,i));return s}function a(r,e,t){var s;for(s=0;s1)throw new TypeError(p("00L05"));if(null===(b=o(g)))throw new TypeError(p("00L2k",g));return new b(0)}if(c<2)throw new TypeError(p("00L05"));if(n(arguments[c-=1]))if(n(arguments[c-1])){if(d=arguments[c],y=arguments[c-=1],0===c)throw new TypeError(p("00L05"))}else y=arguments[c];else{if(!(c>=2))throw new TypeError(p("00L05"));if(d=arguments[c],!n(y=arguments[c-=1]))throw new TypeError(p("00L2n",y))}if((c-=1)>=0&&r(arguments[c])?(g=arguments[c],c-=1):g="float64",null===(b=o(g)))throw new TypeError(p("00L2k",g));if("generic"===g){if(x=arguments[0],0===c){if(e(x)?u=x:t(x)&&(u=x.length),void 0!==u)return m(u,y,d);if(s(x))throw new Error(p("00L04"));if(i(x)){if(!1===w)throw new TypeError(p("00L2l",x));if(!n(x[f]))throw new TypeError(p("00L2m",x));if(x=x[f](),!n(x.next))throw new TypeError(p("00L2m",x));return j(x,y,d)}throw new TypeError(p("00L2m",x))}if(s(x))throw new Error(p("00L04"));throw new TypeError(p("00L2m",x))}if(0===c)if(t(x=arguments[0]))v=new b(x.length);else if(s(x))v=new b(x);else if(e(x))v=new b(x);else{if(!i(x))throw new TypeError(p("00L2m",x));if(!1===w)throw new TypeError(p("00L2l",x));if(!n(x[f]))throw new TypeError(p("00L2m",x));if(x=x[f](),!n(x.next))throw new TypeError(p("00L2m",x));v=new b(h(x))}else v=1===c?new b(arguments[0],arguments[1]):new b(arguments[0],arguments[1],arguments[2]);return v.length>0&&(/^complex/.test(g)?a(v,y,d):l(v.length,v,1,E)),v;function E(r,e){return y.call(d,e)}}export{c as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..d359dd2 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.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\nimport { isPrimitive as isString } from '@stdlib/assert-is-string' ;\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer' ;\nimport isCollection from '@stdlib/assert-is-collection' ;\nimport isArrayBuffer from '@stdlib/assert-is-arraybuffer' ;\nimport isObject from '@stdlib/assert-is-object' ;\nimport isFunction from '@stdlib/assert-is-function' ;\nimport ctors from '@stdlib/array-ctors' ;\nimport gfillBy from '@stdlib/blas-ext-base-gfill-by' ;\nimport filledArray from '@stdlib/array-base-filled-by' ;\nimport hasIteratorSymbolSupport from '@stdlib/assert-has-iterator-symbol-support' ;\nimport ITERATOR_SYMBOL from '@stdlib/symbol-iterator' ;\nimport iterLength from '@stdlib/iter-length' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\n\n\n// VARIABLES //\n\nvar HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport();\nvar DEFAULT_DTYPE = 'float64';\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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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( format( '00L05' ) );\n\t\t}\n\t\tctor = ctors( dtype );\n\t\tif ( ctor === null ) {\n\t\t\tthrow new TypeError( format( '00L2k', 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( format( '00L05' ) );\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( format( '00L05' ) );\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( '00L2n', 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( format( '00L05' ) );\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( '00L2k', 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( format( '00L04' ) );\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( '00L2l', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00L2m', 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( '00L2m', 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( '00L2m', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format( '00L04' ) );\n\t\t}\n\t\tthrow new TypeError( format( '00L2m', 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( '00L2l', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00L2m', 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( '00L2m', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00L2m', 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\nexport default filledarrayBy;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","filledArrayIterator","it","clbk","thisArg","arr","i","next","done","push","call","filledAccessors","length","set","filledarrayBy","nargs","dtype","ctor","len","arg","arguments","ctors","isString","TypeError","format","isFunction","isNonNegativeInteger","isCollection","filledArray","isArrayBuffer","Error","isObject","ITERATOR_SYMBOL","iterLength","test","gfillBy","callback","value","aidx"],"mappings":";;ipCAuCA,IAAIA,EAAsBC,IAe1B,SAASC,EAAqBC,EAAIC,EAAMC,GACvC,IAAIC,EACAC,EAKJ,IAFAD,EAAM,GACNC,GAAK,GAEAJ,EAAGK,OACAC,MAGPF,GAAK,EACLD,EAAII,KAAMN,EAAKO,KAAMN,EAASE,IAE/B,OAAOD,EAYR,SAASM,EAAiBN,EAAKF,EAAMC,GACpC,IAAIE,EACJ,IAAMA,EAAI,EAAGA,EAAID,EAAIO,OAAQN,IAC5BD,EAAIQ,IAAKV,EAAKO,KAAMN,EAASE,GAAKA,GAEnC,OAAOD,EA6JR,SAASS,IACR,IAAIV,EACAW,EACAC,EACAb,EACAc,EACAZ,EACAa,EACAC,EAKJ,GAAe,KAHfJ,EAAQK,UAAUR,QAKjB,OAAO,IADPK,EAAOI,EAzNW,YA0ND,GAIlB,GAAKC,EADLN,EAAQI,UAAW,IACM,CAExB,GAAKL,EAAQ,EACZ,MAAM,IAAIQ,UAAWC,EAAQ,UAG9B,GAAc,QADdP,EAAOI,EAAOL,IAEb,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAGvC,OAAO,IAAIC,EAAM,GAGlB,GAAKF,EAAQ,EACZ,MAAM,IAAIQ,UAAWC,EAAQ,UAM9B,GAAKC,EAAYL,UAHjBL,GAAS,IAKR,GAAKU,EAAYL,UAAWL,EAAM,KAMjC,GALAX,EAAUgB,UAAWL,GAErBZ,EAAOiB,UADPL,GAAS,GAIM,IAAVA,EACJ,MAAM,IAAIQ,UAAWC,EAAQ,eAI9BrB,EAAOiB,UAAWL,OAIf,MAAKA,GAAS,GAUlB,MAAM,IAAIQ,UAAWC,EAAQ,UAN7B,GAHApB,EAAUgB,UAAWL,IAGfU,EADNtB,EAAOiB,UADPL,GAAS,IAGR,MAAM,IAAIQ,UAAWC,EAAQ,QAASrB,IAgBxC,IARAY,GAAS,IACK,GAAKO,EAAUF,UAAWL,KACvCC,EAAQI,UAAWL,GACnBA,GAAS,GAETC,EArRkB,UAwRL,QADdC,EAAOI,EAAOL,IAEb,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAGvC,GAAe,YAAVA,EAAsB,CAE1B,GADAG,EAAMC,UAAW,GACF,IAAVL,EAAc,CAMlB,GALKW,EAAsBP,GAC1BD,EAAMC,EACKQ,EAAcR,KACzBD,EAAMC,EAAIP,aAEE,IAARM,EACJ,OAAOU,EAAaV,EAAKf,EAAMC,GAEhC,GAAKyB,EAAeV,GACnB,MAAM,IAAIW,MAAON,EAAQ,UAE1B,GAAKO,EAAUZ,GAAQ,CACtB,IAA6B,IAAxBpB,EACJ,MAAM,IAAIwB,UAAWC,EAAQ,QAASL,IAEvC,IAAMM,EAAYN,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASL,IAGvC,GADAA,EAAMA,EAAKa,MACLP,EAAYN,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,QAASL,IAEvC,OAAOlB,EAAqBkB,EAAKhB,EAAMC,GAExC,MAAM,IAAImB,UAAWC,EAAQ,QAASL,IAChC,GAAKU,EAAeV,GAC1B,MAAM,IAAIW,MAAON,EAAQ,UAE1B,MAAM,IAAID,UAAWC,EAAQ,QAASL,IAEvC,GAAe,IAAVJ,EAEJ,GAAKY,EADLR,EAAMC,UAAW,IAEhBf,EAAM,IAAIY,EAAME,EAAIP,aACd,GAAKiB,EAAeV,GAC1Bd,EAAM,IAAIY,EAAME,QACV,GAAKO,EAAsBP,GACjCd,EAAM,IAAIY,EAAME,OACV,KAAKY,EAAUZ,GAarB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAZtC,IAA6B,IAAxBpB,EACJ,MAAM,IAAIwB,UAAWC,EAAQ,QAASL,IAEvC,IAAMM,EAAYN,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASL,IAGvC,GADAA,EAAMA,EAAKa,MACLP,EAAYN,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,QAASL,IAEvCd,EAAM,IAAIY,EAAMgB,EAAYd,SAK7Bd,EADqB,IAAVU,EACL,IAAIE,EAAMG,UAAU,GAAIA,UAAU,IAElC,IAAIH,EAAMG,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKf,EAAIO,OAAS,IACZ,WAAWsB,KAAMlB,GACrBL,EAAiBN,EAAKF,EAAMC,GAE5B+B,EAAS9B,EAAIO,OAAQP,EAAK,EAAG+B,IAGxB/B,EAYP,SAAS+B,EAAUC,EAAOC,GACzB,OAAOnC,EAAKO,KAAMN,EAASkC"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d115cf0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,192 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -/** -* Create a filled array according to a provided callback function. -* -* @module @stdlib/array-filled-by -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* var arr = filledarrayBy(); -* // returns -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'generic', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( [ 0.5, 0.5 ], clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1; -* } -* -* var arr = filledarrayBy( [ 5, -3 ], 'int32', clbk ); -* // returns [ 1, 1 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk1() { -* return 10; -* } -* -* function clbk2() { -* return 1.0; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, clbk2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk1() { -* return 1.0; -* } -* -* function clbk2() { -* return 2; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, 'uint32', clbk2 ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 'float32', clbk ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, clbk ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, 'int32', clbk ); -* // returns [ 1, 1 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index d6fbe5e..0000000 --- a/lib/main.js +++ /dev/null @@ -1,413 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var isCollection = require( '@stdlib/assert-is-collection' ); -var isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isObject = require( '@stdlib/assert-is-object' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var ctors = require( '@stdlib/array-ctors' ); -var gfillBy = require( '@stdlib/blas-ext-base-gfill-by' ); -var filledArray = require( '@stdlib/array-base-filled-by' ); -var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var iterLength = require( '@stdlib/iter-length' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport(); -var DEFAULT_DTYPE = 'float64'; - - -// FUNCTIONS // - -/** -* Creates a filled "generic" array from an iterator. -* -* @private -* @param {Iterable} it - iterator -* @param {Callback} clbk - callback function -* @param {*} thisArg - callback function execution context -* @returns {Array} filled array -*/ -function filledArrayIterator( it, clbk, thisArg ) { - var arr; - var i; - var v; - - arr = []; - i = -1; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - i += 1; - arr.push( clbk.call( thisArg, i ) ); - } - return arr; -} - -/** -* Fills an array exposing accessors for getting and setting array elements. -* -* @private -* @param {Collection} arr - input array -* @param {Callback} clbk - callback function -* @param {*} thisArg - callback function execution context -* @returns {Collection} input array -*/ -function filledAccessors( arr, clbk, thisArg ) { - var i; - for ( i = 0; i < arr.length; i++ ) { - arr.set( clbk.call( thisArg, i ), i ); - } - return arr; -} - - -// MAIN // - -/** -* Creates a filled array according to a provided callback function. -* -* @param {(NonNegativeInteger|TypedArray|ArrayLikeObject|ArrayBuffer|Iterable)} [arg] - a length, typed array, array-like object, buffer, or iterable -* @param {NonNegativeInteger} [byteOffset=0] - byte offset -* @param {NonNegativeInteger} [length] - view length -* @param {string} [dtype="float64"] - data type -* @param {Callback} [clbk] - callback to invoke -* @param {*} [thisArg] - callback execution context -* @throws {TypeError} must provide a recognized data type -* @throws {TypeError} must provide a length, typed array, array-like object, buffer, or iterable -* @throws {TypeError} callback argument must be a function. -* @throws {Error} creating a generic array from an `ArrayBuffer` is not supported -* @returns {(TypedArray|Array)} array or typed array -* -* @example -* var arr = filledarrayBy(); -* // returns -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'generic', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( [ 0.5, 0.5 ], clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1; -* } -* -* var arr = filledarrayBy( [ 5, -3 ], 'int32', clbk ); -* // returns [ 1, 1 ] -* -* @example -* function clbk1() { -* return 10; -* } -* -* function clbk2() { -* return 1.0; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, clbk2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk1() { -* return 1.0; -* } -* -* function clbk2() { -* return 2; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, 'uint32', clbk2 ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 'float32', clbk ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, clbk ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, 'int32', clbk ); -* // returns [ 1, 1 ] -*/ -function filledarrayBy() { - var thisArg; - var nargs; - var dtype; - var clbk; - var ctor; - var arr; - var len; - var arg; - - nargs = arguments.length; - - // If we weren't provided any arguments, return an empty array... - if ( nargs === 0 ) { - ctor = ctors( DEFAULT_DTYPE ); - return new ctor( 0 ); - } - // Check if we were provided a dtype as the first argument... - dtype = arguments[ 0 ]; - if ( isString( dtype ) ) { - // Invoking this function with arguments `f( dtype, clbk[, thisArg] )` is not allowed (otherwise, we'd need to also allow `f( clbk[, thisArg] )`)... - if ( nargs > 1 ) { - throw new TypeError( format( '00L05' ) ); - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '00L2k', dtype ) ); - } - // Return an empty array having the specified dtype: - return new ctor( 0 ); - } - // For all other supported invocations, we need at least two arguments... - if ( nargs < 2 ) { - throw new TypeError( format( '00L05' ) ); - } - // At this point, we need to do some argument juggling... - nargs -= 1; // henceforth, the number of available arguments is `nargs+1` - - // Determine whether the last argument is a callback or "this" context... - if ( isFunction( arguments[ nargs ] ) ) { - // 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... - if ( isFunction( arguments[ nargs-1 ] ) ) { - thisArg = arguments[ nargs ]; - nargs -= 1; - clbk = arguments[ nargs ]; - - // Check if we were provided only a callback and a "this" context.. - if ( nargs === 0 ) { - throw new TypeError( format( '00L05' ) ); - } - } else { - // "this" context is left undefined... - clbk = arguments[ nargs ]; - } - } - // 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... - else if ( nargs >= 2 ) { - thisArg = arguments[ nargs ]; - nargs -= 1; - clbk = arguments[ nargs ]; - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '00L2n', clbk ) ); - } - } - // If were were only provided 2 arguments and the last argument was not a function, we've been provided an insufficient number of arguments... - else { - throw new TypeError( format( '00L05' ) ); - } - // Now that we've processed the callback arguments, let's continue working backward to see if we've been provided a `dtype` argument... - nargs -= 1; - if ( nargs >= 0 && isString( arguments[ nargs ] ) ) { - dtype = arguments[ nargs ]; - nargs -= 1; - } else { - dtype = DEFAULT_DTYPE; - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '00L2k', dtype ) ); - } - // At this point, we've resolved the output array data type, and now we can actually create the output array... - if ( dtype === 'generic' ) { - arg = arguments[ 0 ]; - if ( nargs === 0 ) { - if ( isNonNegativeInteger( arg ) ) { - len = arg; - } else if ( isCollection( arg ) ) { - len = arg.length; - } - if ( len !== void 0 ) { - return filledArray( len, clbk, thisArg ); - } - if ( isArrayBuffer( arg ) ) { - throw new Error( format( '00L04' ) ); - } - if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( '00L2l', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00L2m', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00L2m', arg ) ); - } - return filledArrayIterator( arg, clbk, thisArg ); - } - throw new TypeError( format( '00L2m', arg ) ); - } else if ( isArrayBuffer( arg ) ) { - throw new Error( format( '00L04' ) ); - } - throw new TypeError( format( '00L2m', arg ) ); - } - if ( nargs === 0 ) { // length || array-like || ArrayBuffer || iterable - arg = arguments[ 0 ]; - if ( isCollection( arg ) ) { - arr = new ctor( arg.length ); - } else if ( isArrayBuffer( arg ) ) { - arr = new ctor( arg ); - } else if ( isNonNegativeInteger( arg ) ) { - arr = new ctor( arg ); - } else if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( '00L2l', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00L2m', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00L2m', arg ) ); - } - arr = new ctor( iterLength( arg ) ); - } else { - throw new TypeError( format( '00L2m', arg ) ); - } - } else if ( nargs === 1 ) { - arr = new ctor( arguments[0], arguments[1] ); // (ArrayBuffer, byteOffset) - } else { - arr = new ctor( arguments[0], arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset, length) - } - if ( arr.length > 0 ) { - if ( /^complex/.test( dtype ) ) { - filledAccessors( arr, clbk, thisArg ); - } else { - gfillBy( arr.length, arr, 1, callback ); - } - } - return arr; - - /** - * Callback which wraps a provided callback and is invoked for each array element. - * - * @private - * @param {*} value - element value - * @param {NonNegativeInteger} aidx - array index - * @param {NonNegativeInteger} sidx - strided index - * @param {Collection} array - input array/collection - * @returns {*} callback return value - */ - function callback( value, aidx ) { - return clbk.call( thisArg, aidx ); - } -} - - -// EXPORTS // - -module.exports = filledarrayBy; diff --git a/package.json b/package.json index 6511a88..498622b 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.2", "description": "Create a filled array according to a provided callback function.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,69 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-filled-by": "^0.0.x", - "@stdlib/array-ctors": "^0.0.x", - "@stdlib/assert-has-iterator-symbol-support": "^0.0.x", - "@stdlib/assert-is-arraybuffer": "^0.0.x", - "@stdlib/assert-is-collection": "^0.0.x", - "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/assert-is-nonnegative-integer": "^0.0.x", - "@stdlib/assert-is-object": "^0.0.x", - "@stdlib/assert-is-string": "^0.0.x", - "@stdlib/blas-ext-base-gfill-by": "^0.0.x", - "@stdlib/iter-length": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x", - "@stdlib/symbol-iterator": "^0.0.x", - "@stdlib/types": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-buffer": "^0.0.x", - "@stdlib/array-complex128": "^0.0.x", - "@stdlib/array-complex64": "^0.0.x", - "@stdlib/array-float32": "^0.0.x", - "@stdlib/array-float64": "^0.0.x", - "@stdlib/array-int16": "^0.0.x", - "@stdlib/array-int32": "^0.0.x", - "@stdlib/array-int8": "^0.0.x", - "@stdlib/array-typed-real-dtypes": "^0.0.x", - "@stdlib/array-uint16": "^0.0.x", - "@stdlib/array-uint32": "^0.0.x", - "@stdlib/array-uint8": "^0.0.x", - "@stdlib/array-uint8c": "^0.0.x", - "@stdlib/assert-instance-of": "^0.0.x", - "@stdlib/assert-is-array": "^0.0.x", - "@stdlib/assert-is-typed-array": "^0.0.x", - "@stdlib/assert-is-typed-array-like": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/complex-float32": "^0.0.x", - "@stdlib/complex-float64": "^0.0.x", - "@stdlib/iter-constant": "^0.0.x", - "@stdlib/math-base-special-pow": "^0.0.x", - "@stdlib/random-base-discrete-uniform": "^0.0.x", - "@stdlib/strided-base-reinterpret-complex128": "^0.0.x", - "@stdlib/strided-base-reinterpret-complex64": "^0.0.x", - "@stdlib/utils-constant-function": "^0.0.x", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..d058f65 --- /dev/null +++ b/stats.html @@ -0,0 +1,2689 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index b55aa4a..0000000 --- a/test/test.js +++ /dev/null @@ -1,4248 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 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. -*/ - -/* eslint-disable max-len */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -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 ArrayBuffer = require( '@stdlib/array-buffer' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var iterConstant = require( '@stdlib/iter-constant' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var filledarrayBy = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': !hasIteratorSymbolSupport() -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof filledarrayBy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if only provided callback arguments', function test( t ) { - t.throws( clbk1, TypeError, 'throws an error' ); - t.throws( clbk2, TypeError, 'throws an error' ); - t.throws( clbk3, TypeError, 'throws an error' ); - t.end(); - - function clbk1() { - filledarrayBy( constantFunction( 1.0 ) ); - } - - function clbk2() { - filledarrayBy( constantFunction( 1.0 ), {} ); - } - - function clbk3() { - filledarrayBy( constantFunction( 1.0 ), constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (only argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (typed array; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (array-like object)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (array-like object; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 8 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 8 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, 1, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (iterator)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( iterConstant( 1.0 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (iterator; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( iterConstant( 1.0 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if only provided data type and callback arguments', function test( t ) { - t.throws( clbk1, TypeError, 'throws an error' ); - t.throws( clbk2, TypeError, 'throws an error' ); - t.throws( clbk3, TypeError, 'throws an error' ); - t.end(); - - function clbk1() { - filledarrayBy( 'float64', constantFunction( 1.0 ) ); - } - - function clbk2() { - filledarrayBy( 'float64', constantFunction( 1.0 ), {} ); - } - - function clbk3() { - filledarrayBy( 'float64', constantFunction( 1.0 ), constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (array-like object)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (array-like object; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, 1, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, 1, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (no iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (no iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (non-function iterator symbol property)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (non-function iterator symbol property; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (`next` property is not a function)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ) ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (`next` property is not a function; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ), {} ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (no iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (no iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (non-function iterator symbol property)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (non-function iterator symbol property; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (`next` property is not a function)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ) ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (`next` property is not a function; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ), {} ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 1, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 1, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function returns a filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - arr = filledarrayBy(); - - t.strictEqual( instanceOf( arr, Float64Array ), 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=float64)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - arr = filledarrayBy( 'float64' ); - - t.strictEqual( instanceOf( arr, Float64Array ), 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=float32)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( 0 ); - arr = filledarrayBy( 'float32' ); - - t.strictEqual( instanceOf( arr, Float32Array ), 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; - - expected = new Complex128Array( 0 ); - arr = filledarrayBy( 'complex128' ); - - t.strictEqual( instanceOf( arr, Complex128Array ), 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=complex64)', function test( t ) { - var expected; - var arr; - - expected = new Complex64Array( 0 ); - arr = filledarrayBy( 'complex64' ); - - t.strictEqual( instanceOf( arr, Complex64Array ), 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=int32)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( 0 ); - arr = filledarrayBy( 'int32' ); - - t.strictEqual( instanceOf( arr, Int32Array ), 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=uint32)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( 0 ); - arr = filledarrayBy( 'uint32' ); - - t.strictEqual( instanceOf( arr, Uint32Array ), 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=int16)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( 0 ); - arr = filledarrayBy( 'int16' ); - - t.strictEqual( instanceOf( arr, Int16Array ), 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=uint16)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( 0 ); - arr = filledarrayBy( 'uint16' ); - - t.strictEqual( instanceOf( arr, Uint16Array ), 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=int8)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( 0 ); - arr = filledarrayBy( 'int8' ); - - t.strictEqual( instanceOf( arr, Int8Array ), 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=uint8)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( 0 ); - arr = filledarrayBy( 'uint8' ); - - t.strictEqual( instanceOf( arr, Uint8Array ), 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=uint8c)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( 0 ); - arr = filledarrayBy( 'uint8c' ); - - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), 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=generic)', function test( t ) { - var expected; - var arr; - - expected = []; - arr = filledarrayBy( 'generic' ); - - t.strictEqual( instanceOf( arr, Array ), 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 (default, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, length=0)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array(); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 0, clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, clbk, ctx ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (default, length; thisArg=function)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, clbk, context ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this(); // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } - - function context() { - ctx.count += 1; - } -}); - -tape( 'the function returns a filled array (dtype=float64, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, 'float64', clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, length; thisArg=function)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, 'float64', clbk, context ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this(); // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } - - function context() { - ctx.count += 1; - } -}); - -tape( 'the function returns a filled array (dtype=float32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, 'float32', clbk ); - - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex128, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = filledarrayBy( 5, 'complex128', clbk ); - - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = filledarrayBy( 5, 'complex64', clbk ); - - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int32Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int32', clbk ); - - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint32Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint32', clbk ); - - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int16Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int16', clbk ); - - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint16', clbk ); - - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int8Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int8', clbk ); - - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint8', clbk ); - - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint8c', clbk ); - - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = [ 1, 1, 1, 1, 1 ]; - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'generic', clbk ); - - t.strictEqual( instanceOf( arr, Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex128, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = [ 1.0, 2.0 ]; - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = [ 1.0, 2.0 ]; - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int32', clbk ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, typed array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, typed array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex128, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = new Float64Array( [ 1.0, 2.0 ] ); - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = new Float64Array( [ 1.0, 2.0 ] ); - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (default, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex128, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer, byteoffset; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer, byteoffset; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, 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; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 48 ); - out = filledarrayBy( buf, 16, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 24 ); - out = filledarrayBy( buf, 8, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int32', clbk ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint8c', clbk ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, 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; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 64 ); - out = filledarrayBy( buf, 16, 2, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset, length)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 1, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 1, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled array (default, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, iterator; thisArg)', opts, function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - ctx = { - 'count': 0 - }; - indices = []; - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, iterator; thisArg)', opts, function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - ctx = { - 'count': 0 - }; - indices = []; - out = filledarrayBy( arr, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex128, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = iterConstant( new Complex128( 3.0, 3.0 ), { - 'iter': 2 - }); - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = iterConstant( new Complex64( 3.0, 3.0 ), { - 'iter': 2 - }); - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); From cdd438c0cb28977b2b3ffcad6826518e1c0377ef Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Jul 2022 18:33:07 +0000 Subject: [PATCH 005/117] Transform error messages --- lib/main.js | 38 +++++++++++++++++++------------------- package.json | 2 +- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/lib/main.js b/lib/main.js index d27b055..d6fbe5e 100644 --- a/lib/main.js +++ b/lib/main.js @@ -32,7 +32,7 @@ var filledArray = require( '@stdlib/array-base-filled-by' ); var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); var iterLength = require( '@stdlib/iter-length' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -263,18 +263,18 @@ function filledarrayBy() { if ( isString( dtype ) ) { // Invoking this function with arguments `f( dtype, clbk[, thisArg] )` is not allowed (otherwise, we'd need to also allow `f( clbk[, thisArg] )`)... if ( nargs > 1 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format( '00L05' ) ); } ctor = ctors( dtype ); if ( ctor === null ) { - throw new TypeError( format( 'invalid argument. Must provide a recognized data type. Value: `%s`.', dtype ) ); + throw new TypeError( format( '00L2k', dtype ) ); } // Return an empty array having the specified dtype: return new ctor( 0 ); } // For all other supported invocations, we need at least two arguments... if ( nargs < 2 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format( '00L05' ) ); } // At this point, we need to do some argument juggling... nargs -= 1; // henceforth, the number of available arguments is `nargs+1` @@ -289,7 +289,7 @@ function filledarrayBy() { // Check if we were provided only a callback and a "this" context.. if ( nargs === 0 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format( '00L05' ) ); } } else { // "this" context is left undefined... @@ -302,12 +302,12 @@ function filledarrayBy() { nargs -= 1; clbk = arguments[ nargs ]; if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '00L2n', clbk ) ); } } // If were were only provided 2 arguments and the last argument was not a function, we've been provided an insufficient number of arguments... else { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format( '00L05' ) ); } // Now that we've processed the callback arguments, let's continue working backward to see if we've been provided a `dtype` argument... nargs -= 1; @@ -319,7 +319,7 @@ function filledarrayBy() { } ctor = ctors( dtype ); if ( ctor === null ) { - throw new TypeError( format( 'invalid argument. Must provide a recognized data type. Value: `%s`.', dtype ) ); + throw new TypeError( format( '00L2k', dtype ) ); } // At this point, we've resolved the output array data type, and now we can actually create the output array... if ( dtype === 'generic' ) { @@ -334,26 +334,26 @@ function filledarrayBy() { return filledArray( len, clbk, thisArg ); } if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format( '00L04' ) ); } if ( isObject( arg ) ) { if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.', arg ) ); + throw new TypeError( format( '00L2l', arg ) ); } if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00L2m', arg ) ); } arg = arg[ ITERATOR_SYMBOL ](); if ( !isFunction( arg.next ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00L2m', arg ) ); } return filledArrayIterator( arg, clbk, thisArg ); } - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00L2m', arg ) ); } else if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format( '00L04' ) ); } - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00L2m', arg ) ); } if ( nargs === 0 ) { // length || array-like || ArrayBuffer || iterable arg = arguments[ 0 ]; @@ -365,18 +365,18 @@ function filledarrayBy() { arr = new ctor( arg ); } else if ( isObject( arg ) ) { if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.', arg ) ); + throw new TypeError( format( '00L2l', arg ) ); } if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00L2m', arg ) ); } arg = arg[ ITERATOR_SYMBOL ](); if ( !isFunction( arg.next ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00L2m', arg ) ); } arr = new ctor( iterLength( arg ) ); } else { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00L2m', arg ) ); } } else if ( nargs === 1 ) { arr = new ctor( arguments[0], arguments[1] ); // (ArrayBuffer, byteOffset) diff --git a/package.json b/package.json index b974a7b..6511a88 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "@stdlib/assert-is-string": "^0.0.x", "@stdlib/blas-ext-base-gfill-by": "^0.0.x", "@stdlib/iter-length": "^0.0.x", - "@stdlib/string-format": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x", "@stdlib/symbol-iterator": "^0.0.x", "@stdlib/types": "^0.0.x" }, From e0c114dfb5d83274b8b6084a5cf02581e1af5181 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 2 Jul 2022 03:49:12 +0000 Subject: [PATCH 006/117] Remove files --- index.d.ts | 427 -------- index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 3121 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 2156674..0000000 --- a/index.d.ts +++ /dev/null @@ -1,427 +0,0 @@ -/* -* @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. -*/ - -// TypeScript Version: 2.0 - -/// - -import { RealOrComplexTypedArray, DataType } from '@stdlib/types/array'; -import { Collection } from '@stdlib/types/object'; -import { IterableIterator } from '@stdlib/types/iter'; - -/** -* Array or typed array. -*/ -type ArrayOrTypedArray = Array | RealOrComplexTypedArray; - -/** -* Nullary callback function. -* -* @returns fill value -*/ -type Nullary = () => any; - -/** -* Unary callback function. -* -* @param i - current array index -* @returns fill value -*/ -type Unary = ( i: number ) => any; - -/** -* Callback function. -* -* @param i - current array index -* @returns fill value -*/ -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 -* -* @example -* var arr = filledarrayBy(); -* // returns -* -* @example -* var arr = filledarrayBy( 'float32' ); -* // returns -*/ -declare function filledarrayBy( dtype?: DataType ): ArrayOrTypedArray; // tslint:disable-line:unified-signatures - -/** -* Creates a filled array according to a provided callback function and having a specified `length`. -* -* @param length - array length -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* -* var arr = filledarrayBy( 5, constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( length: number, clbk: Callback, thisArg?: any ): ArrayOrTypedArray; // tslint:disable-line:max-line-length unified-signatures - -/** -* 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 -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* -* var arr = filledarrayBy( 5, 'float64', constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( length: number, dtype: DataType, clbk: Callback, thisArg?: any ): ArrayOrTypedArray; // tslint:disable-line:max-line-length unified-signatures - -/** -* Creates a filled array from another `array` according to a provided callback function. -* -* @param array - typed array or array-like object -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* -* 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; // tslint:disable-line:max-line-length 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 -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* -* 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; // tslint:disable-line:max-line-length unified-signatures - -/** -* Creates a filled array from an iterable according to a callback function. -* -* @param iterable - iterable -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* var iterConstant = require( `@stdlib/iter/constant` ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarrayBy( it, constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( iterable: IterableIterator, callback: Callback, thisArg?: any ): ArrayOrTypedArray; // tslint:disable-line:max-line-length 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 -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* var iterConstant = require( `@stdlib/iter/constant` ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* 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; // tslint:disable-line:max-line-length unified-signatures - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; // tslint:disable-line:max-line-length - -/** -* 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. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; // tslint:disable-line:max-line-length unified-signatures - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; // tslint:disable-line:max-line-length - -/** -* 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. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; // tslint:disable-line:max-line-length unified-signatures - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; // tslint:disable-line:max-line-length 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. -* -* @param buffer - `ArrayBuffer` -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; // tslint:disable-line:max-line-length unified-signatures - - -// EXPORTS // - -export = filledarrayBy; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index ea454f9..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-ctors@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill-by@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled-by@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";var w=d();function j(r,e,t){var s,i;for(s=[],i=-1;!r.next().done;)i+=1,s.push(e.call(t,i));return s}function a(r,e,t){var s;for(s=0;s1)throw new TypeError(p("00L05"));if(null===(b=o(g)))throw new TypeError(p("00L2k",g));return new b(0)}if(c<2)throw new TypeError(p("00L05"));if(n(arguments[c-=1]))if(n(arguments[c-1])){if(d=arguments[c],y=arguments[c-=1],0===c)throw new TypeError(p("00L05"))}else y=arguments[c];else{if(!(c>=2))throw new TypeError(p("00L05"));if(d=arguments[c],!n(y=arguments[c-=1]))throw new TypeError(p("00L2n",y))}if((c-=1)>=0&&r(arguments[c])?(g=arguments[c],c-=1):g="float64",null===(b=o(g)))throw new TypeError(p("00L2k",g));if("generic"===g){if(x=arguments[0],0===c){if(e(x)?u=x:t(x)&&(u=x.length),void 0!==u)return m(u,y,d);if(s(x))throw new Error(p("00L04"));if(i(x)){if(!1===w)throw new TypeError(p("00L2l",x));if(!n(x[f]))throw new TypeError(p("00L2m",x));if(x=x[f](),!n(x.next))throw new TypeError(p("00L2m",x));return j(x,y,d)}throw new TypeError(p("00L2m",x))}if(s(x))throw new Error(p("00L04"));throw new TypeError(p("00L2m",x))}if(0===c)if(t(x=arguments[0]))v=new b(x.length);else if(s(x))v=new b(x);else if(e(x))v=new b(x);else{if(!i(x))throw new TypeError(p("00L2m",x));if(!1===w)throw new TypeError(p("00L2l",x));if(!n(x[f]))throw new TypeError(p("00L2m",x));if(x=x[f](),!n(x.next))throw new TypeError(p("00L2m",x));v=new b(h(x))}else v=1===c?new b(arguments[0],arguments[1]):new b(arguments[0],arguments[1],arguments[2]);return v.length>0&&(/^complex/.test(g)?a(v,y,d):l(v.length,v,1,E)),v;function E(r,e){return y.call(d,e)}}export{c as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index d359dd2..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.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\nimport { isPrimitive as isString } from '@stdlib/assert-is-string' ;\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer' ;\nimport isCollection from '@stdlib/assert-is-collection' ;\nimport isArrayBuffer from '@stdlib/assert-is-arraybuffer' ;\nimport isObject from '@stdlib/assert-is-object' ;\nimport isFunction from '@stdlib/assert-is-function' ;\nimport ctors from '@stdlib/array-ctors' ;\nimport gfillBy from '@stdlib/blas-ext-base-gfill-by' ;\nimport filledArray from '@stdlib/array-base-filled-by' ;\nimport hasIteratorSymbolSupport from '@stdlib/assert-has-iterator-symbol-support' ;\nimport ITERATOR_SYMBOL from '@stdlib/symbol-iterator' ;\nimport iterLength from '@stdlib/iter-length' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\n\n\n// VARIABLES //\n\nvar HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport();\nvar DEFAULT_DTYPE = 'float64';\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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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( format( '00L05' ) );\n\t\t}\n\t\tctor = ctors( dtype );\n\t\tif ( ctor === null ) {\n\t\t\tthrow new TypeError( format( '00L2k', 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( format( '00L05' ) );\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( format( '00L05' ) );\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( '00L2n', 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( format( '00L05' ) );\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( '00L2k', 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( format( '00L04' ) );\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( '00L2l', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00L2m', 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( '00L2m', 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( '00L2m', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format( '00L04' ) );\n\t\t}\n\t\tthrow new TypeError( format( '00L2m', 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( '00L2l', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00L2m', 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( '00L2m', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00L2m', 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\nexport default filledarrayBy;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","filledArrayIterator","it","clbk","thisArg","arr","i","next","done","push","call","filledAccessors","length","set","filledarrayBy","nargs","dtype","ctor","len","arg","arguments","ctors","isString","TypeError","format","isFunction","isNonNegativeInteger","isCollection","filledArray","isArrayBuffer","Error","isObject","ITERATOR_SYMBOL","iterLength","test","gfillBy","callback","value","aidx"],"mappings":";;ipCAuCA,IAAIA,EAAsBC,IAe1B,SAASC,EAAqBC,EAAIC,EAAMC,GACvC,IAAIC,EACAC,EAKJ,IAFAD,EAAM,GACNC,GAAK,GAEAJ,EAAGK,OACAC,MAGPF,GAAK,EACLD,EAAII,KAAMN,EAAKO,KAAMN,EAASE,IAE/B,OAAOD,EAYR,SAASM,EAAiBN,EAAKF,EAAMC,GACpC,IAAIE,EACJ,IAAMA,EAAI,EAAGA,EAAID,EAAIO,OAAQN,IAC5BD,EAAIQ,IAAKV,EAAKO,KAAMN,EAASE,GAAKA,GAEnC,OAAOD,EA6JR,SAASS,IACR,IAAIV,EACAW,EACAC,EACAb,EACAc,EACAZ,EACAa,EACAC,EAKJ,GAAe,KAHfJ,EAAQK,UAAUR,QAKjB,OAAO,IADPK,EAAOI,EAzNW,YA0ND,GAIlB,GAAKC,EADLN,EAAQI,UAAW,IACM,CAExB,GAAKL,EAAQ,EACZ,MAAM,IAAIQ,UAAWC,EAAQ,UAG9B,GAAc,QADdP,EAAOI,EAAOL,IAEb,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAGvC,OAAO,IAAIC,EAAM,GAGlB,GAAKF,EAAQ,EACZ,MAAM,IAAIQ,UAAWC,EAAQ,UAM9B,GAAKC,EAAYL,UAHjBL,GAAS,IAKR,GAAKU,EAAYL,UAAWL,EAAM,KAMjC,GALAX,EAAUgB,UAAWL,GAErBZ,EAAOiB,UADPL,GAAS,GAIM,IAAVA,EACJ,MAAM,IAAIQ,UAAWC,EAAQ,eAI9BrB,EAAOiB,UAAWL,OAIf,MAAKA,GAAS,GAUlB,MAAM,IAAIQ,UAAWC,EAAQ,UAN7B,GAHApB,EAAUgB,UAAWL,IAGfU,EADNtB,EAAOiB,UADPL,GAAS,IAGR,MAAM,IAAIQ,UAAWC,EAAQ,QAASrB,IAgBxC,IARAY,GAAS,IACK,GAAKO,EAAUF,UAAWL,KACvCC,EAAQI,UAAWL,GACnBA,GAAS,GAETC,EArRkB,UAwRL,QADdC,EAAOI,EAAOL,IAEb,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAGvC,GAAe,YAAVA,EAAsB,CAE1B,GADAG,EAAMC,UAAW,GACF,IAAVL,EAAc,CAMlB,GALKW,EAAsBP,GAC1BD,EAAMC,EACKQ,EAAcR,KACzBD,EAAMC,EAAIP,aAEE,IAARM,EACJ,OAAOU,EAAaV,EAAKf,EAAMC,GAEhC,GAAKyB,EAAeV,GACnB,MAAM,IAAIW,MAAON,EAAQ,UAE1B,GAAKO,EAAUZ,GAAQ,CACtB,IAA6B,IAAxBpB,EACJ,MAAM,IAAIwB,UAAWC,EAAQ,QAASL,IAEvC,IAAMM,EAAYN,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASL,IAGvC,GADAA,EAAMA,EAAKa,MACLP,EAAYN,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,QAASL,IAEvC,OAAOlB,EAAqBkB,EAAKhB,EAAMC,GAExC,MAAM,IAAImB,UAAWC,EAAQ,QAASL,IAChC,GAAKU,EAAeV,GAC1B,MAAM,IAAIW,MAAON,EAAQ,UAE1B,MAAM,IAAID,UAAWC,EAAQ,QAASL,IAEvC,GAAe,IAAVJ,EAEJ,GAAKY,EADLR,EAAMC,UAAW,IAEhBf,EAAM,IAAIY,EAAME,EAAIP,aACd,GAAKiB,EAAeV,GAC1Bd,EAAM,IAAIY,EAAME,QACV,GAAKO,EAAsBP,GACjCd,EAAM,IAAIY,EAAME,OACV,KAAKY,EAAUZ,GAarB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAZtC,IAA6B,IAAxBpB,EACJ,MAAM,IAAIwB,UAAWC,EAAQ,QAASL,IAEvC,IAAMM,EAAYN,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASL,IAGvC,GADAA,EAAMA,EAAKa,MACLP,EAAYN,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,QAASL,IAEvCd,EAAM,IAAIY,EAAMgB,EAAYd,SAK7Bd,EADqB,IAAVU,EACL,IAAIE,EAAMG,UAAU,GAAIA,UAAU,IAElC,IAAIH,EAAMG,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKf,EAAIO,OAAS,IACZ,WAAWsB,KAAMlB,GACrBL,EAAiBN,EAAKF,EAAMC,GAE5B+B,EAAS9B,EAAIO,OAAQP,EAAK,EAAG+B,IAGxB/B,EAYP,SAAS+B,EAAUC,EAAOC,GACzB,OAAOnC,EAAKO,KAAMN,EAASkC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index d058f65..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 0235c79049f87da4f4b5678310a3bc59d9ad7035 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 2 Jul 2022 03:49:59 +0000 Subject: [PATCH 007/117] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 33 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 681 ---- .github/workflows/publish.yml | 157 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 178 - .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 41 +- benchmark/benchmark.js | 319 -- benchmark/benchmark.length.complex128.js | 98 - benchmark/benchmark.length.complex64.js | 98 - benchmark/benchmark.length.float32.js | 97 - benchmark/benchmark.length.float64.js | 97 - benchmark/benchmark.length.generic.js | 97 - benchmark/benchmark.length.int16.js | 97 - benchmark/benchmark.length.int32.js | 97 - benchmark/benchmark.length.int8.js | 97 - benchmark/benchmark.length.uint16.js | 97 - benchmark/benchmark.length.uint32.js | 97 - benchmark/benchmark.length.uint8.js | 97 - benchmark/benchmark.length.uint8c.js | 97 - branches.md | 53 - docs/repl.txt | 174 - docs/types/test.ts | 606 --- examples/index.js | 37 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 192 - lib/main.js | 413 -- package.json | 90 +- stats.html | 2689 +++++++++++++ test/test.js | 4248 --------------------- 49 files changed, 2714 insertions(+), 10170 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.length.complex128.js delete mode 100644 benchmark/benchmark.length.complex64.js delete mode 100644 benchmark/benchmark.length.float32.js delete mode 100644 benchmark/benchmark.length.float64.js delete mode 100644 benchmark/benchmark.length.generic.js delete mode 100644 benchmark/benchmark.length.int16.js delete mode 100644 benchmark/benchmark.length.int32.js delete mode 100644 benchmark/benchmark.length.int8.js delete mode 100644 benchmark/benchmark.length.uint16.js delete mode 100644 benchmark/benchmark.length.uint32.js delete mode 100644 benchmark/benchmark.length.uint8.js delete mode 100644 benchmark/benchmark.length.uint8c.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 7212d81..0000000 --- a/.gitattributes +++ /dev/null @@ -1,33 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 858b015..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-07-01T01:49:05.895Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 8be0b82..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 29bf533..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index a7a7f51..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.9.0 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index df9d9d7..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 39b1613..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 7ca169c..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '0 8 * * 6' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "::set-output name=package_name::$name" - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "::set-output name=data::$data" - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v2 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v2 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 128c22e..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,681 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the repository: - push: - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs rm -rf - - git add -A - git commit -m "Remove files" - - git merge -s recursive -X theirs origin/production --allow-unrelated-histories - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch or create new branch tag: - - name: 'Push changes to `deno` branch or create new branch tag' - run: | - SLUG=${{ github.repository }} - VERSION=$(echo ${{ github.ref }} | sed -E -n 's/refs\/tags\/?(v[0-9]+.[0-9]+.[0-9]+).*/\1/p') - if [ -z "$VERSION" ]; then - echo "Workflow job was not triggered by a new tag...." - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - else - echo "Workflow job was triggered by a new tag: $VERSION" - echo "Creating new bundle branch tag of the form $VERSION-deno" - git tag -a $VERSION-deno -m "$VERSION-deno" - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" $VERSION-deno - fi - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs rm -rf - - git add -A - git commit -m "Remove files" - - git merge -s recursive -X theirs origin/production --allow-unrelated-histories - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "::set-output name=alias::${alias}" - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -273,7 +266,7 @@ for ( i = 0; i < dt.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 421b48e..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,319 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); -var isArray = require( '@stdlib/assert-is-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var pkg = require( './../package.json' ).name; -var filledarrayBy = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 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=float64', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'float64', 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=float32', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'float32', 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; - var i; - - clbk = constantFunction( new Complex128( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'complex128', 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=complex64', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( new Complex64( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'complex64', 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=int32', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int32', 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=uint32', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint32', 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=int16', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int16', 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=uint16', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint16', 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=int8', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int8', 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=uint8', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint8', 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=uint8c', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint8c', 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=generic', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'generic', clbk ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.length.complex128.js b/benchmark/benchmark.length.complex128.js deleted file mode 100644 index 671de86..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var Complex128 = require( '@stdlib/complex-float64' ); -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( new Complex128( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'complex128', 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=complex128,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.complex64.js b/benchmark/benchmark.length.complex64.js deleted file mode 100644 index 52da4e3..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var Complex64 = require( '@stdlib/complex-float32' ); -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( new Complex64( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'complex64', 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=complex64,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.float32.js b/benchmark/benchmark.length.float32.js deleted file mode 100644 index 9b4ef9b..0000000 --- a/benchmark/benchmark.length.float32.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'float32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=float32,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.float64.js b/benchmark/benchmark.length.float64.js deleted file mode 100644 index 66cb6b6..0000000 --- a/benchmark/benchmark.length.float64.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'float64', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=float64,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.generic.js b/benchmark/benchmark.length.generic.js deleted file mode 100644 index 5194c1b..0000000 --- a/benchmark/benchmark.length.generic.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isArray = require( '@stdlib/assert-is-array' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'generic', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isArray( 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=generic,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int16.js b/benchmark/benchmark.length.int16.js deleted file mode 100644 index 6669b28..0000000 --- a/benchmark/benchmark.length.int16.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int16', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=int16,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int32.js b/benchmark/benchmark.length.int32.js deleted file mode 100644 index e9c5c88..0000000 --- a/benchmark/benchmark.length.int32.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=int32,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int8.js b/benchmark/benchmark.length.int8.js deleted file mode 100644 index 14bbadf..0000000 --- a/benchmark/benchmark.length.int8.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int8', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=int8,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint16.js b/benchmark/benchmark.length.uint16.js deleted file mode 100644 index d03b23e..0000000 --- a/benchmark/benchmark.length.uint16.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint16', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint16,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint32.js b/benchmark/benchmark.length.uint32.js deleted file mode 100644 index 1382134..0000000 --- a/benchmark/benchmark.length.uint32.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint32,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint8.js b/benchmark/benchmark.length.uint8.js deleted file mode 100644 index c135d6c..0000000 --- a/benchmark/benchmark.length.uint8.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint8', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint8,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint8c.js b/benchmark/benchmark.length.uint8c.js deleted file mode 100644 index 2f7523a..0000000 --- a/benchmark/benchmark.length.uint8c.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint8c', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint8c,len='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 18101fd..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by" -click B href "https://github.com/stdlib-js/array-filled-by/tree/main" -click C href "https://github.com/stdlib-js/array-filled-by/tree/production" -click D href "https://github.com/stdlib-js/array-filled-by/tree/esm" -click E href "https://github.com/stdlib-js/array-filled-by/tree/deno" -click F href "https://github.com/stdlib-js/array-filled-by/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by -[production-url]: https://github.com/stdlib-js/array-filled-by/tree/production -[deno-url]: https://github.com/stdlib-js/array-filled-by/tree/deno -[umd-url]: https://github.com/stdlib-js/array-filled-by/tree/umd -[esm-url]: https://github.com/stdlib-js/array-filled-by/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 5a68984..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,174 +0,0 @@ - -{{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) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr = {{alias}}() - - > arr = {{alias}}( 'float32' ) - - - -{{alias}}( length[, dtype], clbk[, thisArg] ) - Returns a filled array according to a provided callback function and having - a specified length. - - Parameters - ---------- - length: integer - Array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > function clbk() { return 1.0; }; - > var arr = {{alias}}( 5, clbk ) - [ 1.0, 1.0, 1.0, 1.0, 1.0 ] - > arr = {{alias}}( 5, 'int32', clbk ) - [ 1, 1, 1, 1, 1 ] - - -{{alias}}( array[, dtype], clbk[, thisArg] ) - Creates a filled array from another array (or array-like object) according - to a provided callback function. - - Parameters - ---------- - array: ArrayLikeObject - Array from which to generate another array. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias}}( [ 0.5, 0.5, 0.5 ], {{alias:@stdlib/utils/constant-function}}( 2.0 ) ) - [ 2.0, 2.0, 2.0 ] - > var arr2 = {{alias}}( arr1, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( iterable[, dtype], clbk[, thisArg] ) - Creates a filled array from an iterable according to a provided callback - function. - - Parameters - ---------- - iterable: Iterable - Iterable from which to generate an array. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias:@stdlib/iter/constant}}( 3.0, {'iter': 3} ); - > var arr2 = {{alias}}( arr1, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( buffer[, byteOffset[, length]][, dtype], clbk[, thisArg] ) - Returns a filled typed array view of an ArrayBuffer according to a provided - callback function. - - The 'generic' array data type is *not* supported. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( buf, 0, 4, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0, 1.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 394ac49..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,606 +0,0 @@ -/* -* @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. -*/ - -/// - -import { IterableIterator } from '@stdlib/types/iter'; -import filledarrayBy = require( './index' ); - - -/** -* Returns an iterator protocol-compliant object. -* -* @returns iterator protocol-compliant object -*/ -function iterator(): IterableIterator { - const obj: IterableIterator = { - [Symbol.iterator]: iterator, - 'next': next - }; - return obj; -} - -/** -* Implements the iterator protocol `next` method. -* -* @returns iterator protocol-compliant object -*/ -function next(): any { - return { - 'value': 1.0, - 'done': false - }; -} - -/** -* Callback function. -* -* @param i - current array index -* @returns return value -*/ -function clbk( i: number ): number { - return i; -} - - -// TESTS // - -// The function returns an array or typed array... -{ - filledarrayBy(); // $ExpectType ArrayOrTypedArray - filledarrayBy( 'float32' ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( 10, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( 10, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( 10, 'int32', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( 10, 'int32', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const x = new Float64Array( 10 ); - filledarrayBy( x, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( x, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( x, 'uint8', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( x, 'uint8', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const y = [ 2.0, 2.0, 2.0 ]; - filledarrayBy( y, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( y, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( y, 'float64', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( y, 'float64', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const it = iterator(); - filledarrayBy( it, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( it, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( it, 'uint8c', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( it, 'uint8c', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const buf = new ArrayBuffer( 32 ); - filledarrayBy( buf, clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 'uint32', clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 'uint32', clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 8, clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 8, clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 8, 'uint16', clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 8, 'uint16', clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 8, 2, clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 8, 2, clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 8, 2, 'int16', clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 8, 2, 'int16', clbk, {} ); // $ExpectType RealOrComplexTypedArray -} - -// The compiler throws an error if a callback function argument is not a function... -{ - filledarrayBy( 'float64', '5' ); // $ExpectError - filledarrayBy( 'float64', 1.0 ); // $ExpectError - filledarrayBy( 'float64', false ); // $ExpectError - filledarrayBy( 'float64', true ); // $ExpectError - filledarrayBy( 'float64', null ); // $ExpectError - filledarrayBy( 'float64', undefined ); // $ExpectError - filledarrayBy( 'float64', [] ); // $ExpectError - filledarrayBy( 'float64', {} ); // $ExpectError - - filledarrayBy( 'float64', '5', {} ); // $ExpectError - filledarrayBy( 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( 'float64', false, {} ); // $ExpectError - filledarrayBy( 'float64', true, {} ); // $ExpectError - filledarrayBy( 'float64', null, {} ); // $ExpectError - filledarrayBy( 'float64', undefined, {} ); // $ExpectError - filledarrayBy( 'float64', [], {} ); // $ExpectError - filledarrayBy( 'float64', {}, {} ); // $ExpectError - - filledarrayBy( 10, '5' ); // $ExpectError - filledarrayBy( 10, 1.0 ); // $ExpectError - filledarrayBy( 10, false ); // $ExpectError - filledarrayBy( 10, true ); // $ExpectError - filledarrayBy( 10, null ); // $ExpectError - filledarrayBy( 10, undefined ); // $ExpectError - filledarrayBy( 10, [] ); // $ExpectError - filledarrayBy( 10, {} ); // $ExpectError - - filledarrayBy( 10, '5', {} ); // $ExpectError - filledarrayBy( 10, 1.0, {} ); // $ExpectError - filledarrayBy( 10, false, {} ); // $ExpectError - filledarrayBy( 10, true, {} ); // $ExpectError - filledarrayBy( 10, null, {} ); // $ExpectError - filledarrayBy( 10, undefined, {} ); // $ExpectError - filledarrayBy( 10, [], {} ); // $ExpectError - filledarrayBy( 10, {}, {} ); // $ExpectError - - filledarrayBy( 10, 'float64', '5' ); // $ExpectError - filledarrayBy( 10, 'float64', 1.0 ); // $ExpectError - filledarrayBy( 10, 'float64', false ); // $ExpectError - filledarrayBy( 10, 'float64', true ); // $ExpectError - filledarrayBy( 10, 'float64', null ); // $ExpectError - filledarrayBy( 10, 'float64', undefined ); // $ExpectError - filledarrayBy( 10, 'float64', [] ); // $ExpectError - filledarrayBy( 10, 'float64', {} ); // $ExpectError - - filledarrayBy( 10, 'float64', '5', {} ); // $ExpectError - filledarrayBy( 10, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( 10, 'float64', false, {} ); // $ExpectError - filledarrayBy( 10, 'float64', true, {} ); // $ExpectError - filledarrayBy( 10, 'float64', null, {} ); // $ExpectError - filledarrayBy( 10, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( 10, 'float64', [], {} ); // $ExpectError - filledarrayBy( 10, 'float64', {}, {} ); // $ExpectError - - const x = new Float64Array( 10 ); - filledarrayBy( x, '5' ); // $ExpectError - filledarrayBy( x, 1.0 ); // $ExpectError - filledarrayBy( x, false ); // $ExpectError - filledarrayBy( x, true ); // $ExpectError - filledarrayBy( x, null ); // $ExpectError - filledarrayBy( x, undefined ); // $ExpectError - filledarrayBy( x, [] ); // $ExpectError - filledarrayBy( x, {} ); // $ExpectError - - filledarrayBy( x, '5', {} ); // $ExpectError - filledarrayBy( x, 1.0, {} ); // $ExpectError - filledarrayBy( x, false, {} ); // $ExpectError - filledarrayBy( x, true, {} ); // $ExpectError - filledarrayBy( x, null, {} ); // $ExpectError - filledarrayBy( x, undefined, {} ); // $ExpectError - filledarrayBy( x, [], {} ); // $ExpectError - filledarrayBy( x, {}, {} ); // $ExpectError - - filledarrayBy( x, 'float64', '5' ); // $ExpectError - filledarrayBy( x, 'float64', 1.0 ); // $ExpectError - filledarrayBy( x, 'float64', false ); // $ExpectError - filledarrayBy( x, 'float64', true ); // $ExpectError - filledarrayBy( x, 'float64', null ); // $ExpectError - filledarrayBy( x, 'float64', undefined ); // $ExpectError - filledarrayBy( x, 'float64', [] ); // $ExpectError - filledarrayBy( x, 'float64', {} ); // $ExpectError - - filledarrayBy( x, 'float64', '5', {} ); // $ExpectError - filledarrayBy( x, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( x, 'float64', false, {} ); // $ExpectError - filledarrayBy( x, 'float64', true, {} ); // $ExpectError - filledarrayBy( x, 'float64', null, {} ); // $ExpectError - filledarrayBy( x, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( x, 'float64', [], {} ); // $ExpectError - filledarrayBy( x, 'float64', {}, {} ); // $ExpectError - - const y = [ 2.0, 2.0, 2.0 ]; - filledarrayBy( y, '5' ); // $ExpectError - filledarrayBy( y, 1.0 ); // $ExpectError - filledarrayBy( y, false ); // $ExpectError - filledarrayBy( y, true ); // $ExpectError - filledarrayBy( y, null ); // $ExpectError - filledarrayBy( y, undefined ); // $ExpectError - filledarrayBy( y, [] ); // $ExpectError - filledarrayBy( y, {} ); // $ExpectError - - filledarrayBy( y, '5', {} ); // $ExpectError - filledarrayBy( y, 1.0, {} ); // $ExpectError - filledarrayBy( y, false, {} ); // $ExpectError - filledarrayBy( y, true, {} ); // $ExpectError - filledarrayBy( y, null, {} ); // $ExpectError - filledarrayBy( y, undefined, {} ); // $ExpectError - filledarrayBy( y, [], {} ); // $ExpectError - filledarrayBy( y, {}, {} ); // $ExpectError - - filledarrayBy( y, 'float64', '5' ); // $ExpectError - filledarrayBy( y, 'float64', 1.0 ); // $ExpectError - filledarrayBy( y, 'float64', false ); // $ExpectError - filledarrayBy( y, 'float64', true ); // $ExpectError - filledarrayBy( y, 'float64', null ); // $ExpectError - filledarrayBy( y, 'float64', undefined ); // $ExpectError - filledarrayBy( y, 'float64', [] ); // $ExpectError - filledarrayBy( y, 'float64', {} ); // $ExpectError - - filledarrayBy( y, 'float64', '5', {} ); // $ExpectError - filledarrayBy( y, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( y, 'float64', false, {} ); // $ExpectError - filledarrayBy( y, 'float64', true, {} ); // $ExpectError - filledarrayBy( y, 'float64', null, {} ); // $ExpectError - filledarrayBy( y, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( y, 'float64', [], {} ); // $ExpectError - filledarrayBy( y, 'float64', {}, {} ); // $ExpectError - - const it = iterator(); - filledarrayBy( it, '5' ); // $ExpectError - filledarrayBy( it, 1.0 ); // $ExpectError - filledarrayBy( it, false ); // $ExpectError - filledarrayBy( it, true ); // $ExpectError - filledarrayBy( it, null ); // $ExpectError - filledarrayBy( it, undefined ); // $ExpectError - filledarrayBy( it, [] ); // $ExpectError - filledarrayBy( it, {} ); // $ExpectError - - filledarrayBy( it, '5', {} ); // $ExpectError - filledarrayBy( it, 1.0, {} ); // $ExpectError - filledarrayBy( it, false, {} ); // $ExpectError - filledarrayBy( it, true, {} ); // $ExpectError - filledarrayBy( it, null, {} ); // $ExpectError - filledarrayBy( it, undefined, {} ); // $ExpectError - filledarrayBy( it, [], {} ); // $ExpectError - filledarrayBy( it, {}, {} ); // $ExpectError - - filledarrayBy( it, 'float64', '5' ); // $ExpectError - filledarrayBy( it, 'float64', 1.0 ); // $ExpectError - filledarrayBy( it, 'float64', false ); // $ExpectError - filledarrayBy( it, 'float64', true ); // $ExpectError - filledarrayBy( it, 'float64', null ); // $ExpectError - filledarrayBy( it, 'float64', undefined ); // $ExpectError - filledarrayBy( it, 'float64', [] ); // $ExpectError - filledarrayBy( it, 'float64', {} ); // $ExpectError - - filledarrayBy( it, 'float64', '5', {} ); // $ExpectError - filledarrayBy( it, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( it, 'float64', false, {} ); // $ExpectError - filledarrayBy( it, 'float64', true, {} ); // $ExpectError - filledarrayBy( it, 'float64', null, {} ); // $ExpectError - filledarrayBy( it, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( it, 'float64', [], {} ); // $ExpectError - filledarrayBy( it, 'float64', {}, {} ); // $ExpectError - - const buf = new ArrayBuffer( 32 ); - filledarrayBy( buf, '5' ); // $ExpectError - filledarrayBy( buf, 1.0 ); // $ExpectError - filledarrayBy( buf, false ); // $ExpectError - filledarrayBy( buf, true ); // $ExpectError - filledarrayBy( buf, null ); // $ExpectError - filledarrayBy( buf, undefined ); // $ExpectError - filledarrayBy( buf, [] ); // $ExpectError - filledarrayBy( buf, {} ); // $ExpectError - - filledarrayBy( buf, '5', {} ); // $ExpectError - filledarrayBy( buf, 1.0, {} ); // $ExpectError - filledarrayBy( buf, false, {} ); // $ExpectError - filledarrayBy( buf, true, {} ); // $ExpectError - filledarrayBy( buf, null, {} ); // $ExpectError - filledarrayBy( buf, undefined, {} ); // $ExpectError - filledarrayBy( buf, [], {} ); // $ExpectError - filledarrayBy( buf, {}, {} ); // $ExpectError - - filledarrayBy( buf, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 'float64', false ); // $ExpectError - filledarrayBy( buf, 'float64', true ); // $ExpectError - filledarrayBy( buf, 'float64', null ); // $ExpectError - filledarrayBy( buf, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 'float64', {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5' ); // $ExpectError - filledarrayBy( buf, 8, 1.0 ); // $ExpectError - filledarrayBy( buf, 8, false ); // $ExpectError - filledarrayBy( buf, 8, true ); // $ExpectError - filledarrayBy( buf, 8, null ); // $ExpectError - filledarrayBy( buf, 8, undefined ); // $ExpectError - filledarrayBy( buf, 8, [] ); // $ExpectError - filledarrayBy( buf, 8, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, false, {} ); // $ExpectError - filledarrayBy( buf, 8, true, {} ); // $ExpectError - filledarrayBy( buf, 8, null, {} ); // $ExpectError - filledarrayBy( buf, 8, undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, [], {} ); // $ExpectError - filledarrayBy( buf, 8, {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 8, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 'float64', false ); // $ExpectError - filledarrayBy( buf, 8, 'float64', true ); // $ExpectError - filledarrayBy( buf, 8, 'float64', null ); // $ExpectError - filledarrayBy( buf, 8, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 8, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 8, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 8, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, '5' ); // $ExpectError - filledarrayBy( buf, 8, 2, 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 2, false ); // $ExpectError - filledarrayBy( buf, 8, 2, true ); // $ExpectError - filledarrayBy( buf, 8, 2, null ); // $ExpectError - filledarrayBy( buf, 8, 2, undefined ); // $ExpectError - filledarrayBy( buf, 8, 2, [] ); // $ExpectError - filledarrayBy( buf, 8, 2, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, false, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, true, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, null, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, [], {} ); // $ExpectError - filledarrayBy( buf, 8, 2, {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', false ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', true ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', null ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', {}, {} ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid length, typed array, array-like object, `ArrayBuffer`, or iterable argument... -{ - filledarrayBy( false, clbk ); // $ExpectError - filledarrayBy( true, clbk ); // $ExpectError - filledarrayBy( null, clbk ); // $ExpectError - filledarrayBy( {}, clbk ); // $ExpectError - - filledarrayBy( false, clbk, {} ); // $ExpectError - filledarrayBy( true, clbk, {} ); // $ExpectError - filledarrayBy( null, clbk, {} ); // $ExpectError - filledarrayBy( {}, clbk, {} ); // $ExpectError - - filledarrayBy( false, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 'float64', clbk ); // $ExpectError - - filledarrayBy( false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, clbk ); // $ExpectError - filledarrayBy( 1.0, 8, clbk ); // $ExpectError - filledarrayBy( false, 8, clbk ); // $ExpectError - filledarrayBy( true, 8, clbk ); // $ExpectError - filledarrayBy( null, 8, clbk ); // $ExpectError - filledarrayBy( undefined, 8, clbk ); // $ExpectError - filledarrayBy( [], 8, clbk ); // $ExpectError - filledarrayBy( {}, 8, clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, clbk ); // $ExpectError - - filledarrayBy( '5', 8, clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, clbk, {} ); // $ExpectError - filledarrayBy( false, 8, clbk, {} ); // $ExpectError - filledarrayBy( true, 8, clbk, {} ); // $ExpectError - filledarrayBy( null, 8, clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, clbk, {} ); // $ExpectError - filledarrayBy( [], 8, clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 'float64', clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( false, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( [], 8, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 'float64', clbk ); // $ExpectError - - filledarrayBy( '5', 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 2, clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 2, clbk ); // $ExpectError - filledarrayBy( false, 8, 2, clbk ); // $ExpectError - filledarrayBy( true, 8, 2, clbk ); // $ExpectError - filledarrayBy( null, 8, 2, clbk ); // $ExpectError - filledarrayBy( undefined, 8, 2, clbk ); // $ExpectError - filledarrayBy( [], 8, 2, clbk ); // $ExpectError - filledarrayBy( {}, 8, 2, clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, clbk ); // $ExpectError - - filledarrayBy( '5', 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( false, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( [], 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, 'float64', clbk ); // $ExpectError - - filledarrayBy( '5', 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a byte offset argument which is not a number... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, false, clbk ); // $ExpectError - filledarrayBy( buf, true, clbk ); // $ExpectError - filledarrayBy( buf, null, clbk ); // $ExpectError - filledarrayBy( buf, [], clbk ); // $ExpectError - filledarrayBy( buf, {}, clbk ); // $ExpectError - - filledarrayBy( buf, false, clbk, {} ); // $ExpectError - filledarrayBy( buf, true, clbk, {} ); // $ExpectError - filledarrayBy( buf, null, clbk, {} ); // $ExpectError - filledarrayBy( buf, [], clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, clbk, {} ); // $ExpectError - - filledarrayBy( buf, '5', 'float64', clbk ); // $ExpectError - filledarrayBy( buf, false, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, true, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, null, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, [], 'float64', clbk ); // $ExpectError - filledarrayBy( buf, {}, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, '5', 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( buf, false, 2, clbk ); // $ExpectError - filledarrayBy( buf, true, 2, clbk ); // $ExpectError - filledarrayBy( buf, null, 2, clbk ); // $ExpectError - filledarrayBy( buf, [], 2, clbk ); // $ExpectError - filledarrayBy( buf, {}, 2, clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, clbk ); // $ExpectError - - filledarrayBy( buf, false, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, clbk, {} ); // $ExpectError - - filledarrayBy( buf, '5', 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, false, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, true, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, null, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, undefined, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, [], 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, {}, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, '5', 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, false, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, undefined, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a view length argument which is not a number... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, 8, false, clbk ); // $ExpectError - filledarrayBy( buf, 8, true, clbk ); // $ExpectError - filledarrayBy( buf, 8, null, clbk ); // $ExpectError - filledarrayBy( buf, 8, [], clbk ); // $ExpectError - filledarrayBy( buf, 8, {}, clbk ); // $ExpectError - - filledarrayBy( buf, 8, false, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, true, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, null, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, [], clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, {}, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, clbk, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5', 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, false, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, true, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, null, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, [], 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, {}, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, 8, '5', 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, [], 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, {}, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided too many arguments... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, 8, 2, 'float64', 1, clbk, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 997a381..0000000 --- a/examples/index.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ).factory; -var dtypes = require( '@stdlib/array-typed-real-dtypes' ); -var filledarrayBy = require( './../lib' ); - -// Create a pseudorandom number generator: -var rand = discreteUniform( 0, 100 ); - -// Get a list of array data types: -var dt = dtypes(); - -// Generate filled arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = filledarrayBy( 10, dt[ i ], rand ); - console.log( arr ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 3fc2784..2156674 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { RealOrComplexTypedArray, DataType } from '@stdlib/types/array'; import { Collection } from '@stdlib/types/object'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..ea454f9 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-ctors@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill-by@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled-by@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";var w=d();function j(r,e,t){var s,i;for(s=[],i=-1;!r.next().done;)i+=1,s.push(e.call(t,i));return s}function a(r,e,t){var s;for(s=0;s1)throw new TypeError(p("00L05"));if(null===(b=o(g)))throw new TypeError(p("00L2k",g));return new b(0)}if(c<2)throw new TypeError(p("00L05"));if(n(arguments[c-=1]))if(n(arguments[c-1])){if(d=arguments[c],y=arguments[c-=1],0===c)throw new TypeError(p("00L05"))}else y=arguments[c];else{if(!(c>=2))throw new TypeError(p("00L05"));if(d=arguments[c],!n(y=arguments[c-=1]))throw new TypeError(p("00L2n",y))}if((c-=1)>=0&&r(arguments[c])?(g=arguments[c],c-=1):g="float64",null===(b=o(g)))throw new TypeError(p("00L2k",g));if("generic"===g){if(x=arguments[0],0===c){if(e(x)?u=x:t(x)&&(u=x.length),void 0!==u)return m(u,y,d);if(s(x))throw new Error(p("00L04"));if(i(x)){if(!1===w)throw new TypeError(p("00L2l",x));if(!n(x[f]))throw new TypeError(p("00L2m",x));if(x=x[f](),!n(x.next))throw new TypeError(p("00L2m",x));return j(x,y,d)}throw new TypeError(p("00L2m",x))}if(s(x))throw new Error(p("00L04"));throw new TypeError(p("00L2m",x))}if(0===c)if(t(x=arguments[0]))v=new b(x.length);else if(s(x))v=new b(x);else if(e(x))v=new b(x);else{if(!i(x))throw new TypeError(p("00L2m",x));if(!1===w)throw new TypeError(p("00L2l",x));if(!n(x[f]))throw new TypeError(p("00L2m",x));if(x=x[f](),!n(x.next))throw new TypeError(p("00L2m",x));v=new b(h(x))}else v=1===c?new b(arguments[0],arguments[1]):new b(arguments[0],arguments[1],arguments[2]);return v.length>0&&(/^complex/.test(g)?a(v,y,d):l(v.length,v,1,E)),v;function E(r,e){return y.call(d,e)}}export{c as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..d359dd2 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.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\nimport { isPrimitive as isString } from '@stdlib/assert-is-string' ;\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer' ;\nimport isCollection from '@stdlib/assert-is-collection' ;\nimport isArrayBuffer from '@stdlib/assert-is-arraybuffer' ;\nimport isObject from '@stdlib/assert-is-object' ;\nimport isFunction from '@stdlib/assert-is-function' ;\nimport ctors from '@stdlib/array-ctors' ;\nimport gfillBy from '@stdlib/blas-ext-base-gfill-by' ;\nimport filledArray from '@stdlib/array-base-filled-by' ;\nimport hasIteratorSymbolSupport from '@stdlib/assert-has-iterator-symbol-support' ;\nimport ITERATOR_SYMBOL from '@stdlib/symbol-iterator' ;\nimport iterLength from '@stdlib/iter-length' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\n\n\n// VARIABLES //\n\nvar HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport();\nvar DEFAULT_DTYPE = 'float64';\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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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( format( '00L05' ) );\n\t\t}\n\t\tctor = ctors( dtype );\n\t\tif ( ctor === null ) {\n\t\t\tthrow new TypeError( format( '00L2k', 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( format( '00L05' ) );\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( format( '00L05' ) );\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( '00L2n', 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( format( '00L05' ) );\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( '00L2k', 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( format( '00L04' ) );\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( '00L2l', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00L2m', 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( '00L2m', 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( '00L2m', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format( '00L04' ) );\n\t\t}\n\t\tthrow new TypeError( format( '00L2m', 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( '00L2l', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00L2m', 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( '00L2m', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00L2m', 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\nexport default filledarrayBy;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","filledArrayIterator","it","clbk","thisArg","arr","i","next","done","push","call","filledAccessors","length","set","filledarrayBy","nargs","dtype","ctor","len","arg","arguments","ctors","isString","TypeError","format","isFunction","isNonNegativeInteger","isCollection","filledArray","isArrayBuffer","Error","isObject","ITERATOR_SYMBOL","iterLength","test","gfillBy","callback","value","aidx"],"mappings":";;ipCAuCA,IAAIA,EAAsBC,IAe1B,SAASC,EAAqBC,EAAIC,EAAMC,GACvC,IAAIC,EACAC,EAKJ,IAFAD,EAAM,GACNC,GAAK,GAEAJ,EAAGK,OACAC,MAGPF,GAAK,EACLD,EAAII,KAAMN,EAAKO,KAAMN,EAASE,IAE/B,OAAOD,EAYR,SAASM,EAAiBN,EAAKF,EAAMC,GACpC,IAAIE,EACJ,IAAMA,EAAI,EAAGA,EAAID,EAAIO,OAAQN,IAC5BD,EAAIQ,IAAKV,EAAKO,KAAMN,EAASE,GAAKA,GAEnC,OAAOD,EA6JR,SAASS,IACR,IAAIV,EACAW,EACAC,EACAb,EACAc,EACAZ,EACAa,EACAC,EAKJ,GAAe,KAHfJ,EAAQK,UAAUR,QAKjB,OAAO,IADPK,EAAOI,EAzNW,YA0ND,GAIlB,GAAKC,EADLN,EAAQI,UAAW,IACM,CAExB,GAAKL,EAAQ,EACZ,MAAM,IAAIQ,UAAWC,EAAQ,UAG9B,GAAc,QADdP,EAAOI,EAAOL,IAEb,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAGvC,OAAO,IAAIC,EAAM,GAGlB,GAAKF,EAAQ,EACZ,MAAM,IAAIQ,UAAWC,EAAQ,UAM9B,GAAKC,EAAYL,UAHjBL,GAAS,IAKR,GAAKU,EAAYL,UAAWL,EAAM,KAMjC,GALAX,EAAUgB,UAAWL,GAErBZ,EAAOiB,UADPL,GAAS,GAIM,IAAVA,EACJ,MAAM,IAAIQ,UAAWC,EAAQ,eAI9BrB,EAAOiB,UAAWL,OAIf,MAAKA,GAAS,GAUlB,MAAM,IAAIQ,UAAWC,EAAQ,UAN7B,GAHApB,EAAUgB,UAAWL,IAGfU,EADNtB,EAAOiB,UADPL,GAAS,IAGR,MAAM,IAAIQ,UAAWC,EAAQ,QAASrB,IAgBxC,IARAY,GAAS,IACK,GAAKO,EAAUF,UAAWL,KACvCC,EAAQI,UAAWL,GACnBA,GAAS,GAETC,EArRkB,UAwRL,QADdC,EAAOI,EAAOL,IAEb,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAGvC,GAAe,YAAVA,EAAsB,CAE1B,GADAG,EAAMC,UAAW,GACF,IAAVL,EAAc,CAMlB,GALKW,EAAsBP,GAC1BD,EAAMC,EACKQ,EAAcR,KACzBD,EAAMC,EAAIP,aAEE,IAARM,EACJ,OAAOU,EAAaV,EAAKf,EAAMC,GAEhC,GAAKyB,EAAeV,GACnB,MAAM,IAAIW,MAAON,EAAQ,UAE1B,GAAKO,EAAUZ,GAAQ,CACtB,IAA6B,IAAxBpB,EACJ,MAAM,IAAIwB,UAAWC,EAAQ,QAASL,IAEvC,IAAMM,EAAYN,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASL,IAGvC,GADAA,EAAMA,EAAKa,MACLP,EAAYN,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,QAASL,IAEvC,OAAOlB,EAAqBkB,EAAKhB,EAAMC,GAExC,MAAM,IAAImB,UAAWC,EAAQ,QAASL,IAChC,GAAKU,EAAeV,GAC1B,MAAM,IAAIW,MAAON,EAAQ,UAE1B,MAAM,IAAID,UAAWC,EAAQ,QAASL,IAEvC,GAAe,IAAVJ,EAEJ,GAAKY,EADLR,EAAMC,UAAW,IAEhBf,EAAM,IAAIY,EAAME,EAAIP,aACd,GAAKiB,EAAeV,GAC1Bd,EAAM,IAAIY,EAAME,QACV,GAAKO,EAAsBP,GACjCd,EAAM,IAAIY,EAAME,OACV,KAAKY,EAAUZ,GAarB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAZtC,IAA6B,IAAxBpB,EACJ,MAAM,IAAIwB,UAAWC,EAAQ,QAASL,IAEvC,IAAMM,EAAYN,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASL,IAGvC,GADAA,EAAMA,EAAKa,MACLP,EAAYN,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,QAASL,IAEvCd,EAAM,IAAIY,EAAMgB,EAAYd,SAK7Bd,EADqB,IAAVU,EACL,IAAIE,EAAMG,UAAU,GAAIA,UAAU,IAElC,IAAIH,EAAMG,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKf,EAAIO,OAAS,IACZ,WAAWsB,KAAMlB,GACrBL,EAAiBN,EAAKF,EAAMC,GAE5B+B,EAAS9B,EAAIO,OAAQP,EAAK,EAAG+B,IAGxB/B,EAYP,SAAS+B,EAAUC,EAAOC,GACzB,OAAOnC,EAAKO,KAAMN,EAASkC"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d115cf0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,192 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -/** -* Create a filled array according to a provided callback function. -* -* @module @stdlib/array-filled-by -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* var arr = filledarrayBy(); -* // returns -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'generic', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( [ 0.5, 0.5 ], clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1; -* } -* -* var arr = filledarrayBy( [ 5, -3 ], 'int32', clbk ); -* // returns [ 1, 1 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk1() { -* return 10; -* } -* -* function clbk2() { -* return 1.0; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, clbk2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk1() { -* return 1.0; -* } -* -* function clbk2() { -* return 2; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, 'uint32', clbk2 ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 'float32', clbk ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, clbk ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, 'int32', clbk ); -* // returns [ 1, 1 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index d6fbe5e..0000000 --- a/lib/main.js +++ /dev/null @@ -1,413 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var isCollection = require( '@stdlib/assert-is-collection' ); -var isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isObject = require( '@stdlib/assert-is-object' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var ctors = require( '@stdlib/array-ctors' ); -var gfillBy = require( '@stdlib/blas-ext-base-gfill-by' ); -var filledArray = require( '@stdlib/array-base-filled-by' ); -var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var iterLength = require( '@stdlib/iter-length' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport(); -var DEFAULT_DTYPE = 'float64'; - - -// FUNCTIONS // - -/** -* Creates a filled "generic" array from an iterator. -* -* @private -* @param {Iterable} it - iterator -* @param {Callback} clbk - callback function -* @param {*} thisArg - callback function execution context -* @returns {Array} filled array -*/ -function filledArrayIterator( it, clbk, thisArg ) { - var arr; - var i; - var v; - - arr = []; - i = -1; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - i += 1; - arr.push( clbk.call( thisArg, i ) ); - } - return arr; -} - -/** -* Fills an array exposing accessors for getting and setting array elements. -* -* @private -* @param {Collection} arr - input array -* @param {Callback} clbk - callback function -* @param {*} thisArg - callback function execution context -* @returns {Collection} input array -*/ -function filledAccessors( arr, clbk, thisArg ) { - var i; - for ( i = 0; i < arr.length; i++ ) { - arr.set( clbk.call( thisArg, i ), i ); - } - return arr; -} - - -// MAIN // - -/** -* Creates a filled array according to a provided callback function. -* -* @param {(NonNegativeInteger|TypedArray|ArrayLikeObject|ArrayBuffer|Iterable)} [arg] - a length, typed array, array-like object, buffer, or iterable -* @param {NonNegativeInteger} [byteOffset=0] - byte offset -* @param {NonNegativeInteger} [length] - view length -* @param {string} [dtype="float64"] - data type -* @param {Callback} [clbk] - callback to invoke -* @param {*} [thisArg] - callback execution context -* @throws {TypeError} must provide a recognized data type -* @throws {TypeError} must provide a length, typed array, array-like object, buffer, or iterable -* @throws {TypeError} callback argument must be a function. -* @throws {Error} creating a generic array from an `ArrayBuffer` is not supported -* @returns {(TypedArray|Array)} array or typed array -* -* @example -* var arr = filledarrayBy(); -* // returns -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'generic', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( [ 0.5, 0.5 ], clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1; -* } -* -* var arr = filledarrayBy( [ 5, -3 ], 'int32', clbk ); -* // returns [ 1, 1 ] -* -* @example -* function clbk1() { -* return 10; -* } -* -* function clbk2() { -* return 1.0; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, clbk2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk1() { -* return 1.0; -* } -* -* function clbk2() { -* return 2; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, 'uint32', clbk2 ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 'float32', clbk ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, clbk ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, 'int32', clbk ); -* // returns [ 1, 1 ] -*/ -function filledarrayBy() { - var thisArg; - var nargs; - var dtype; - var clbk; - var ctor; - var arr; - var len; - var arg; - - nargs = arguments.length; - - // If we weren't provided any arguments, return an empty array... - if ( nargs === 0 ) { - ctor = ctors( DEFAULT_DTYPE ); - return new ctor( 0 ); - } - // Check if we were provided a dtype as the first argument... - dtype = arguments[ 0 ]; - if ( isString( dtype ) ) { - // Invoking this function with arguments `f( dtype, clbk[, thisArg] )` is not allowed (otherwise, we'd need to also allow `f( clbk[, thisArg] )`)... - if ( nargs > 1 ) { - throw new TypeError( format( '00L05' ) ); - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '00L2k', dtype ) ); - } - // Return an empty array having the specified dtype: - return new ctor( 0 ); - } - // For all other supported invocations, we need at least two arguments... - if ( nargs < 2 ) { - throw new TypeError( format( '00L05' ) ); - } - // At this point, we need to do some argument juggling... - nargs -= 1; // henceforth, the number of available arguments is `nargs+1` - - // Determine whether the last argument is a callback or "this" context... - if ( isFunction( arguments[ nargs ] ) ) { - // 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... - if ( isFunction( arguments[ nargs-1 ] ) ) { - thisArg = arguments[ nargs ]; - nargs -= 1; - clbk = arguments[ nargs ]; - - // Check if we were provided only a callback and a "this" context.. - if ( nargs === 0 ) { - throw new TypeError( format( '00L05' ) ); - } - } else { - // "this" context is left undefined... - clbk = arguments[ nargs ]; - } - } - // 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... - else if ( nargs >= 2 ) { - thisArg = arguments[ nargs ]; - nargs -= 1; - clbk = arguments[ nargs ]; - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '00L2n', clbk ) ); - } - } - // If were were only provided 2 arguments and the last argument was not a function, we've been provided an insufficient number of arguments... - else { - throw new TypeError( format( '00L05' ) ); - } - // Now that we've processed the callback arguments, let's continue working backward to see if we've been provided a `dtype` argument... - nargs -= 1; - if ( nargs >= 0 && isString( arguments[ nargs ] ) ) { - dtype = arguments[ nargs ]; - nargs -= 1; - } else { - dtype = DEFAULT_DTYPE; - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '00L2k', dtype ) ); - } - // At this point, we've resolved the output array data type, and now we can actually create the output array... - if ( dtype === 'generic' ) { - arg = arguments[ 0 ]; - if ( nargs === 0 ) { - if ( isNonNegativeInteger( arg ) ) { - len = arg; - } else if ( isCollection( arg ) ) { - len = arg.length; - } - if ( len !== void 0 ) { - return filledArray( len, clbk, thisArg ); - } - if ( isArrayBuffer( arg ) ) { - throw new Error( format( '00L04' ) ); - } - if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( '00L2l', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00L2m', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00L2m', arg ) ); - } - return filledArrayIterator( arg, clbk, thisArg ); - } - throw new TypeError( format( '00L2m', arg ) ); - } else if ( isArrayBuffer( arg ) ) { - throw new Error( format( '00L04' ) ); - } - throw new TypeError( format( '00L2m', arg ) ); - } - if ( nargs === 0 ) { // length || array-like || ArrayBuffer || iterable - arg = arguments[ 0 ]; - if ( isCollection( arg ) ) { - arr = new ctor( arg.length ); - } else if ( isArrayBuffer( arg ) ) { - arr = new ctor( arg ); - } else if ( isNonNegativeInteger( arg ) ) { - arr = new ctor( arg ); - } else if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( '00L2l', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00L2m', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00L2m', arg ) ); - } - arr = new ctor( iterLength( arg ) ); - } else { - throw new TypeError( format( '00L2m', arg ) ); - } - } else if ( nargs === 1 ) { - arr = new ctor( arguments[0], arguments[1] ); // (ArrayBuffer, byteOffset) - } else { - arr = new ctor( arguments[0], arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset, length) - } - if ( arr.length > 0 ) { - if ( /^complex/.test( dtype ) ) { - filledAccessors( arr, clbk, thisArg ); - } else { - gfillBy( arr.length, arr, 1, callback ); - } - } - return arr; - - /** - * Callback which wraps a provided callback and is invoked for each array element. - * - * @private - * @param {*} value - element value - * @param {NonNegativeInteger} aidx - array index - * @param {NonNegativeInteger} sidx - strided index - * @param {Collection} array - input array/collection - * @returns {*} callback return value - */ - function callback( value, aidx ) { - return clbk.call( thisArg, aidx ); - } -} - - -// EXPORTS // - -module.exports = filledarrayBy; diff --git a/package.json b/package.json index 6511a88..498622b 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.2", "description": "Create a filled array according to a provided callback function.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,69 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-filled-by": "^0.0.x", - "@stdlib/array-ctors": "^0.0.x", - "@stdlib/assert-has-iterator-symbol-support": "^0.0.x", - "@stdlib/assert-is-arraybuffer": "^0.0.x", - "@stdlib/assert-is-collection": "^0.0.x", - "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/assert-is-nonnegative-integer": "^0.0.x", - "@stdlib/assert-is-object": "^0.0.x", - "@stdlib/assert-is-string": "^0.0.x", - "@stdlib/blas-ext-base-gfill-by": "^0.0.x", - "@stdlib/iter-length": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x", - "@stdlib/symbol-iterator": "^0.0.x", - "@stdlib/types": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-buffer": "^0.0.x", - "@stdlib/array-complex128": "^0.0.x", - "@stdlib/array-complex64": "^0.0.x", - "@stdlib/array-float32": "^0.0.x", - "@stdlib/array-float64": "^0.0.x", - "@stdlib/array-int16": "^0.0.x", - "@stdlib/array-int32": "^0.0.x", - "@stdlib/array-int8": "^0.0.x", - "@stdlib/array-typed-real-dtypes": "^0.0.x", - "@stdlib/array-uint16": "^0.0.x", - "@stdlib/array-uint32": "^0.0.x", - "@stdlib/array-uint8": "^0.0.x", - "@stdlib/array-uint8c": "^0.0.x", - "@stdlib/assert-instance-of": "^0.0.x", - "@stdlib/assert-is-array": "^0.0.x", - "@stdlib/assert-is-typed-array": "^0.0.x", - "@stdlib/assert-is-typed-array-like": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/complex-float32": "^0.0.x", - "@stdlib/complex-float64": "^0.0.x", - "@stdlib/iter-constant": "^0.0.x", - "@stdlib/math-base-special-pow": "^0.0.x", - "@stdlib/random-base-discrete-uniform": "^0.0.x", - "@stdlib/strided-base-reinterpret-complex128": "^0.0.x", - "@stdlib/strided-base-reinterpret-complex64": "^0.0.x", - "@stdlib/utils-constant-function": "^0.0.x", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..86d21cc --- /dev/null +++ b/stats.html @@ -0,0 +1,2689 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index b55aa4a..0000000 --- a/test/test.js +++ /dev/null @@ -1,4248 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 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. -*/ - -/* eslint-disable max-len */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -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 ArrayBuffer = require( '@stdlib/array-buffer' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var iterConstant = require( '@stdlib/iter-constant' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var filledarrayBy = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': !hasIteratorSymbolSupport() -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof filledarrayBy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if only provided callback arguments', function test( t ) { - t.throws( clbk1, TypeError, 'throws an error' ); - t.throws( clbk2, TypeError, 'throws an error' ); - t.throws( clbk3, TypeError, 'throws an error' ); - t.end(); - - function clbk1() { - filledarrayBy( constantFunction( 1.0 ) ); - } - - function clbk2() { - filledarrayBy( constantFunction( 1.0 ), {} ); - } - - function clbk3() { - filledarrayBy( constantFunction( 1.0 ), constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (only argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (typed array; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (array-like object)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (array-like object; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 8 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 8 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, 1, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (iterator)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( iterConstant( 1.0 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (iterator; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( iterConstant( 1.0 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if only provided data type and callback arguments', function test( t ) { - t.throws( clbk1, TypeError, 'throws an error' ); - t.throws( clbk2, TypeError, 'throws an error' ); - t.throws( clbk3, TypeError, 'throws an error' ); - t.end(); - - function clbk1() { - filledarrayBy( 'float64', constantFunction( 1.0 ) ); - } - - function clbk2() { - filledarrayBy( 'float64', constantFunction( 1.0 ), {} ); - } - - function clbk3() { - filledarrayBy( 'float64', constantFunction( 1.0 ), constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (array-like object)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (array-like object; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, 1, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, 1, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (no iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (no iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (non-function iterator symbol property)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (non-function iterator symbol property; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (`next` property is not a function)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ) ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (`next` property is not a function; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ), {} ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (no iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (no iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (non-function iterator symbol property)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (non-function iterator symbol property; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (`next` property is not a function)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ) ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (`next` property is not a function; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ), {} ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 1, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 1, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function returns a filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - arr = filledarrayBy(); - - t.strictEqual( instanceOf( arr, Float64Array ), 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=float64)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - arr = filledarrayBy( 'float64' ); - - t.strictEqual( instanceOf( arr, Float64Array ), 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=float32)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( 0 ); - arr = filledarrayBy( 'float32' ); - - t.strictEqual( instanceOf( arr, Float32Array ), 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; - - expected = new Complex128Array( 0 ); - arr = filledarrayBy( 'complex128' ); - - t.strictEqual( instanceOf( arr, Complex128Array ), 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=complex64)', function test( t ) { - var expected; - var arr; - - expected = new Complex64Array( 0 ); - arr = filledarrayBy( 'complex64' ); - - t.strictEqual( instanceOf( arr, Complex64Array ), 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=int32)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( 0 ); - arr = filledarrayBy( 'int32' ); - - t.strictEqual( instanceOf( arr, Int32Array ), 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=uint32)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( 0 ); - arr = filledarrayBy( 'uint32' ); - - t.strictEqual( instanceOf( arr, Uint32Array ), 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=int16)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( 0 ); - arr = filledarrayBy( 'int16' ); - - t.strictEqual( instanceOf( arr, Int16Array ), 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=uint16)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( 0 ); - arr = filledarrayBy( 'uint16' ); - - t.strictEqual( instanceOf( arr, Uint16Array ), 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=int8)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( 0 ); - arr = filledarrayBy( 'int8' ); - - t.strictEqual( instanceOf( arr, Int8Array ), 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=uint8)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( 0 ); - arr = filledarrayBy( 'uint8' ); - - t.strictEqual( instanceOf( arr, Uint8Array ), 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=uint8c)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( 0 ); - arr = filledarrayBy( 'uint8c' ); - - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), 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=generic)', function test( t ) { - var expected; - var arr; - - expected = []; - arr = filledarrayBy( 'generic' ); - - t.strictEqual( instanceOf( arr, Array ), 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 (default, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, length=0)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array(); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 0, clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, clbk, ctx ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (default, length; thisArg=function)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, clbk, context ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this(); // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } - - function context() { - ctx.count += 1; - } -}); - -tape( 'the function returns a filled array (dtype=float64, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, 'float64', clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, length; thisArg=function)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, 'float64', clbk, context ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this(); // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } - - function context() { - ctx.count += 1; - } -}); - -tape( 'the function returns a filled array (dtype=float32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, 'float32', clbk ); - - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex128, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = filledarrayBy( 5, 'complex128', clbk ); - - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = filledarrayBy( 5, 'complex64', clbk ); - - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int32Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int32', clbk ); - - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint32Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint32', clbk ); - - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int16Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int16', clbk ); - - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint16', clbk ); - - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int8Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int8', clbk ); - - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint8', clbk ); - - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint8c', clbk ); - - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = [ 1, 1, 1, 1, 1 ]; - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'generic', clbk ); - - t.strictEqual( instanceOf( arr, Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex128, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = [ 1.0, 2.0 ]; - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = [ 1.0, 2.0 ]; - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int32', clbk ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, typed array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, typed array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex128, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = new Float64Array( [ 1.0, 2.0 ] ); - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = new Float64Array( [ 1.0, 2.0 ] ); - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (default, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex128, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer, byteoffset; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer, byteoffset; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, 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; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 48 ); - out = filledarrayBy( buf, 16, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 24 ); - out = filledarrayBy( buf, 8, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int32', clbk ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint8c', clbk ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, 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; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 64 ); - out = filledarrayBy( buf, 16, 2, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset, length)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 1, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 1, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled array (default, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, iterator; thisArg)', opts, function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - ctx = { - 'count': 0 - }; - indices = []; - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, iterator; thisArg)', opts, function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - ctx = { - 'count': 0 - }; - indices = []; - out = filledarrayBy( arr, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex128, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = iterConstant( new Complex128( 3.0, 3.0 ), { - 'iter': 2 - }); - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = iterConstant( new Complex64( 3.0, 3.0 ), { - 'iter': 2 - }); - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); From 239d1f758baa91e76716641b3c2455ca0b956c06 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 6 Jul 2022 18:53:05 +0000 Subject: [PATCH 008/117] Transform error messages --- lib/main.js | 38 +++++++++++++++++++------------------- package.json | 2 +- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/lib/main.js b/lib/main.js index d27b055..d6fbe5e 100644 --- a/lib/main.js +++ b/lib/main.js @@ -32,7 +32,7 @@ var filledArray = require( '@stdlib/array-base-filled-by' ); var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); var iterLength = require( '@stdlib/iter-length' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -263,18 +263,18 @@ function filledarrayBy() { if ( isString( dtype ) ) { // Invoking this function with arguments `f( dtype, clbk[, thisArg] )` is not allowed (otherwise, we'd need to also allow `f( clbk[, thisArg] )`)... if ( nargs > 1 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format( '00L05' ) ); } ctor = ctors( dtype ); if ( ctor === null ) { - throw new TypeError( format( 'invalid argument. Must provide a recognized data type. Value: `%s`.', dtype ) ); + throw new TypeError( format( '00L2k', dtype ) ); } // Return an empty array having the specified dtype: return new ctor( 0 ); } // For all other supported invocations, we need at least two arguments... if ( nargs < 2 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format( '00L05' ) ); } // At this point, we need to do some argument juggling... nargs -= 1; // henceforth, the number of available arguments is `nargs+1` @@ -289,7 +289,7 @@ function filledarrayBy() { // Check if we were provided only a callback and a "this" context.. if ( nargs === 0 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format( '00L05' ) ); } } else { // "this" context is left undefined... @@ -302,12 +302,12 @@ function filledarrayBy() { nargs -= 1; clbk = arguments[ nargs ]; if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '00L2n', clbk ) ); } } // If were were only provided 2 arguments and the last argument was not a function, we've been provided an insufficient number of arguments... else { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format( '00L05' ) ); } // Now that we've processed the callback arguments, let's continue working backward to see if we've been provided a `dtype` argument... nargs -= 1; @@ -319,7 +319,7 @@ function filledarrayBy() { } ctor = ctors( dtype ); if ( ctor === null ) { - throw new TypeError( format( 'invalid argument. Must provide a recognized data type. Value: `%s`.', dtype ) ); + throw new TypeError( format( '00L2k', dtype ) ); } // At this point, we've resolved the output array data type, and now we can actually create the output array... if ( dtype === 'generic' ) { @@ -334,26 +334,26 @@ function filledarrayBy() { return filledArray( len, clbk, thisArg ); } if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format( '00L04' ) ); } if ( isObject( arg ) ) { if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.', arg ) ); + throw new TypeError( format( '00L2l', arg ) ); } if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00L2m', arg ) ); } arg = arg[ ITERATOR_SYMBOL ](); if ( !isFunction( arg.next ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00L2m', arg ) ); } return filledArrayIterator( arg, clbk, thisArg ); } - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00L2m', arg ) ); } else if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format( '00L04' ) ); } - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00L2m', arg ) ); } if ( nargs === 0 ) { // length || array-like || ArrayBuffer || iterable arg = arguments[ 0 ]; @@ -365,18 +365,18 @@ function filledarrayBy() { arr = new ctor( arg ); } else if ( isObject( arg ) ) { if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.', arg ) ); + throw new TypeError( format( '00L2l', arg ) ); } if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00L2m', arg ) ); } arg = arg[ ITERATOR_SYMBOL ](); if ( !isFunction( arg.next ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00L2m', arg ) ); } arr = new ctor( iterLength( arg ) ); } else { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00L2m', arg ) ); } } else if ( nargs === 1 ) { arr = new ctor( arguments[0], arguments[1] ); // (ArrayBuffer, byteOffset) diff --git a/package.json b/package.json index b974a7b..6511a88 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "@stdlib/assert-is-string": "^0.0.x", "@stdlib/blas-ext-base-gfill-by": "^0.0.x", "@stdlib/iter-length": "^0.0.x", - "@stdlib/string-format": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x", "@stdlib/symbol-iterator": "^0.0.x", "@stdlib/types": "^0.0.x" }, From 86f4a65baf80af735c3e80ab597a20c51c12b28d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 6 Jul 2022 19:24:35 +0000 Subject: [PATCH 009/117] Remove files --- index.d.ts | 427 -------- index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 3121 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 2156674..0000000 --- a/index.d.ts +++ /dev/null @@ -1,427 +0,0 @@ -/* -* @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. -*/ - -// TypeScript Version: 2.0 - -/// - -import { RealOrComplexTypedArray, DataType } from '@stdlib/types/array'; -import { Collection } from '@stdlib/types/object'; -import { IterableIterator } from '@stdlib/types/iter'; - -/** -* Array or typed array. -*/ -type ArrayOrTypedArray = Array | RealOrComplexTypedArray; - -/** -* Nullary callback function. -* -* @returns fill value -*/ -type Nullary = () => any; - -/** -* Unary callback function. -* -* @param i - current array index -* @returns fill value -*/ -type Unary = ( i: number ) => any; - -/** -* Callback function. -* -* @param i - current array index -* @returns fill value -*/ -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 -* -* @example -* var arr = filledarrayBy(); -* // returns -* -* @example -* var arr = filledarrayBy( 'float32' ); -* // returns -*/ -declare function filledarrayBy( dtype?: DataType ): ArrayOrTypedArray; // tslint:disable-line:unified-signatures - -/** -* Creates a filled array according to a provided callback function and having a specified `length`. -* -* @param length - array length -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* -* var arr = filledarrayBy( 5, constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( length: number, clbk: Callback, thisArg?: any ): ArrayOrTypedArray; // tslint:disable-line:max-line-length unified-signatures - -/** -* 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 -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* -* var arr = filledarrayBy( 5, 'float64', constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( length: number, dtype: DataType, clbk: Callback, thisArg?: any ): ArrayOrTypedArray; // tslint:disable-line:max-line-length unified-signatures - -/** -* Creates a filled array from another `array` according to a provided callback function. -* -* @param array - typed array or array-like object -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* -* 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; // tslint:disable-line:max-line-length 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 -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* -* 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; // tslint:disable-line:max-line-length unified-signatures - -/** -* Creates a filled array from an iterable according to a callback function. -* -* @param iterable - iterable -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* var iterConstant = require( `@stdlib/iter/constant` ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarrayBy( it, constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( iterable: IterableIterator, callback: Callback, thisArg?: any ): ArrayOrTypedArray; // tslint:disable-line:max-line-length 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 -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* var iterConstant = require( `@stdlib/iter/constant` ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* 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; // tslint:disable-line:max-line-length unified-signatures - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; // tslint:disable-line:max-line-length - -/** -* 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. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; // tslint:disable-line:max-line-length unified-signatures - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; // tslint:disable-line:max-line-length - -/** -* 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. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; // tslint:disable-line:max-line-length unified-signatures - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; // tslint:disable-line:max-line-length 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. -* -* @param buffer - `ArrayBuffer` -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; // tslint:disable-line:max-line-length unified-signatures - - -// EXPORTS // - -export = filledarrayBy; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index ea454f9..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-ctors@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill-by@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled-by@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";var w=d();function j(r,e,t){var s,i;for(s=[],i=-1;!r.next().done;)i+=1,s.push(e.call(t,i));return s}function a(r,e,t){var s;for(s=0;s1)throw new TypeError(p("00L05"));if(null===(b=o(g)))throw new TypeError(p("00L2k",g));return new b(0)}if(c<2)throw new TypeError(p("00L05"));if(n(arguments[c-=1]))if(n(arguments[c-1])){if(d=arguments[c],y=arguments[c-=1],0===c)throw new TypeError(p("00L05"))}else y=arguments[c];else{if(!(c>=2))throw new TypeError(p("00L05"));if(d=arguments[c],!n(y=arguments[c-=1]))throw new TypeError(p("00L2n",y))}if((c-=1)>=0&&r(arguments[c])?(g=arguments[c],c-=1):g="float64",null===(b=o(g)))throw new TypeError(p("00L2k",g));if("generic"===g){if(x=arguments[0],0===c){if(e(x)?u=x:t(x)&&(u=x.length),void 0!==u)return m(u,y,d);if(s(x))throw new Error(p("00L04"));if(i(x)){if(!1===w)throw new TypeError(p("00L2l",x));if(!n(x[f]))throw new TypeError(p("00L2m",x));if(x=x[f](),!n(x.next))throw new TypeError(p("00L2m",x));return j(x,y,d)}throw new TypeError(p("00L2m",x))}if(s(x))throw new Error(p("00L04"));throw new TypeError(p("00L2m",x))}if(0===c)if(t(x=arguments[0]))v=new b(x.length);else if(s(x))v=new b(x);else if(e(x))v=new b(x);else{if(!i(x))throw new TypeError(p("00L2m",x));if(!1===w)throw new TypeError(p("00L2l",x));if(!n(x[f]))throw new TypeError(p("00L2m",x));if(x=x[f](),!n(x.next))throw new TypeError(p("00L2m",x));v=new b(h(x))}else v=1===c?new b(arguments[0],arguments[1]):new b(arguments[0],arguments[1],arguments[2]);return v.length>0&&(/^complex/.test(g)?a(v,y,d):l(v.length,v,1,E)),v;function E(r,e){return y.call(d,e)}}export{c as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index d359dd2..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.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\nimport { isPrimitive as isString } from '@stdlib/assert-is-string' ;\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer' ;\nimport isCollection from '@stdlib/assert-is-collection' ;\nimport isArrayBuffer from '@stdlib/assert-is-arraybuffer' ;\nimport isObject from '@stdlib/assert-is-object' ;\nimport isFunction from '@stdlib/assert-is-function' ;\nimport ctors from '@stdlib/array-ctors' ;\nimport gfillBy from '@stdlib/blas-ext-base-gfill-by' ;\nimport filledArray from '@stdlib/array-base-filled-by' ;\nimport hasIteratorSymbolSupport from '@stdlib/assert-has-iterator-symbol-support' ;\nimport ITERATOR_SYMBOL from '@stdlib/symbol-iterator' ;\nimport iterLength from '@stdlib/iter-length' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\n\n\n// VARIABLES //\n\nvar HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport();\nvar DEFAULT_DTYPE = 'float64';\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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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( format( '00L05' ) );\n\t\t}\n\t\tctor = ctors( dtype );\n\t\tif ( ctor === null ) {\n\t\t\tthrow new TypeError( format( '00L2k', 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( format( '00L05' ) );\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( format( '00L05' ) );\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( '00L2n', 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( format( '00L05' ) );\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( '00L2k', 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( format( '00L04' ) );\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( '00L2l', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00L2m', 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( '00L2m', 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( '00L2m', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format( '00L04' ) );\n\t\t}\n\t\tthrow new TypeError( format( '00L2m', 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( '00L2l', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00L2m', 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( '00L2m', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00L2m', 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\nexport default filledarrayBy;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","filledArrayIterator","it","clbk","thisArg","arr","i","next","done","push","call","filledAccessors","length","set","filledarrayBy","nargs","dtype","ctor","len","arg","arguments","ctors","isString","TypeError","format","isFunction","isNonNegativeInteger","isCollection","filledArray","isArrayBuffer","Error","isObject","ITERATOR_SYMBOL","iterLength","test","gfillBy","callback","value","aidx"],"mappings":";;ipCAuCA,IAAIA,EAAsBC,IAe1B,SAASC,EAAqBC,EAAIC,EAAMC,GACvC,IAAIC,EACAC,EAKJ,IAFAD,EAAM,GACNC,GAAK,GAEAJ,EAAGK,OACAC,MAGPF,GAAK,EACLD,EAAII,KAAMN,EAAKO,KAAMN,EAASE,IAE/B,OAAOD,EAYR,SAASM,EAAiBN,EAAKF,EAAMC,GACpC,IAAIE,EACJ,IAAMA,EAAI,EAAGA,EAAID,EAAIO,OAAQN,IAC5BD,EAAIQ,IAAKV,EAAKO,KAAMN,EAASE,GAAKA,GAEnC,OAAOD,EA6JR,SAASS,IACR,IAAIV,EACAW,EACAC,EACAb,EACAc,EACAZ,EACAa,EACAC,EAKJ,GAAe,KAHfJ,EAAQK,UAAUR,QAKjB,OAAO,IADPK,EAAOI,EAzNW,YA0ND,GAIlB,GAAKC,EADLN,EAAQI,UAAW,IACM,CAExB,GAAKL,EAAQ,EACZ,MAAM,IAAIQ,UAAWC,EAAQ,UAG9B,GAAc,QADdP,EAAOI,EAAOL,IAEb,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAGvC,OAAO,IAAIC,EAAM,GAGlB,GAAKF,EAAQ,EACZ,MAAM,IAAIQ,UAAWC,EAAQ,UAM9B,GAAKC,EAAYL,UAHjBL,GAAS,IAKR,GAAKU,EAAYL,UAAWL,EAAM,KAMjC,GALAX,EAAUgB,UAAWL,GAErBZ,EAAOiB,UADPL,GAAS,GAIM,IAAVA,EACJ,MAAM,IAAIQ,UAAWC,EAAQ,eAI9BrB,EAAOiB,UAAWL,OAIf,MAAKA,GAAS,GAUlB,MAAM,IAAIQ,UAAWC,EAAQ,UAN7B,GAHApB,EAAUgB,UAAWL,IAGfU,EADNtB,EAAOiB,UADPL,GAAS,IAGR,MAAM,IAAIQ,UAAWC,EAAQ,QAASrB,IAgBxC,IARAY,GAAS,IACK,GAAKO,EAAUF,UAAWL,KACvCC,EAAQI,UAAWL,GACnBA,GAAS,GAETC,EArRkB,UAwRL,QADdC,EAAOI,EAAOL,IAEb,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAGvC,GAAe,YAAVA,EAAsB,CAE1B,GADAG,EAAMC,UAAW,GACF,IAAVL,EAAc,CAMlB,GALKW,EAAsBP,GAC1BD,EAAMC,EACKQ,EAAcR,KACzBD,EAAMC,EAAIP,aAEE,IAARM,EACJ,OAAOU,EAAaV,EAAKf,EAAMC,GAEhC,GAAKyB,EAAeV,GACnB,MAAM,IAAIW,MAAON,EAAQ,UAE1B,GAAKO,EAAUZ,GAAQ,CACtB,IAA6B,IAAxBpB,EACJ,MAAM,IAAIwB,UAAWC,EAAQ,QAASL,IAEvC,IAAMM,EAAYN,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASL,IAGvC,GADAA,EAAMA,EAAKa,MACLP,EAAYN,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,QAASL,IAEvC,OAAOlB,EAAqBkB,EAAKhB,EAAMC,GAExC,MAAM,IAAImB,UAAWC,EAAQ,QAASL,IAChC,GAAKU,EAAeV,GAC1B,MAAM,IAAIW,MAAON,EAAQ,UAE1B,MAAM,IAAID,UAAWC,EAAQ,QAASL,IAEvC,GAAe,IAAVJ,EAEJ,GAAKY,EADLR,EAAMC,UAAW,IAEhBf,EAAM,IAAIY,EAAME,EAAIP,aACd,GAAKiB,EAAeV,GAC1Bd,EAAM,IAAIY,EAAME,QACV,GAAKO,EAAsBP,GACjCd,EAAM,IAAIY,EAAME,OACV,KAAKY,EAAUZ,GAarB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAZtC,IAA6B,IAAxBpB,EACJ,MAAM,IAAIwB,UAAWC,EAAQ,QAASL,IAEvC,IAAMM,EAAYN,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASL,IAGvC,GADAA,EAAMA,EAAKa,MACLP,EAAYN,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,QAASL,IAEvCd,EAAM,IAAIY,EAAMgB,EAAYd,SAK7Bd,EADqB,IAAVU,EACL,IAAIE,EAAMG,UAAU,GAAIA,UAAU,IAElC,IAAIH,EAAMG,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKf,EAAIO,OAAS,IACZ,WAAWsB,KAAMlB,GACrBL,EAAiBN,EAAKF,EAAMC,GAE5B+B,EAAS9B,EAAIO,OAAQP,EAAK,EAAG+B,IAGxB/B,EAYP,SAAS+B,EAAUC,EAAOC,GACzB,OAAOnC,EAAKO,KAAMN,EAASkC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 86d21cc..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From c0c112e1c115d6517f4616c0f0f9c33637166456 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 6 Jul 2022 19:25:36 +0000 Subject: [PATCH 010/117] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 33 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 687 ---- .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 178 - .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 41 +- benchmark/benchmark.js | 319 -- benchmark/benchmark.length.complex128.js | 98 - benchmark/benchmark.length.complex64.js | 98 - benchmark/benchmark.length.float32.js | 97 - benchmark/benchmark.length.float64.js | 97 - benchmark/benchmark.length.generic.js | 97 - benchmark/benchmark.length.int16.js | 97 - benchmark/benchmark.length.int32.js | 97 - benchmark/benchmark.length.int8.js | 97 - benchmark/benchmark.length.uint16.js | 97 - benchmark/benchmark.length.uint32.js | 97 - benchmark/benchmark.length.uint8.js | 97 - benchmark/benchmark.length.uint8c.js | 97 - branches.md | 53 - docs/repl.txt | 174 - docs/types/test.ts | 606 --- examples/index.js | 37 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 192 - lib/main.js | 413 -- package.json | 90 +- stats.html | 2689 +++++++++++++ test/test.js | 4248 --------------------- 48 files changed, 2714 insertions(+), 10135 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.length.complex128.js delete mode 100644 benchmark/benchmark.length.complex64.js delete mode 100644 benchmark/benchmark.length.float32.js delete mode 100644 benchmark/benchmark.length.float64.js delete mode 100644 benchmark/benchmark.length.generic.js delete mode 100644 benchmark/benchmark.length.int16.js delete mode 100644 benchmark/benchmark.length.int32.js delete mode 100644 benchmark/benchmark.length.int8.js delete mode 100644 benchmark/benchmark.length.uint16.js delete mode 100644 benchmark/benchmark.length.uint32.js delete mode 100644 benchmark/benchmark.length.uint8.js delete mode 100644 benchmark/benchmark.length.uint8c.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 7212d81..0000000 --- a/.gitattributes +++ /dev/null @@ -1,33 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 8be0b82..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 29bf533..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index a7a7f51..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.9.0 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index df9d9d7..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 39b1613..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 7ca169c..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '0 8 * * 6' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "::set-output name=package_name::$name" - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "::set-output name=data::$data" - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v2 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v2 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 6726965..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,687 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the repository: - push: - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch or create new branch tag: - - name: 'Push changes to `deno` branch or create new branch tag' - run: | - SLUG=${{ github.repository }} - VERSION=$(echo ${{ github.ref }} | sed -E -n 's/refs\/tags\/?(v[0-9]+.[0-9]+.[0-9]+).*/\1/p') - if [ -z "$VERSION" ]; then - echo "Workflow job was not triggered by a new tag...." - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - else - echo "Workflow job was triggered by a new tag: $VERSION" - echo "Creating new bundle branch tag of the form $VERSION-deno" - git tag -a $VERSION-deno -m "$VERSION-deno" - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" $VERSION-deno - fi - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "::set-output name=alias::${alias}" - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -273,7 +266,7 @@ for ( i = 0; i < dt.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 421b48e..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,319 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); -var isArray = require( '@stdlib/assert-is-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var pkg = require( './../package.json' ).name; -var filledarrayBy = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 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=float64', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'float64', 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=float32', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'float32', 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; - var i; - - clbk = constantFunction( new Complex128( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'complex128', 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=complex64', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( new Complex64( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'complex64', 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=int32', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int32', 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=uint32', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint32', 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=int16', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int16', 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=uint16', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint16', 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=int8', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int8', 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=uint8', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint8', 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=uint8c', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint8c', 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=generic', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'generic', clbk ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.length.complex128.js b/benchmark/benchmark.length.complex128.js deleted file mode 100644 index 671de86..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var Complex128 = require( '@stdlib/complex-float64' ); -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( new Complex128( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'complex128', 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=complex128,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.complex64.js b/benchmark/benchmark.length.complex64.js deleted file mode 100644 index 52da4e3..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var Complex64 = require( '@stdlib/complex-float32' ); -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( new Complex64( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'complex64', 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=complex64,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.float32.js b/benchmark/benchmark.length.float32.js deleted file mode 100644 index 9b4ef9b..0000000 --- a/benchmark/benchmark.length.float32.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'float32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=float32,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.float64.js b/benchmark/benchmark.length.float64.js deleted file mode 100644 index 66cb6b6..0000000 --- a/benchmark/benchmark.length.float64.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'float64', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=float64,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.generic.js b/benchmark/benchmark.length.generic.js deleted file mode 100644 index 5194c1b..0000000 --- a/benchmark/benchmark.length.generic.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isArray = require( '@stdlib/assert-is-array' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'generic', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isArray( 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=generic,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int16.js b/benchmark/benchmark.length.int16.js deleted file mode 100644 index 6669b28..0000000 --- a/benchmark/benchmark.length.int16.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int16', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=int16,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int32.js b/benchmark/benchmark.length.int32.js deleted file mode 100644 index e9c5c88..0000000 --- a/benchmark/benchmark.length.int32.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=int32,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int8.js b/benchmark/benchmark.length.int8.js deleted file mode 100644 index 14bbadf..0000000 --- a/benchmark/benchmark.length.int8.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int8', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=int8,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint16.js b/benchmark/benchmark.length.uint16.js deleted file mode 100644 index d03b23e..0000000 --- a/benchmark/benchmark.length.uint16.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint16', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint16,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint32.js b/benchmark/benchmark.length.uint32.js deleted file mode 100644 index 1382134..0000000 --- a/benchmark/benchmark.length.uint32.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint32,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint8.js b/benchmark/benchmark.length.uint8.js deleted file mode 100644 index c135d6c..0000000 --- a/benchmark/benchmark.length.uint8.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint8', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint8,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint8c.js b/benchmark/benchmark.length.uint8c.js deleted file mode 100644 index 2f7523a..0000000 --- a/benchmark/benchmark.length.uint8c.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint8c', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint8c,len='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 18101fd..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by" -click B href "https://github.com/stdlib-js/array-filled-by/tree/main" -click C href "https://github.com/stdlib-js/array-filled-by/tree/production" -click D href "https://github.com/stdlib-js/array-filled-by/tree/esm" -click E href "https://github.com/stdlib-js/array-filled-by/tree/deno" -click F href "https://github.com/stdlib-js/array-filled-by/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by -[production-url]: https://github.com/stdlib-js/array-filled-by/tree/production -[deno-url]: https://github.com/stdlib-js/array-filled-by/tree/deno -[umd-url]: https://github.com/stdlib-js/array-filled-by/tree/umd -[esm-url]: https://github.com/stdlib-js/array-filled-by/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 5a68984..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,174 +0,0 @@ - -{{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) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr = {{alias}}() - - > arr = {{alias}}( 'float32' ) - - - -{{alias}}( length[, dtype], clbk[, thisArg] ) - Returns a filled array according to a provided callback function and having - a specified length. - - Parameters - ---------- - length: integer - Array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > function clbk() { return 1.0; }; - > var arr = {{alias}}( 5, clbk ) - [ 1.0, 1.0, 1.0, 1.0, 1.0 ] - > arr = {{alias}}( 5, 'int32', clbk ) - [ 1, 1, 1, 1, 1 ] - - -{{alias}}( array[, dtype], clbk[, thisArg] ) - Creates a filled array from another array (or array-like object) according - to a provided callback function. - - Parameters - ---------- - array: ArrayLikeObject - Array from which to generate another array. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias}}( [ 0.5, 0.5, 0.5 ], {{alias:@stdlib/utils/constant-function}}( 2.0 ) ) - [ 2.0, 2.0, 2.0 ] - > var arr2 = {{alias}}( arr1, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( iterable[, dtype], clbk[, thisArg] ) - Creates a filled array from an iterable according to a provided callback - function. - - Parameters - ---------- - iterable: Iterable - Iterable from which to generate an array. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias:@stdlib/iter/constant}}( 3.0, {'iter': 3} ); - > var arr2 = {{alias}}( arr1, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( buffer[, byteOffset[, length]][, dtype], clbk[, thisArg] ) - Returns a filled typed array view of an ArrayBuffer according to a provided - callback function. - - The 'generic' array data type is *not* supported. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( buf, 0, 4, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0, 1.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 394ac49..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,606 +0,0 @@ -/* -* @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. -*/ - -/// - -import { IterableIterator } from '@stdlib/types/iter'; -import filledarrayBy = require( './index' ); - - -/** -* Returns an iterator protocol-compliant object. -* -* @returns iterator protocol-compliant object -*/ -function iterator(): IterableIterator { - const obj: IterableIterator = { - [Symbol.iterator]: iterator, - 'next': next - }; - return obj; -} - -/** -* Implements the iterator protocol `next` method. -* -* @returns iterator protocol-compliant object -*/ -function next(): any { - return { - 'value': 1.0, - 'done': false - }; -} - -/** -* Callback function. -* -* @param i - current array index -* @returns return value -*/ -function clbk( i: number ): number { - return i; -} - - -// TESTS // - -// The function returns an array or typed array... -{ - filledarrayBy(); // $ExpectType ArrayOrTypedArray - filledarrayBy( 'float32' ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( 10, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( 10, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( 10, 'int32', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( 10, 'int32', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const x = new Float64Array( 10 ); - filledarrayBy( x, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( x, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( x, 'uint8', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( x, 'uint8', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const y = [ 2.0, 2.0, 2.0 ]; - filledarrayBy( y, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( y, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( y, 'float64', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( y, 'float64', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const it = iterator(); - filledarrayBy( it, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( it, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( it, 'uint8c', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( it, 'uint8c', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const buf = new ArrayBuffer( 32 ); - filledarrayBy( buf, clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 'uint32', clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 'uint32', clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 8, clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 8, clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 8, 'uint16', clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 8, 'uint16', clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 8, 2, clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 8, 2, clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 8, 2, 'int16', clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 8, 2, 'int16', clbk, {} ); // $ExpectType RealOrComplexTypedArray -} - -// The compiler throws an error if a callback function argument is not a function... -{ - filledarrayBy( 'float64', '5' ); // $ExpectError - filledarrayBy( 'float64', 1.0 ); // $ExpectError - filledarrayBy( 'float64', false ); // $ExpectError - filledarrayBy( 'float64', true ); // $ExpectError - filledarrayBy( 'float64', null ); // $ExpectError - filledarrayBy( 'float64', undefined ); // $ExpectError - filledarrayBy( 'float64', [] ); // $ExpectError - filledarrayBy( 'float64', {} ); // $ExpectError - - filledarrayBy( 'float64', '5', {} ); // $ExpectError - filledarrayBy( 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( 'float64', false, {} ); // $ExpectError - filledarrayBy( 'float64', true, {} ); // $ExpectError - filledarrayBy( 'float64', null, {} ); // $ExpectError - filledarrayBy( 'float64', undefined, {} ); // $ExpectError - filledarrayBy( 'float64', [], {} ); // $ExpectError - filledarrayBy( 'float64', {}, {} ); // $ExpectError - - filledarrayBy( 10, '5' ); // $ExpectError - filledarrayBy( 10, 1.0 ); // $ExpectError - filledarrayBy( 10, false ); // $ExpectError - filledarrayBy( 10, true ); // $ExpectError - filledarrayBy( 10, null ); // $ExpectError - filledarrayBy( 10, undefined ); // $ExpectError - filledarrayBy( 10, [] ); // $ExpectError - filledarrayBy( 10, {} ); // $ExpectError - - filledarrayBy( 10, '5', {} ); // $ExpectError - filledarrayBy( 10, 1.0, {} ); // $ExpectError - filledarrayBy( 10, false, {} ); // $ExpectError - filledarrayBy( 10, true, {} ); // $ExpectError - filledarrayBy( 10, null, {} ); // $ExpectError - filledarrayBy( 10, undefined, {} ); // $ExpectError - filledarrayBy( 10, [], {} ); // $ExpectError - filledarrayBy( 10, {}, {} ); // $ExpectError - - filledarrayBy( 10, 'float64', '5' ); // $ExpectError - filledarrayBy( 10, 'float64', 1.0 ); // $ExpectError - filledarrayBy( 10, 'float64', false ); // $ExpectError - filledarrayBy( 10, 'float64', true ); // $ExpectError - filledarrayBy( 10, 'float64', null ); // $ExpectError - filledarrayBy( 10, 'float64', undefined ); // $ExpectError - filledarrayBy( 10, 'float64', [] ); // $ExpectError - filledarrayBy( 10, 'float64', {} ); // $ExpectError - - filledarrayBy( 10, 'float64', '5', {} ); // $ExpectError - filledarrayBy( 10, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( 10, 'float64', false, {} ); // $ExpectError - filledarrayBy( 10, 'float64', true, {} ); // $ExpectError - filledarrayBy( 10, 'float64', null, {} ); // $ExpectError - filledarrayBy( 10, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( 10, 'float64', [], {} ); // $ExpectError - filledarrayBy( 10, 'float64', {}, {} ); // $ExpectError - - const x = new Float64Array( 10 ); - filledarrayBy( x, '5' ); // $ExpectError - filledarrayBy( x, 1.0 ); // $ExpectError - filledarrayBy( x, false ); // $ExpectError - filledarrayBy( x, true ); // $ExpectError - filledarrayBy( x, null ); // $ExpectError - filledarrayBy( x, undefined ); // $ExpectError - filledarrayBy( x, [] ); // $ExpectError - filledarrayBy( x, {} ); // $ExpectError - - filledarrayBy( x, '5', {} ); // $ExpectError - filledarrayBy( x, 1.0, {} ); // $ExpectError - filledarrayBy( x, false, {} ); // $ExpectError - filledarrayBy( x, true, {} ); // $ExpectError - filledarrayBy( x, null, {} ); // $ExpectError - filledarrayBy( x, undefined, {} ); // $ExpectError - filledarrayBy( x, [], {} ); // $ExpectError - filledarrayBy( x, {}, {} ); // $ExpectError - - filledarrayBy( x, 'float64', '5' ); // $ExpectError - filledarrayBy( x, 'float64', 1.0 ); // $ExpectError - filledarrayBy( x, 'float64', false ); // $ExpectError - filledarrayBy( x, 'float64', true ); // $ExpectError - filledarrayBy( x, 'float64', null ); // $ExpectError - filledarrayBy( x, 'float64', undefined ); // $ExpectError - filledarrayBy( x, 'float64', [] ); // $ExpectError - filledarrayBy( x, 'float64', {} ); // $ExpectError - - filledarrayBy( x, 'float64', '5', {} ); // $ExpectError - filledarrayBy( x, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( x, 'float64', false, {} ); // $ExpectError - filledarrayBy( x, 'float64', true, {} ); // $ExpectError - filledarrayBy( x, 'float64', null, {} ); // $ExpectError - filledarrayBy( x, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( x, 'float64', [], {} ); // $ExpectError - filledarrayBy( x, 'float64', {}, {} ); // $ExpectError - - const y = [ 2.0, 2.0, 2.0 ]; - filledarrayBy( y, '5' ); // $ExpectError - filledarrayBy( y, 1.0 ); // $ExpectError - filledarrayBy( y, false ); // $ExpectError - filledarrayBy( y, true ); // $ExpectError - filledarrayBy( y, null ); // $ExpectError - filledarrayBy( y, undefined ); // $ExpectError - filledarrayBy( y, [] ); // $ExpectError - filledarrayBy( y, {} ); // $ExpectError - - filledarrayBy( y, '5', {} ); // $ExpectError - filledarrayBy( y, 1.0, {} ); // $ExpectError - filledarrayBy( y, false, {} ); // $ExpectError - filledarrayBy( y, true, {} ); // $ExpectError - filledarrayBy( y, null, {} ); // $ExpectError - filledarrayBy( y, undefined, {} ); // $ExpectError - filledarrayBy( y, [], {} ); // $ExpectError - filledarrayBy( y, {}, {} ); // $ExpectError - - filledarrayBy( y, 'float64', '5' ); // $ExpectError - filledarrayBy( y, 'float64', 1.0 ); // $ExpectError - filledarrayBy( y, 'float64', false ); // $ExpectError - filledarrayBy( y, 'float64', true ); // $ExpectError - filledarrayBy( y, 'float64', null ); // $ExpectError - filledarrayBy( y, 'float64', undefined ); // $ExpectError - filledarrayBy( y, 'float64', [] ); // $ExpectError - filledarrayBy( y, 'float64', {} ); // $ExpectError - - filledarrayBy( y, 'float64', '5', {} ); // $ExpectError - filledarrayBy( y, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( y, 'float64', false, {} ); // $ExpectError - filledarrayBy( y, 'float64', true, {} ); // $ExpectError - filledarrayBy( y, 'float64', null, {} ); // $ExpectError - filledarrayBy( y, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( y, 'float64', [], {} ); // $ExpectError - filledarrayBy( y, 'float64', {}, {} ); // $ExpectError - - const it = iterator(); - filledarrayBy( it, '5' ); // $ExpectError - filledarrayBy( it, 1.0 ); // $ExpectError - filledarrayBy( it, false ); // $ExpectError - filledarrayBy( it, true ); // $ExpectError - filledarrayBy( it, null ); // $ExpectError - filledarrayBy( it, undefined ); // $ExpectError - filledarrayBy( it, [] ); // $ExpectError - filledarrayBy( it, {} ); // $ExpectError - - filledarrayBy( it, '5', {} ); // $ExpectError - filledarrayBy( it, 1.0, {} ); // $ExpectError - filledarrayBy( it, false, {} ); // $ExpectError - filledarrayBy( it, true, {} ); // $ExpectError - filledarrayBy( it, null, {} ); // $ExpectError - filledarrayBy( it, undefined, {} ); // $ExpectError - filledarrayBy( it, [], {} ); // $ExpectError - filledarrayBy( it, {}, {} ); // $ExpectError - - filledarrayBy( it, 'float64', '5' ); // $ExpectError - filledarrayBy( it, 'float64', 1.0 ); // $ExpectError - filledarrayBy( it, 'float64', false ); // $ExpectError - filledarrayBy( it, 'float64', true ); // $ExpectError - filledarrayBy( it, 'float64', null ); // $ExpectError - filledarrayBy( it, 'float64', undefined ); // $ExpectError - filledarrayBy( it, 'float64', [] ); // $ExpectError - filledarrayBy( it, 'float64', {} ); // $ExpectError - - filledarrayBy( it, 'float64', '5', {} ); // $ExpectError - filledarrayBy( it, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( it, 'float64', false, {} ); // $ExpectError - filledarrayBy( it, 'float64', true, {} ); // $ExpectError - filledarrayBy( it, 'float64', null, {} ); // $ExpectError - filledarrayBy( it, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( it, 'float64', [], {} ); // $ExpectError - filledarrayBy( it, 'float64', {}, {} ); // $ExpectError - - const buf = new ArrayBuffer( 32 ); - filledarrayBy( buf, '5' ); // $ExpectError - filledarrayBy( buf, 1.0 ); // $ExpectError - filledarrayBy( buf, false ); // $ExpectError - filledarrayBy( buf, true ); // $ExpectError - filledarrayBy( buf, null ); // $ExpectError - filledarrayBy( buf, undefined ); // $ExpectError - filledarrayBy( buf, [] ); // $ExpectError - filledarrayBy( buf, {} ); // $ExpectError - - filledarrayBy( buf, '5', {} ); // $ExpectError - filledarrayBy( buf, 1.0, {} ); // $ExpectError - filledarrayBy( buf, false, {} ); // $ExpectError - filledarrayBy( buf, true, {} ); // $ExpectError - filledarrayBy( buf, null, {} ); // $ExpectError - filledarrayBy( buf, undefined, {} ); // $ExpectError - filledarrayBy( buf, [], {} ); // $ExpectError - filledarrayBy( buf, {}, {} ); // $ExpectError - - filledarrayBy( buf, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 'float64', false ); // $ExpectError - filledarrayBy( buf, 'float64', true ); // $ExpectError - filledarrayBy( buf, 'float64', null ); // $ExpectError - filledarrayBy( buf, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 'float64', {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5' ); // $ExpectError - filledarrayBy( buf, 8, 1.0 ); // $ExpectError - filledarrayBy( buf, 8, false ); // $ExpectError - filledarrayBy( buf, 8, true ); // $ExpectError - filledarrayBy( buf, 8, null ); // $ExpectError - filledarrayBy( buf, 8, undefined ); // $ExpectError - filledarrayBy( buf, 8, [] ); // $ExpectError - filledarrayBy( buf, 8, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, false, {} ); // $ExpectError - filledarrayBy( buf, 8, true, {} ); // $ExpectError - filledarrayBy( buf, 8, null, {} ); // $ExpectError - filledarrayBy( buf, 8, undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, [], {} ); // $ExpectError - filledarrayBy( buf, 8, {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 8, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 'float64', false ); // $ExpectError - filledarrayBy( buf, 8, 'float64', true ); // $ExpectError - filledarrayBy( buf, 8, 'float64', null ); // $ExpectError - filledarrayBy( buf, 8, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 8, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 8, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 8, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, '5' ); // $ExpectError - filledarrayBy( buf, 8, 2, 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 2, false ); // $ExpectError - filledarrayBy( buf, 8, 2, true ); // $ExpectError - filledarrayBy( buf, 8, 2, null ); // $ExpectError - filledarrayBy( buf, 8, 2, undefined ); // $ExpectError - filledarrayBy( buf, 8, 2, [] ); // $ExpectError - filledarrayBy( buf, 8, 2, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, false, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, true, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, null, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, [], {} ); // $ExpectError - filledarrayBy( buf, 8, 2, {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', false ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', true ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', null ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', {}, {} ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid length, typed array, array-like object, `ArrayBuffer`, or iterable argument... -{ - filledarrayBy( false, clbk ); // $ExpectError - filledarrayBy( true, clbk ); // $ExpectError - filledarrayBy( null, clbk ); // $ExpectError - filledarrayBy( {}, clbk ); // $ExpectError - - filledarrayBy( false, clbk, {} ); // $ExpectError - filledarrayBy( true, clbk, {} ); // $ExpectError - filledarrayBy( null, clbk, {} ); // $ExpectError - filledarrayBy( {}, clbk, {} ); // $ExpectError - - filledarrayBy( false, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 'float64', clbk ); // $ExpectError - - filledarrayBy( false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, clbk ); // $ExpectError - filledarrayBy( 1.0, 8, clbk ); // $ExpectError - filledarrayBy( false, 8, clbk ); // $ExpectError - filledarrayBy( true, 8, clbk ); // $ExpectError - filledarrayBy( null, 8, clbk ); // $ExpectError - filledarrayBy( undefined, 8, clbk ); // $ExpectError - filledarrayBy( [], 8, clbk ); // $ExpectError - filledarrayBy( {}, 8, clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, clbk ); // $ExpectError - - filledarrayBy( '5', 8, clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, clbk, {} ); // $ExpectError - filledarrayBy( false, 8, clbk, {} ); // $ExpectError - filledarrayBy( true, 8, clbk, {} ); // $ExpectError - filledarrayBy( null, 8, clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, clbk, {} ); // $ExpectError - filledarrayBy( [], 8, clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 'float64', clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( false, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( [], 8, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 'float64', clbk ); // $ExpectError - - filledarrayBy( '5', 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 2, clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 2, clbk ); // $ExpectError - filledarrayBy( false, 8, 2, clbk ); // $ExpectError - filledarrayBy( true, 8, 2, clbk ); // $ExpectError - filledarrayBy( null, 8, 2, clbk ); // $ExpectError - filledarrayBy( undefined, 8, 2, clbk ); // $ExpectError - filledarrayBy( [], 8, 2, clbk ); // $ExpectError - filledarrayBy( {}, 8, 2, clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, clbk ); // $ExpectError - - filledarrayBy( '5', 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( false, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( [], 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, 'float64', clbk ); // $ExpectError - - filledarrayBy( '5', 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a byte offset argument which is not a number... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, false, clbk ); // $ExpectError - filledarrayBy( buf, true, clbk ); // $ExpectError - filledarrayBy( buf, null, clbk ); // $ExpectError - filledarrayBy( buf, [], clbk ); // $ExpectError - filledarrayBy( buf, {}, clbk ); // $ExpectError - - filledarrayBy( buf, false, clbk, {} ); // $ExpectError - filledarrayBy( buf, true, clbk, {} ); // $ExpectError - filledarrayBy( buf, null, clbk, {} ); // $ExpectError - filledarrayBy( buf, [], clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, clbk, {} ); // $ExpectError - - filledarrayBy( buf, '5', 'float64', clbk ); // $ExpectError - filledarrayBy( buf, false, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, true, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, null, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, [], 'float64', clbk ); // $ExpectError - filledarrayBy( buf, {}, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, '5', 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( buf, false, 2, clbk ); // $ExpectError - filledarrayBy( buf, true, 2, clbk ); // $ExpectError - filledarrayBy( buf, null, 2, clbk ); // $ExpectError - filledarrayBy( buf, [], 2, clbk ); // $ExpectError - filledarrayBy( buf, {}, 2, clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, clbk ); // $ExpectError - - filledarrayBy( buf, false, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, clbk, {} ); // $ExpectError - - filledarrayBy( buf, '5', 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, false, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, true, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, null, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, undefined, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, [], 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, {}, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, '5', 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, false, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, undefined, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a view length argument which is not a number... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, 8, false, clbk ); // $ExpectError - filledarrayBy( buf, 8, true, clbk ); // $ExpectError - filledarrayBy( buf, 8, null, clbk ); // $ExpectError - filledarrayBy( buf, 8, [], clbk ); // $ExpectError - filledarrayBy( buf, 8, {}, clbk ); // $ExpectError - - filledarrayBy( buf, 8, false, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, true, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, null, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, [], clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, {}, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, clbk, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5', 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, false, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, true, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, null, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, [], 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, {}, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, 8, '5', 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, [], 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, {}, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided too many arguments... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, 8, 2, 'float64', 1, clbk, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 997a381..0000000 --- a/examples/index.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ).factory; -var dtypes = require( '@stdlib/array-typed-real-dtypes' ); -var filledarrayBy = require( './../lib' ); - -// Create a pseudorandom number generator: -var rand = discreteUniform( 0, 100 ); - -// Get a list of array data types: -var dt = dtypes(); - -// Generate filled arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = filledarrayBy( 10, dt[ i ], rand ); - console.log( arr ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 3fc2784..2156674 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { RealOrComplexTypedArray, DataType } from '@stdlib/types/array'; import { Collection } from '@stdlib/types/object'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..ea454f9 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-ctors@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill-by@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled-by@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";var w=d();function j(r,e,t){var s,i;for(s=[],i=-1;!r.next().done;)i+=1,s.push(e.call(t,i));return s}function a(r,e,t){var s;for(s=0;s1)throw new TypeError(p("00L05"));if(null===(b=o(g)))throw new TypeError(p("00L2k",g));return new b(0)}if(c<2)throw new TypeError(p("00L05"));if(n(arguments[c-=1]))if(n(arguments[c-1])){if(d=arguments[c],y=arguments[c-=1],0===c)throw new TypeError(p("00L05"))}else y=arguments[c];else{if(!(c>=2))throw new TypeError(p("00L05"));if(d=arguments[c],!n(y=arguments[c-=1]))throw new TypeError(p("00L2n",y))}if((c-=1)>=0&&r(arguments[c])?(g=arguments[c],c-=1):g="float64",null===(b=o(g)))throw new TypeError(p("00L2k",g));if("generic"===g){if(x=arguments[0],0===c){if(e(x)?u=x:t(x)&&(u=x.length),void 0!==u)return m(u,y,d);if(s(x))throw new Error(p("00L04"));if(i(x)){if(!1===w)throw new TypeError(p("00L2l",x));if(!n(x[f]))throw new TypeError(p("00L2m",x));if(x=x[f](),!n(x.next))throw new TypeError(p("00L2m",x));return j(x,y,d)}throw new TypeError(p("00L2m",x))}if(s(x))throw new Error(p("00L04"));throw new TypeError(p("00L2m",x))}if(0===c)if(t(x=arguments[0]))v=new b(x.length);else if(s(x))v=new b(x);else if(e(x))v=new b(x);else{if(!i(x))throw new TypeError(p("00L2m",x));if(!1===w)throw new TypeError(p("00L2l",x));if(!n(x[f]))throw new TypeError(p("00L2m",x));if(x=x[f](),!n(x.next))throw new TypeError(p("00L2m",x));v=new b(h(x))}else v=1===c?new b(arguments[0],arguments[1]):new b(arguments[0],arguments[1],arguments[2]);return v.length>0&&(/^complex/.test(g)?a(v,y,d):l(v.length,v,1,E)),v;function E(r,e){return y.call(d,e)}}export{c as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..d359dd2 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.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\nimport { isPrimitive as isString } from '@stdlib/assert-is-string' ;\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer' ;\nimport isCollection from '@stdlib/assert-is-collection' ;\nimport isArrayBuffer from '@stdlib/assert-is-arraybuffer' ;\nimport isObject from '@stdlib/assert-is-object' ;\nimport isFunction from '@stdlib/assert-is-function' ;\nimport ctors from '@stdlib/array-ctors' ;\nimport gfillBy from '@stdlib/blas-ext-base-gfill-by' ;\nimport filledArray from '@stdlib/array-base-filled-by' ;\nimport hasIteratorSymbolSupport from '@stdlib/assert-has-iterator-symbol-support' ;\nimport ITERATOR_SYMBOL from '@stdlib/symbol-iterator' ;\nimport iterLength from '@stdlib/iter-length' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\n\n\n// VARIABLES //\n\nvar HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport();\nvar DEFAULT_DTYPE = 'float64';\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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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( format( '00L05' ) );\n\t\t}\n\t\tctor = ctors( dtype );\n\t\tif ( ctor === null ) {\n\t\t\tthrow new TypeError( format( '00L2k', 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( format( '00L05' ) );\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( format( '00L05' ) );\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( '00L2n', 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( format( '00L05' ) );\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( '00L2k', 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( format( '00L04' ) );\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( '00L2l', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00L2m', 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( '00L2m', 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( '00L2m', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format( '00L04' ) );\n\t\t}\n\t\tthrow new TypeError( format( '00L2m', 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( '00L2l', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00L2m', 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( '00L2m', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00L2m', 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\nexport default filledarrayBy;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","filledArrayIterator","it","clbk","thisArg","arr","i","next","done","push","call","filledAccessors","length","set","filledarrayBy","nargs","dtype","ctor","len","arg","arguments","ctors","isString","TypeError","format","isFunction","isNonNegativeInteger","isCollection","filledArray","isArrayBuffer","Error","isObject","ITERATOR_SYMBOL","iterLength","test","gfillBy","callback","value","aidx"],"mappings":";;ipCAuCA,IAAIA,EAAsBC,IAe1B,SAASC,EAAqBC,EAAIC,EAAMC,GACvC,IAAIC,EACAC,EAKJ,IAFAD,EAAM,GACNC,GAAK,GAEAJ,EAAGK,OACAC,MAGPF,GAAK,EACLD,EAAII,KAAMN,EAAKO,KAAMN,EAASE,IAE/B,OAAOD,EAYR,SAASM,EAAiBN,EAAKF,EAAMC,GACpC,IAAIE,EACJ,IAAMA,EAAI,EAAGA,EAAID,EAAIO,OAAQN,IAC5BD,EAAIQ,IAAKV,EAAKO,KAAMN,EAASE,GAAKA,GAEnC,OAAOD,EA6JR,SAASS,IACR,IAAIV,EACAW,EACAC,EACAb,EACAc,EACAZ,EACAa,EACAC,EAKJ,GAAe,KAHfJ,EAAQK,UAAUR,QAKjB,OAAO,IADPK,EAAOI,EAzNW,YA0ND,GAIlB,GAAKC,EADLN,EAAQI,UAAW,IACM,CAExB,GAAKL,EAAQ,EACZ,MAAM,IAAIQ,UAAWC,EAAQ,UAG9B,GAAc,QADdP,EAAOI,EAAOL,IAEb,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAGvC,OAAO,IAAIC,EAAM,GAGlB,GAAKF,EAAQ,EACZ,MAAM,IAAIQ,UAAWC,EAAQ,UAM9B,GAAKC,EAAYL,UAHjBL,GAAS,IAKR,GAAKU,EAAYL,UAAWL,EAAM,KAMjC,GALAX,EAAUgB,UAAWL,GAErBZ,EAAOiB,UADPL,GAAS,GAIM,IAAVA,EACJ,MAAM,IAAIQ,UAAWC,EAAQ,eAI9BrB,EAAOiB,UAAWL,OAIf,MAAKA,GAAS,GAUlB,MAAM,IAAIQ,UAAWC,EAAQ,UAN7B,GAHApB,EAAUgB,UAAWL,IAGfU,EADNtB,EAAOiB,UADPL,GAAS,IAGR,MAAM,IAAIQ,UAAWC,EAAQ,QAASrB,IAgBxC,IARAY,GAAS,IACK,GAAKO,EAAUF,UAAWL,KACvCC,EAAQI,UAAWL,GACnBA,GAAS,GAETC,EArRkB,UAwRL,QADdC,EAAOI,EAAOL,IAEb,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAGvC,GAAe,YAAVA,EAAsB,CAE1B,GADAG,EAAMC,UAAW,GACF,IAAVL,EAAc,CAMlB,GALKW,EAAsBP,GAC1BD,EAAMC,EACKQ,EAAcR,KACzBD,EAAMC,EAAIP,aAEE,IAARM,EACJ,OAAOU,EAAaV,EAAKf,EAAMC,GAEhC,GAAKyB,EAAeV,GACnB,MAAM,IAAIW,MAAON,EAAQ,UAE1B,GAAKO,EAAUZ,GAAQ,CACtB,IAA6B,IAAxBpB,EACJ,MAAM,IAAIwB,UAAWC,EAAQ,QAASL,IAEvC,IAAMM,EAAYN,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASL,IAGvC,GADAA,EAAMA,EAAKa,MACLP,EAAYN,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,QAASL,IAEvC,OAAOlB,EAAqBkB,EAAKhB,EAAMC,GAExC,MAAM,IAAImB,UAAWC,EAAQ,QAASL,IAChC,GAAKU,EAAeV,GAC1B,MAAM,IAAIW,MAAON,EAAQ,UAE1B,MAAM,IAAID,UAAWC,EAAQ,QAASL,IAEvC,GAAe,IAAVJ,EAEJ,GAAKY,EADLR,EAAMC,UAAW,IAEhBf,EAAM,IAAIY,EAAME,EAAIP,aACd,GAAKiB,EAAeV,GAC1Bd,EAAM,IAAIY,EAAME,QACV,GAAKO,EAAsBP,GACjCd,EAAM,IAAIY,EAAME,OACV,KAAKY,EAAUZ,GAarB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAZtC,IAA6B,IAAxBpB,EACJ,MAAM,IAAIwB,UAAWC,EAAQ,QAASL,IAEvC,IAAMM,EAAYN,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASL,IAGvC,GADAA,EAAMA,EAAKa,MACLP,EAAYN,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,QAASL,IAEvCd,EAAM,IAAIY,EAAMgB,EAAYd,SAK7Bd,EADqB,IAAVU,EACL,IAAIE,EAAMG,UAAU,GAAIA,UAAU,IAElC,IAAIH,EAAMG,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKf,EAAIO,OAAS,IACZ,WAAWsB,KAAMlB,GACrBL,EAAiBN,EAAKF,EAAMC,GAE5B+B,EAAS9B,EAAIO,OAAQP,EAAK,EAAG+B,IAGxB/B,EAYP,SAAS+B,EAAUC,EAAOC,GACzB,OAAOnC,EAAKO,KAAMN,EAASkC"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d115cf0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,192 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -/** -* Create a filled array according to a provided callback function. -* -* @module @stdlib/array-filled-by -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* var arr = filledarrayBy(); -* // returns -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'generic', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( [ 0.5, 0.5 ], clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1; -* } -* -* var arr = filledarrayBy( [ 5, -3 ], 'int32', clbk ); -* // returns [ 1, 1 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk1() { -* return 10; -* } -* -* function clbk2() { -* return 1.0; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, clbk2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk1() { -* return 1.0; -* } -* -* function clbk2() { -* return 2; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, 'uint32', clbk2 ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 'float32', clbk ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, clbk ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, 'int32', clbk ); -* // returns [ 1, 1 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index d6fbe5e..0000000 --- a/lib/main.js +++ /dev/null @@ -1,413 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var isCollection = require( '@stdlib/assert-is-collection' ); -var isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isObject = require( '@stdlib/assert-is-object' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var ctors = require( '@stdlib/array-ctors' ); -var gfillBy = require( '@stdlib/blas-ext-base-gfill-by' ); -var filledArray = require( '@stdlib/array-base-filled-by' ); -var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var iterLength = require( '@stdlib/iter-length' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport(); -var DEFAULT_DTYPE = 'float64'; - - -// FUNCTIONS // - -/** -* Creates a filled "generic" array from an iterator. -* -* @private -* @param {Iterable} it - iterator -* @param {Callback} clbk - callback function -* @param {*} thisArg - callback function execution context -* @returns {Array} filled array -*/ -function filledArrayIterator( it, clbk, thisArg ) { - var arr; - var i; - var v; - - arr = []; - i = -1; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - i += 1; - arr.push( clbk.call( thisArg, i ) ); - } - return arr; -} - -/** -* Fills an array exposing accessors for getting and setting array elements. -* -* @private -* @param {Collection} arr - input array -* @param {Callback} clbk - callback function -* @param {*} thisArg - callback function execution context -* @returns {Collection} input array -*/ -function filledAccessors( arr, clbk, thisArg ) { - var i; - for ( i = 0; i < arr.length; i++ ) { - arr.set( clbk.call( thisArg, i ), i ); - } - return arr; -} - - -// MAIN // - -/** -* Creates a filled array according to a provided callback function. -* -* @param {(NonNegativeInteger|TypedArray|ArrayLikeObject|ArrayBuffer|Iterable)} [arg] - a length, typed array, array-like object, buffer, or iterable -* @param {NonNegativeInteger} [byteOffset=0] - byte offset -* @param {NonNegativeInteger} [length] - view length -* @param {string} [dtype="float64"] - data type -* @param {Callback} [clbk] - callback to invoke -* @param {*} [thisArg] - callback execution context -* @throws {TypeError} must provide a recognized data type -* @throws {TypeError} must provide a length, typed array, array-like object, buffer, or iterable -* @throws {TypeError} callback argument must be a function. -* @throws {Error} creating a generic array from an `ArrayBuffer` is not supported -* @returns {(TypedArray|Array)} array or typed array -* -* @example -* var arr = filledarrayBy(); -* // returns -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'generic', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( [ 0.5, 0.5 ], clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1; -* } -* -* var arr = filledarrayBy( [ 5, -3 ], 'int32', clbk ); -* // returns [ 1, 1 ] -* -* @example -* function clbk1() { -* return 10; -* } -* -* function clbk2() { -* return 1.0; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, clbk2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk1() { -* return 1.0; -* } -* -* function clbk2() { -* return 2; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, 'uint32', clbk2 ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 'float32', clbk ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, clbk ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, 'int32', clbk ); -* // returns [ 1, 1 ] -*/ -function filledarrayBy() { - var thisArg; - var nargs; - var dtype; - var clbk; - var ctor; - var arr; - var len; - var arg; - - nargs = arguments.length; - - // If we weren't provided any arguments, return an empty array... - if ( nargs === 0 ) { - ctor = ctors( DEFAULT_DTYPE ); - return new ctor( 0 ); - } - // Check if we were provided a dtype as the first argument... - dtype = arguments[ 0 ]; - if ( isString( dtype ) ) { - // Invoking this function with arguments `f( dtype, clbk[, thisArg] )` is not allowed (otherwise, we'd need to also allow `f( clbk[, thisArg] )`)... - if ( nargs > 1 ) { - throw new TypeError( format( '00L05' ) ); - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '00L2k', dtype ) ); - } - // Return an empty array having the specified dtype: - return new ctor( 0 ); - } - // For all other supported invocations, we need at least two arguments... - if ( nargs < 2 ) { - throw new TypeError( format( '00L05' ) ); - } - // At this point, we need to do some argument juggling... - nargs -= 1; // henceforth, the number of available arguments is `nargs+1` - - // Determine whether the last argument is a callback or "this" context... - if ( isFunction( arguments[ nargs ] ) ) { - // 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... - if ( isFunction( arguments[ nargs-1 ] ) ) { - thisArg = arguments[ nargs ]; - nargs -= 1; - clbk = arguments[ nargs ]; - - // Check if we were provided only a callback and a "this" context.. - if ( nargs === 0 ) { - throw new TypeError( format( '00L05' ) ); - } - } else { - // "this" context is left undefined... - clbk = arguments[ nargs ]; - } - } - // 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... - else if ( nargs >= 2 ) { - thisArg = arguments[ nargs ]; - nargs -= 1; - clbk = arguments[ nargs ]; - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '00L2n', clbk ) ); - } - } - // If were were only provided 2 arguments and the last argument was not a function, we've been provided an insufficient number of arguments... - else { - throw new TypeError( format( '00L05' ) ); - } - // Now that we've processed the callback arguments, let's continue working backward to see if we've been provided a `dtype` argument... - nargs -= 1; - if ( nargs >= 0 && isString( arguments[ nargs ] ) ) { - dtype = arguments[ nargs ]; - nargs -= 1; - } else { - dtype = DEFAULT_DTYPE; - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '00L2k', dtype ) ); - } - // At this point, we've resolved the output array data type, and now we can actually create the output array... - if ( dtype === 'generic' ) { - arg = arguments[ 0 ]; - if ( nargs === 0 ) { - if ( isNonNegativeInteger( arg ) ) { - len = arg; - } else if ( isCollection( arg ) ) { - len = arg.length; - } - if ( len !== void 0 ) { - return filledArray( len, clbk, thisArg ); - } - if ( isArrayBuffer( arg ) ) { - throw new Error( format( '00L04' ) ); - } - if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( '00L2l', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00L2m', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00L2m', arg ) ); - } - return filledArrayIterator( arg, clbk, thisArg ); - } - throw new TypeError( format( '00L2m', arg ) ); - } else if ( isArrayBuffer( arg ) ) { - throw new Error( format( '00L04' ) ); - } - throw new TypeError( format( '00L2m', arg ) ); - } - if ( nargs === 0 ) { // length || array-like || ArrayBuffer || iterable - arg = arguments[ 0 ]; - if ( isCollection( arg ) ) { - arr = new ctor( arg.length ); - } else if ( isArrayBuffer( arg ) ) { - arr = new ctor( arg ); - } else if ( isNonNegativeInteger( arg ) ) { - arr = new ctor( arg ); - } else if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( '00L2l', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00L2m', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00L2m', arg ) ); - } - arr = new ctor( iterLength( arg ) ); - } else { - throw new TypeError( format( '00L2m', arg ) ); - } - } else if ( nargs === 1 ) { - arr = new ctor( arguments[0], arguments[1] ); // (ArrayBuffer, byteOffset) - } else { - arr = new ctor( arguments[0], arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset, length) - } - if ( arr.length > 0 ) { - if ( /^complex/.test( dtype ) ) { - filledAccessors( arr, clbk, thisArg ); - } else { - gfillBy( arr.length, arr, 1, callback ); - } - } - return arr; - - /** - * Callback which wraps a provided callback and is invoked for each array element. - * - * @private - * @param {*} value - element value - * @param {NonNegativeInteger} aidx - array index - * @param {NonNegativeInteger} sidx - strided index - * @param {Collection} array - input array/collection - * @returns {*} callback return value - */ - function callback( value, aidx ) { - return clbk.call( thisArg, aidx ); - } -} - - -// EXPORTS // - -module.exports = filledarrayBy; diff --git a/package.json b/package.json index 6511a88..498622b 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.2", "description": "Create a filled array according to a provided callback function.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,69 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-filled-by": "^0.0.x", - "@stdlib/array-ctors": "^0.0.x", - "@stdlib/assert-has-iterator-symbol-support": "^0.0.x", - "@stdlib/assert-is-arraybuffer": "^0.0.x", - "@stdlib/assert-is-collection": "^0.0.x", - "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/assert-is-nonnegative-integer": "^0.0.x", - "@stdlib/assert-is-object": "^0.0.x", - "@stdlib/assert-is-string": "^0.0.x", - "@stdlib/blas-ext-base-gfill-by": "^0.0.x", - "@stdlib/iter-length": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x", - "@stdlib/symbol-iterator": "^0.0.x", - "@stdlib/types": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-buffer": "^0.0.x", - "@stdlib/array-complex128": "^0.0.x", - "@stdlib/array-complex64": "^0.0.x", - "@stdlib/array-float32": "^0.0.x", - "@stdlib/array-float64": "^0.0.x", - "@stdlib/array-int16": "^0.0.x", - "@stdlib/array-int32": "^0.0.x", - "@stdlib/array-int8": "^0.0.x", - "@stdlib/array-typed-real-dtypes": "^0.0.x", - "@stdlib/array-uint16": "^0.0.x", - "@stdlib/array-uint32": "^0.0.x", - "@stdlib/array-uint8": "^0.0.x", - "@stdlib/array-uint8c": "^0.0.x", - "@stdlib/assert-instance-of": "^0.0.x", - "@stdlib/assert-is-array": "^0.0.x", - "@stdlib/assert-is-typed-array": "^0.0.x", - "@stdlib/assert-is-typed-array-like": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/complex-float32": "^0.0.x", - "@stdlib/complex-float64": "^0.0.x", - "@stdlib/iter-constant": "^0.0.x", - "@stdlib/math-base-special-pow": "^0.0.x", - "@stdlib/random-base-discrete-uniform": "^0.0.x", - "@stdlib/strided-base-reinterpret-complex128": "^0.0.x", - "@stdlib/strided-base-reinterpret-complex64": "^0.0.x", - "@stdlib/utils-constant-function": "^0.0.x", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..9fceda3 --- /dev/null +++ b/stats.html @@ -0,0 +1,2689 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index b55aa4a..0000000 --- a/test/test.js +++ /dev/null @@ -1,4248 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 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. -*/ - -/* eslint-disable max-len */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -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 ArrayBuffer = require( '@stdlib/array-buffer' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var iterConstant = require( '@stdlib/iter-constant' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var filledarrayBy = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': !hasIteratorSymbolSupport() -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof filledarrayBy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if only provided callback arguments', function test( t ) { - t.throws( clbk1, TypeError, 'throws an error' ); - t.throws( clbk2, TypeError, 'throws an error' ); - t.throws( clbk3, TypeError, 'throws an error' ); - t.end(); - - function clbk1() { - filledarrayBy( constantFunction( 1.0 ) ); - } - - function clbk2() { - filledarrayBy( constantFunction( 1.0 ), {} ); - } - - function clbk3() { - filledarrayBy( constantFunction( 1.0 ), constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (only argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (typed array; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (array-like object)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (array-like object; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 8 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 8 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, 1, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (iterator)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( iterConstant( 1.0 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (iterator; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( iterConstant( 1.0 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if only provided data type and callback arguments', function test( t ) { - t.throws( clbk1, TypeError, 'throws an error' ); - t.throws( clbk2, TypeError, 'throws an error' ); - t.throws( clbk3, TypeError, 'throws an error' ); - t.end(); - - function clbk1() { - filledarrayBy( 'float64', constantFunction( 1.0 ) ); - } - - function clbk2() { - filledarrayBy( 'float64', constantFunction( 1.0 ), {} ); - } - - function clbk3() { - filledarrayBy( 'float64', constantFunction( 1.0 ), constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (array-like object)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (array-like object; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, 1, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, 1, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (no iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (no iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (non-function iterator symbol property)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (non-function iterator symbol property; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (`next` property is not a function)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ) ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (`next` property is not a function; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ), {} ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (no iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (no iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (non-function iterator symbol property)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (non-function iterator symbol property; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (`next` property is not a function)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ) ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (`next` property is not a function; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ), {} ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 1, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 1, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function returns a filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - arr = filledarrayBy(); - - t.strictEqual( instanceOf( arr, Float64Array ), 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=float64)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - arr = filledarrayBy( 'float64' ); - - t.strictEqual( instanceOf( arr, Float64Array ), 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=float32)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( 0 ); - arr = filledarrayBy( 'float32' ); - - t.strictEqual( instanceOf( arr, Float32Array ), 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; - - expected = new Complex128Array( 0 ); - arr = filledarrayBy( 'complex128' ); - - t.strictEqual( instanceOf( arr, Complex128Array ), 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=complex64)', function test( t ) { - var expected; - var arr; - - expected = new Complex64Array( 0 ); - arr = filledarrayBy( 'complex64' ); - - t.strictEqual( instanceOf( arr, Complex64Array ), 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=int32)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( 0 ); - arr = filledarrayBy( 'int32' ); - - t.strictEqual( instanceOf( arr, Int32Array ), 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=uint32)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( 0 ); - arr = filledarrayBy( 'uint32' ); - - t.strictEqual( instanceOf( arr, Uint32Array ), 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=int16)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( 0 ); - arr = filledarrayBy( 'int16' ); - - t.strictEqual( instanceOf( arr, Int16Array ), 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=uint16)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( 0 ); - arr = filledarrayBy( 'uint16' ); - - t.strictEqual( instanceOf( arr, Uint16Array ), 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=int8)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( 0 ); - arr = filledarrayBy( 'int8' ); - - t.strictEqual( instanceOf( arr, Int8Array ), 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=uint8)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( 0 ); - arr = filledarrayBy( 'uint8' ); - - t.strictEqual( instanceOf( arr, Uint8Array ), 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=uint8c)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( 0 ); - arr = filledarrayBy( 'uint8c' ); - - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), 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=generic)', function test( t ) { - var expected; - var arr; - - expected = []; - arr = filledarrayBy( 'generic' ); - - t.strictEqual( instanceOf( arr, Array ), 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 (default, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, length=0)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array(); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 0, clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, clbk, ctx ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (default, length; thisArg=function)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, clbk, context ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this(); // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } - - function context() { - ctx.count += 1; - } -}); - -tape( 'the function returns a filled array (dtype=float64, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, 'float64', clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, length; thisArg=function)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, 'float64', clbk, context ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this(); // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } - - function context() { - ctx.count += 1; - } -}); - -tape( 'the function returns a filled array (dtype=float32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, 'float32', clbk ); - - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex128, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = filledarrayBy( 5, 'complex128', clbk ); - - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = filledarrayBy( 5, 'complex64', clbk ); - - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int32Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int32', clbk ); - - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint32Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint32', clbk ); - - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int16Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int16', clbk ); - - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint16', clbk ); - - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int8Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int8', clbk ); - - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint8', clbk ); - - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint8c', clbk ); - - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = [ 1, 1, 1, 1, 1 ]; - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'generic', clbk ); - - t.strictEqual( instanceOf( arr, Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex128, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = [ 1.0, 2.0 ]; - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = [ 1.0, 2.0 ]; - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int32', clbk ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, typed array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, typed array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex128, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = new Float64Array( [ 1.0, 2.0 ] ); - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = new Float64Array( [ 1.0, 2.0 ] ); - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (default, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex128, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer, byteoffset; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer, byteoffset; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, 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; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 48 ); - out = filledarrayBy( buf, 16, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 24 ); - out = filledarrayBy( buf, 8, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int32', clbk ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint8c', clbk ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, 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; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 64 ); - out = filledarrayBy( buf, 16, 2, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset, length)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 1, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 1, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled array (default, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, iterator; thisArg)', opts, function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - ctx = { - 'count': 0 - }; - indices = []; - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, iterator; thisArg)', opts, function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - ctx = { - 'count': 0 - }; - indices = []; - out = filledarrayBy( arr, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex128, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = iterConstant( new Complex128( 3.0, 3.0 ), { - 'iter': 2 - }); - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = iterConstant( new Complex64( 3.0, 3.0 ), { - 'iter': 2 - }); - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); From 0b97fea17ef8d691cf6b3cecd2b1751e1bd14c1e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Aug 2022 04:03:22 +0000 Subject: [PATCH 011/117] Transform error messages --- lib/main.js | 38 +++++++++++++++++++------------------- package.json | 2 +- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/lib/main.js b/lib/main.js index d27b055..d6fbe5e 100644 --- a/lib/main.js +++ b/lib/main.js @@ -32,7 +32,7 @@ var filledArray = require( '@stdlib/array-base-filled-by' ); var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); var iterLength = require( '@stdlib/iter-length' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -263,18 +263,18 @@ function filledarrayBy() { if ( isString( dtype ) ) { // Invoking this function with arguments `f( dtype, clbk[, thisArg] )` is not allowed (otherwise, we'd need to also allow `f( clbk[, thisArg] )`)... if ( nargs > 1 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format( '00L05' ) ); } ctor = ctors( dtype ); if ( ctor === null ) { - throw new TypeError( format( 'invalid argument. Must provide a recognized data type. Value: `%s`.', dtype ) ); + throw new TypeError( format( '00L2k', dtype ) ); } // Return an empty array having the specified dtype: return new ctor( 0 ); } // For all other supported invocations, we need at least two arguments... if ( nargs < 2 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format( '00L05' ) ); } // At this point, we need to do some argument juggling... nargs -= 1; // henceforth, the number of available arguments is `nargs+1` @@ -289,7 +289,7 @@ function filledarrayBy() { // Check if we were provided only a callback and a "this" context.. if ( nargs === 0 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format( '00L05' ) ); } } else { // "this" context is left undefined... @@ -302,12 +302,12 @@ function filledarrayBy() { nargs -= 1; clbk = arguments[ nargs ]; if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '00L2n', clbk ) ); } } // If were were only provided 2 arguments and the last argument was not a function, we've been provided an insufficient number of arguments... else { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format( '00L05' ) ); } // Now that we've processed the callback arguments, let's continue working backward to see if we've been provided a `dtype` argument... nargs -= 1; @@ -319,7 +319,7 @@ function filledarrayBy() { } ctor = ctors( dtype ); if ( ctor === null ) { - throw new TypeError( format( 'invalid argument. Must provide a recognized data type. Value: `%s`.', dtype ) ); + throw new TypeError( format( '00L2k', dtype ) ); } // At this point, we've resolved the output array data type, and now we can actually create the output array... if ( dtype === 'generic' ) { @@ -334,26 +334,26 @@ function filledarrayBy() { return filledArray( len, clbk, thisArg ); } if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format( '00L04' ) ); } if ( isObject( arg ) ) { if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.', arg ) ); + throw new TypeError( format( '00L2l', arg ) ); } if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00L2m', arg ) ); } arg = arg[ ITERATOR_SYMBOL ](); if ( !isFunction( arg.next ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00L2m', arg ) ); } return filledArrayIterator( arg, clbk, thisArg ); } - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00L2m', arg ) ); } else if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format( '00L04' ) ); } - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00L2m', arg ) ); } if ( nargs === 0 ) { // length || array-like || ArrayBuffer || iterable arg = arguments[ 0 ]; @@ -365,18 +365,18 @@ function filledarrayBy() { arr = new ctor( arg ); } else if ( isObject( arg ) ) { if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.', arg ) ); + throw new TypeError( format( '00L2l', arg ) ); } if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00L2m', arg ) ); } arg = arg[ ITERATOR_SYMBOL ](); if ( !isFunction( arg.next ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00L2m', arg ) ); } arr = new ctor( iterLength( arg ) ); } else { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00L2m', arg ) ); } } else if ( nargs === 1 ) { arr = new ctor( arguments[0], arguments[1] ); // (ArrayBuffer, byteOffset) diff --git a/package.json b/package.json index b974a7b..6511a88 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "@stdlib/assert-is-string": "^0.0.x", "@stdlib/blas-ext-base-gfill-by": "^0.0.x", "@stdlib/iter-length": "^0.0.x", - "@stdlib/string-format": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x", "@stdlib/symbol-iterator": "^0.0.x", "@stdlib/types": "^0.0.x" }, From 83715566f805184e42e7a61fdd5d91ae289c9402 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Aug 2022 14:56:29 +0000 Subject: [PATCH 012/117] Remove files --- index.d.ts | 427 -------- index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 3121 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 2156674..0000000 --- a/index.d.ts +++ /dev/null @@ -1,427 +0,0 @@ -/* -* @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. -*/ - -// TypeScript Version: 2.0 - -/// - -import { RealOrComplexTypedArray, DataType } from '@stdlib/types/array'; -import { Collection } from '@stdlib/types/object'; -import { IterableIterator } from '@stdlib/types/iter'; - -/** -* Array or typed array. -*/ -type ArrayOrTypedArray = Array | RealOrComplexTypedArray; - -/** -* Nullary callback function. -* -* @returns fill value -*/ -type Nullary = () => any; - -/** -* Unary callback function. -* -* @param i - current array index -* @returns fill value -*/ -type Unary = ( i: number ) => any; - -/** -* Callback function. -* -* @param i - current array index -* @returns fill value -*/ -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 -* -* @example -* var arr = filledarrayBy(); -* // returns -* -* @example -* var arr = filledarrayBy( 'float32' ); -* // returns -*/ -declare function filledarrayBy( dtype?: DataType ): ArrayOrTypedArray; // tslint:disable-line:unified-signatures - -/** -* Creates a filled array according to a provided callback function and having a specified `length`. -* -* @param length - array length -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* -* var arr = filledarrayBy( 5, constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( length: number, clbk: Callback, thisArg?: any ): ArrayOrTypedArray; // tslint:disable-line:max-line-length unified-signatures - -/** -* 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 -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* -* var arr = filledarrayBy( 5, 'float64', constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( length: number, dtype: DataType, clbk: Callback, thisArg?: any ): ArrayOrTypedArray; // tslint:disable-line:max-line-length unified-signatures - -/** -* Creates a filled array from another `array` according to a provided callback function. -* -* @param array - typed array or array-like object -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* -* 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; // tslint:disable-line:max-line-length 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 -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* -* 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; // tslint:disable-line:max-line-length unified-signatures - -/** -* Creates a filled array from an iterable according to a callback function. -* -* @param iterable - iterable -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* var iterConstant = require( `@stdlib/iter/constant` ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarrayBy( it, constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( iterable: IterableIterator, callback: Callback, thisArg?: any ): ArrayOrTypedArray; // tslint:disable-line:max-line-length 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 -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* var iterConstant = require( `@stdlib/iter/constant` ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* 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; // tslint:disable-line:max-line-length unified-signatures - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; // tslint:disable-line:max-line-length - -/** -* 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. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; // tslint:disable-line:max-line-length unified-signatures - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; // tslint:disable-line:max-line-length - -/** -* 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. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; // tslint:disable-line:max-line-length unified-signatures - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; // tslint:disable-line:max-line-length 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. -* -* @param buffer - `ArrayBuffer` -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; // tslint:disable-line:max-line-length unified-signatures - - -// EXPORTS // - -export = filledarrayBy; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index ea454f9..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-ctors@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill-by@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled-by@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";var w=d();function j(r,e,t){var s,i;for(s=[],i=-1;!r.next().done;)i+=1,s.push(e.call(t,i));return s}function a(r,e,t){var s;for(s=0;s1)throw new TypeError(p("00L05"));if(null===(b=o(g)))throw new TypeError(p("00L2k",g));return new b(0)}if(c<2)throw new TypeError(p("00L05"));if(n(arguments[c-=1]))if(n(arguments[c-1])){if(d=arguments[c],y=arguments[c-=1],0===c)throw new TypeError(p("00L05"))}else y=arguments[c];else{if(!(c>=2))throw new TypeError(p("00L05"));if(d=arguments[c],!n(y=arguments[c-=1]))throw new TypeError(p("00L2n",y))}if((c-=1)>=0&&r(arguments[c])?(g=arguments[c],c-=1):g="float64",null===(b=o(g)))throw new TypeError(p("00L2k",g));if("generic"===g){if(x=arguments[0],0===c){if(e(x)?u=x:t(x)&&(u=x.length),void 0!==u)return m(u,y,d);if(s(x))throw new Error(p("00L04"));if(i(x)){if(!1===w)throw new TypeError(p("00L2l",x));if(!n(x[f]))throw new TypeError(p("00L2m",x));if(x=x[f](),!n(x.next))throw new TypeError(p("00L2m",x));return j(x,y,d)}throw new TypeError(p("00L2m",x))}if(s(x))throw new Error(p("00L04"));throw new TypeError(p("00L2m",x))}if(0===c)if(t(x=arguments[0]))v=new b(x.length);else if(s(x))v=new b(x);else if(e(x))v=new b(x);else{if(!i(x))throw new TypeError(p("00L2m",x));if(!1===w)throw new TypeError(p("00L2l",x));if(!n(x[f]))throw new TypeError(p("00L2m",x));if(x=x[f](),!n(x.next))throw new TypeError(p("00L2m",x));v=new b(h(x))}else v=1===c?new b(arguments[0],arguments[1]):new b(arguments[0],arguments[1],arguments[2]);return v.length>0&&(/^complex/.test(g)?a(v,y,d):l(v.length,v,1,E)),v;function E(r,e){return y.call(d,e)}}export{c as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index d359dd2..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.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\nimport { isPrimitive as isString } from '@stdlib/assert-is-string' ;\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer' ;\nimport isCollection from '@stdlib/assert-is-collection' ;\nimport isArrayBuffer from '@stdlib/assert-is-arraybuffer' ;\nimport isObject from '@stdlib/assert-is-object' ;\nimport isFunction from '@stdlib/assert-is-function' ;\nimport ctors from '@stdlib/array-ctors' ;\nimport gfillBy from '@stdlib/blas-ext-base-gfill-by' ;\nimport filledArray from '@stdlib/array-base-filled-by' ;\nimport hasIteratorSymbolSupport from '@stdlib/assert-has-iterator-symbol-support' ;\nimport ITERATOR_SYMBOL from '@stdlib/symbol-iterator' ;\nimport iterLength from '@stdlib/iter-length' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\n\n\n// VARIABLES //\n\nvar HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport();\nvar DEFAULT_DTYPE = 'float64';\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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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( format( '00L05' ) );\n\t\t}\n\t\tctor = ctors( dtype );\n\t\tif ( ctor === null ) {\n\t\t\tthrow new TypeError( format( '00L2k', 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( format( '00L05' ) );\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( format( '00L05' ) );\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( '00L2n', 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( format( '00L05' ) );\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( '00L2k', 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( format( '00L04' ) );\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( '00L2l', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00L2m', 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( '00L2m', 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( '00L2m', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format( '00L04' ) );\n\t\t}\n\t\tthrow new TypeError( format( '00L2m', 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( '00L2l', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00L2m', 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( '00L2m', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00L2m', 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\nexport default filledarrayBy;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","filledArrayIterator","it","clbk","thisArg","arr","i","next","done","push","call","filledAccessors","length","set","filledarrayBy","nargs","dtype","ctor","len","arg","arguments","ctors","isString","TypeError","format","isFunction","isNonNegativeInteger","isCollection","filledArray","isArrayBuffer","Error","isObject","ITERATOR_SYMBOL","iterLength","test","gfillBy","callback","value","aidx"],"mappings":";;ipCAuCA,IAAIA,EAAsBC,IAe1B,SAASC,EAAqBC,EAAIC,EAAMC,GACvC,IAAIC,EACAC,EAKJ,IAFAD,EAAM,GACNC,GAAK,GAEAJ,EAAGK,OACAC,MAGPF,GAAK,EACLD,EAAII,KAAMN,EAAKO,KAAMN,EAASE,IAE/B,OAAOD,EAYR,SAASM,EAAiBN,EAAKF,EAAMC,GACpC,IAAIE,EACJ,IAAMA,EAAI,EAAGA,EAAID,EAAIO,OAAQN,IAC5BD,EAAIQ,IAAKV,EAAKO,KAAMN,EAASE,GAAKA,GAEnC,OAAOD,EA6JR,SAASS,IACR,IAAIV,EACAW,EACAC,EACAb,EACAc,EACAZ,EACAa,EACAC,EAKJ,GAAe,KAHfJ,EAAQK,UAAUR,QAKjB,OAAO,IADPK,EAAOI,EAzNW,YA0ND,GAIlB,GAAKC,EADLN,EAAQI,UAAW,IACM,CAExB,GAAKL,EAAQ,EACZ,MAAM,IAAIQ,UAAWC,EAAQ,UAG9B,GAAc,QADdP,EAAOI,EAAOL,IAEb,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAGvC,OAAO,IAAIC,EAAM,GAGlB,GAAKF,EAAQ,EACZ,MAAM,IAAIQ,UAAWC,EAAQ,UAM9B,GAAKC,EAAYL,UAHjBL,GAAS,IAKR,GAAKU,EAAYL,UAAWL,EAAM,KAMjC,GALAX,EAAUgB,UAAWL,GAErBZ,EAAOiB,UADPL,GAAS,GAIM,IAAVA,EACJ,MAAM,IAAIQ,UAAWC,EAAQ,eAI9BrB,EAAOiB,UAAWL,OAIf,MAAKA,GAAS,GAUlB,MAAM,IAAIQ,UAAWC,EAAQ,UAN7B,GAHApB,EAAUgB,UAAWL,IAGfU,EADNtB,EAAOiB,UADPL,GAAS,IAGR,MAAM,IAAIQ,UAAWC,EAAQ,QAASrB,IAgBxC,IARAY,GAAS,IACK,GAAKO,EAAUF,UAAWL,KACvCC,EAAQI,UAAWL,GACnBA,GAAS,GAETC,EArRkB,UAwRL,QADdC,EAAOI,EAAOL,IAEb,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAGvC,GAAe,YAAVA,EAAsB,CAE1B,GADAG,EAAMC,UAAW,GACF,IAAVL,EAAc,CAMlB,GALKW,EAAsBP,GAC1BD,EAAMC,EACKQ,EAAcR,KACzBD,EAAMC,EAAIP,aAEE,IAARM,EACJ,OAAOU,EAAaV,EAAKf,EAAMC,GAEhC,GAAKyB,EAAeV,GACnB,MAAM,IAAIW,MAAON,EAAQ,UAE1B,GAAKO,EAAUZ,GAAQ,CACtB,IAA6B,IAAxBpB,EACJ,MAAM,IAAIwB,UAAWC,EAAQ,QAASL,IAEvC,IAAMM,EAAYN,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASL,IAGvC,GADAA,EAAMA,EAAKa,MACLP,EAAYN,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,QAASL,IAEvC,OAAOlB,EAAqBkB,EAAKhB,EAAMC,GAExC,MAAM,IAAImB,UAAWC,EAAQ,QAASL,IAChC,GAAKU,EAAeV,GAC1B,MAAM,IAAIW,MAAON,EAAQ,UAE1B,MAAM,IAAID,UAAWC,EAAQ,QAASL,IAEvC,GAAe,IAAVJ,EAEJ,GAAKY,EADLR,EAAMC,UAAW,IAEhBf,EAAM,IAAIY,EAAME,EAAIP,aACd,GAAKiB,EAAeV,GAC1Bd,EAAM,IAAIY,EAAME,QACV,GAAKO,EAAsBP,GACjCd,EAAM,IAAIY,EAAME,OACV,KAAKY,EAAUZ,GAarB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAZtC,IAA6B,IAAxBpB,EACJ,MAAM,IAAIwB,UAAWC,EAAQ,QAASL,IAEvC,IAAMM,EAAYN,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASL,IAGvC,GADAA,EAAMA,EAAKa,MACLP,EAAYN,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,QAASL,IAEvCd,EAAM,IAAIY,EAAMgB,EAAYd,SAK7Bd,EADqB,IAAVU,EACL,IAAIE,EAAMG,UAAU,GAAIA,UAAU,IAElC,IAAIH,EAAMG,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKf,EAAIO,OAAS,IACZ,WAAWsB,KAAMlB,GACrBL,EAAiBN,EAAKF,EAAMC,GAE5B+B,EAAS9B,EAAIO,OAAQP,EAAK,EAAG+B,IAGxB/B,EAYP,SAAS+B,EAAUC,EAAOC,GACzB,OAAOnC,EAAKO,KAAMN,EAASkC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 9fceda3..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From e679cc7bc1697f15ffc72a023a22df01e84f4d4c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Aug 2022 14:57:35 +0000 Subject: [PATCH 013/117] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 33 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 760 ---- .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 178 - .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 41 +- benchmark/benchmark.js | 319 -- benchmark/benchmark.length.complex128.js | 98 - benchmark/benchmark.length.complex64.js | 98 - benchmark/benchmark.length.float32.js | 97 - benchmark/benchmark.length.float64.js | 97 - benchmark/benchmark.length.generic.js | 97 - benchmark/benchmark.length.int16.js | 97 - benchmark/benchmark.length.int32.js | 97 - benchmark/benchmark.length.int8.js | 97 - benchmark/benchmark.length.uint16.js | 97 - benchmark/benchmark.length.uint32.js | 97 - benchmark/benchmark.length.uint8.js | 97 - benchmark/benchmark.length.uint8c.js | 97 - branches.md | 53 - docs/repl.txt | 174 - docs/types/test.ts | 606 --- examples/index.js | 37 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 192 - lib/main.js | 413 -- package.json | 90 +- stats.html | 2689 +++++++++++++ test/test.js | 4248 --------------------- 49 files changed, 2714 insertions(+), 10209 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.length.complex128.js delete mode 100644 benchmark/benchmark.length.complex64.js delete mode 100644 benchmark/benchmark.length.float32.js delete mode 100644 benchmark/benchmark.length.float64.js delete mode 100644 benchmark/benchmark.length.generic.js delete mode 100644 benchmark/benchmark.length.int16.js delete mode 100644 benchmark/benchmark.length.int32.js delete mode 100644 benchmark/benchmark.length.int8.js delete mode 100644 benchmark/benchmark.length.uint16.js delete mode 100644 benchmark/benchmark.length.uint32.js delete mode 100644 benchmark/benchmark.length.uint8.js delete mode 100644 benchmark/benchmark.length.uint8c.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 7212d81..0000000 --- a/.gitattributes +++ /dev/null @@ -1,33 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index e3a5d2e..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-08-01T01:50:45.128Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 8be0b82..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 29bf533..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index a7a7f51..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.9.0 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index df9d9d7..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 39b1613..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 7ca169c..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '0 8 * * 6' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "::set-output name=package_name::$name" - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "::set-output name=data::$data" - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v2 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v2 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 5094681..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,760 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "::set-output name=alias::${alias}" - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -273,7 +266,7 @@ for ( i = 0; i < dt.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 421b48e..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,319 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); -var isArray = require( '@stdlib/assert-is-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var pkg = require( './../package.json' ).name; -var filledarrayBy = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 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=float64', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'float64', 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=float32', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'float32', 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; - var i; - - clbk = constantFunction( new Complex128( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'complex128', 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=complex64', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( new Complex64( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'complex64', 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=int32', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int32', 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=uint32', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint32', 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=int16', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int16', 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=uint16', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint16', 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=int8', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int8', 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=uint8', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint8', 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=uint8c', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint8c', 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=generic', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'generic', clbk ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.length.complex128.js b/benchmark/benchmark.length.complex128.js deleted file mode 100644 index 671de86..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var Complex128 = require( '@stdlib/complex-float64' ); -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( new Complex128( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'complex128', 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=complex128,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.complex64.js b/benchmark/benchmark.length.complex64.js deleted file mode 100644 index 52da4e3..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var Complex64 = require( '@stdlib/complex-float32' ); -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( new Complex64( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'complex64', 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=complex64,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.float32.js b/benchmark/benchmark.length.float32.js deleted file mode 100644 index 9b4ef9b..0000000 --- a/benchmark/benchmark.length.float32.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'float32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=float32,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.float64.js b/benchmark/benchmark.length.float64.js deleted file mode 100644 index 66cb6b6..0000000 --- a/benchmark/benchmark.length.float64.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'float64', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=float64,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.generic.js b/benchmark/benchmark.length.generic.js deleted file mode 100644 index 5194c1b..0000000 --- a/benchmark/benchmark.length.generic.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isArray = require( '@stdlib/assert-is-array' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'generic', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isArray( 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=generic,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int16.js b/benchmark/benchmark.length.int16.js deleted file mode 100644 index 6669b28..0000000 --- a/benchmark/benchmark.length.int16.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int16', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=int16,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int32.js b/benchmark/benchmark.length.int32.js deleted file mode 100644 index e9c5c88..0000000 --- a/benchmark/benchmark.length.int32.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=int32,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int8.js b/benchmark/benchmark.length.int8.js deleted file mode 100644 index 14bbadf..0000000 --- a/benchmark/benchmark.length.int8.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int8', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=int8,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint16.js b/benchmark/benchmark.length.uint16.js deleted file mode 100644 index d03b23e..0000000 --- a/benchmark/benchmark.length.uint16.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint16', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint16,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint32.js b/benchmark/benchmark.length.uint32.js deleted file mode 100644 index 1382134..0000000 --- a/benchmark/benchmark.length.uint32.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint32,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint8.js b/benchmark/benchmark.length.uint8.js deleted file mode 100644 index c135d6c..0000000 --- a/benchmark/benchmark.length.uint8.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint8', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint8,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint8c.js b/benchmark/benchmark.length.uint8c.js deleted file mode 100644 index 2f7523a..0000000 --- a/benchmark/benchmark.length.uint8c.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint8c', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint8c,len='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 18101fd..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by" -click B href "https://github.com/stdlib-js/array-filled-by/tree/main" -click C href "https://github.com/stdlib-js/array-filled-by/tree/production" -click D href "https://github.com/stdlib-js/array-filled-by/tree/esm" -click E href "https://github.com/stdlib-js/array-filled-by/tree/deno" -click F href "https://github.com/stdlib-js/array-filled-by/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by -[production-url]: https://github.com/stdlib-js/array-filled-by/tree/production -[deno-url]: https://github.com/stdlib-js/array-filled-by/tree/deno -[umd-url]: https://github.com/stdlib-js/array-filled-by/tree/umd -[esm-url]: https://github.com/stdlib-js/array-filled-by/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 5a68984..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,174 +0,0 @@ - -{{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) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr = {{alias}}() - - > arr = {{alias}}( 'float32' ) - - - -{{alias}}( length[, dtype], clbk[, thisArg] ) - Returns a filled array according to a provided callback function and having - a specified length. - - Parameters - ---------- - length: integer - Array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > function clbk() { return 1.0; }; - > var arr = {{alias}}( 5, clbk ) - [ 1.0, 1.0, 1.0, 1.0, 1.0 ] - > arr = {{alias}}( 5, 'int32', clbk ) - [ 1, 1, 1, 1, 1 ] - - -{{alias}}( array[, dtype], clbk[, thisArg] ) - Creates a filled array from another array (or array-like object) according - to a provided callback function. - - Parameters - ---------- - array: ArrayLikeObject - Array from which to generate another array. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias}}( [ 0.5, 0.5, 0.5 ], {{alias:@stdlib/utils/constant-function}}( 2.0 ) ) - [ 2.0, 2.0, 2.0 ] - > var arr2 = {{alias}}( arr1, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( iterable[, dtype], clbk[, thisArg] ) - Creates a filled array from an iterable according to a provided callback - function. - - Parameters - ---------- - iterable: Iterable - Iterable from which to generate an array. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias:@stdlib/iter/constant}}( 3.0, {'iter': 3} ); - > var arr2 = {{alias}}( arr1, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( buffer[, byteOffset[, length]][, dtype], clbk[, thisArg] ) - Returns a filled typed array view of an ArrayBuffer according to a provided - callback function. - - The 'generic' array data type is *not* supported. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( buf, 0, 4, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0, 1.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 394ac49..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,606 +0,0 @@ -/* -* @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. -*/ - -/// - -import { IterableIterator } from '@stdlib/types/iter'; -import filledarrayBy = require( './index' ); - - -/** -* Returns an iterator protocol-compliant object. -* -* @returns iterator protocol-compliant object -*/ -function iterator(): IterableIterator { - const obj: IterableIterator = { - [Symbol.iterator]: iterator, - 'next': next - }; - return obj; -} - -/** -* Implements the iterator protocol `next` method. -* -* @returns iterator protocol-compliant object -*/ -function next(): any { - return { - 'value': 1.0, - 'done': false - }; -} - -/** -* Callback function. -* -* @param i - current array index -* @returns return value -*/ -function clbk( i: number ): number { - return i; -} - - -// TESTS // - -// The function returns an array or typed array... -{ - filledarrayBy(); // $ExpectType ArrayOrTypedArray - filledarrayBy( 'float32' ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( 10, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( 10, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( 10, 'int32', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( 10, 'int32', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const x = new Float64Array( 10 ); - filledarrayBy( x, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( x, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( x, 'uint8', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( x, 'uint8', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const y = [ 2.0, 2.0, 2.0 ]; - filledarrayBy( y, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( y, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( y, 'float64', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( y, 'float64', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const it = iterator(); - filledarrayBy( it, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( it, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( it, 'uint8c', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( it, 'uint8c', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const buf = new ArrayBuffer( 32 ); - filledarrayBy( buf, clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 'uint32', clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 'uint32', clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 8, clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 8, clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 8, 'uint16', clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 8, 'uint16', clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 8, 2, clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 8, 2, clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 8, 2, 'int16', clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 8, 2, 'int16', clbk, {} ); // $ExpectType RealOrComplexTypedArray -} - -// The compiler throws an error if a callback function argument is not a function... -{ - filledarrayBy( 'float64', '5' ); // $ExpectError - filledarrayBy( 'float64', 1.0 ); // $ExpectError - filledarrayBy( 'float64', false ); // $ExpectError - filledarrayBy( 'float64', true ); // $ExpectError - filledarrayBy( 'float64', null ); // $ExpectError - filledarrayBy( 'float64', undefined ); // $ExpectError - filledarrayBy( 'float64', [] ); // $ExpectError - filledarrayBy( 'float64', {} ); // $ExpectError - - filledarrayBy( 'float64', '5', {} ); // $ExpectError - filledarrayBy( 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( 'float64', false, {} ); // $ExpectError - filledarrayBy( 'float64', true, {} ); // $ExpectError - filledarrayBy( 'float64', null, {} ); // $ExpectError - filledarrayBy( 'float64', undefined, {} ); // $ExpectError - filledarrayBy( 'float64', [], {} ); // $ExpectError - filledarrayBy( 'float64', {}, {} ); // $ExpectError - - filledarrayBy( 10, '5' ); // $ExpectError - filledarrayBy( 10, 1.0 ); // $ExpectError - filledarrayBy( 10, false ); // $ExpectError - filledarrayBy( 10, true ); // $ExpectError - filledarrayBy( 10, null ); // $ExpectError - filledarrayBy( 10, undefined ); // $ExpectError - filledarrayBy( 10, [] ); // $ExpectError - filledarrayBy( 10, {} ); // $ExpectError - - filledarrayBy( 10, '5', {} ); // $ExpectError - filledarrayBy( 10, 1.0, {} ); // $ExpectError - filledarrayBy( 10, false, {} ); // $ExpectError - filledarrayBy( 10, true, {} ); // $ExpectError - filledarrayBy( 10, null, {} ); // $ExpectError - filledarrayBy( 10, undefined, {} ); // $ExpectError - filledarrayBy( 10, [], {} ); // $ExpectError - filledarrayBy( 10, {}, {} ); // $ExpectError - - filledarrayBy( 10, 'float64', '5' ); // $ExpectError - filledarrayBy( 10, 'float64', 1.0 ); // $ExpectError - filledarrayBy( 10, 'float64', false ); // $ExpectError - filledarrayBy( 10, 'float64', true ); // $ExpectError - filledarrayBy( 10, 'float64', null ); // $ExpectError - filledarrayBy( 10, 'float64', undefined ); // $ExpectError - filledarrayBy( 10, 'float64', [] ); // $ExpectError - filledarrayBy( 10, 'float64', {} ); // $ExpectError - - filledarrayBy( 10, 'float64', '5', {} ); // $ExpectError - filledarrayBy( 10, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( 10, 'float64', false, {} ); // $ExpectError - filledarrayBy( 10, 'float64', true, {} ); // $ExpectError - filledarrayBy( 10, 'float64', null, {} ); // $ExpectError - filledarrayBy( 10, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( 10, 'float64', [], {} ); // $ExpectError - filledarrayBy( 10, 'float64', {}, {} ); // $ExpectError - - const x = new Float64Array( 10 ); - filledarrayBy( x, '5' ); // $ExpectError - filledarrayBy( x, 1.0 ); // $ExpectError - filledarrayBy( x, false ); // $ExpectError - filledarrayBy( x, true ); // $ExpectError - filledarrayBy( x, null ); // $ExpectError - filledarrayBy( x, undefined ); // $ExpectError - filledarrayBy( x, [] ); // $ExpectError - filledarrayBy( x, {} ); // $ExpectError - - filledarrayBy( x, '5', {} ); // $ExpectError - filledarrayBy( x, 1.0, {} ); // $ExpectError - filledarrayBy( x, false, {} ); // $ExpectError - filledarrayBy( x, true, {} ); // $ExpectError - filledarrayBy( x, null, {} ); // $ExpectError - filledarrayBy( x, undefined, {} ); // $ExpectError - filledarrayBy( x, [], {} ); // $ExpectError - filledarrayBy( x, {}, {} ); // $ExpectError - - filledarrayBy( x, 'float64', '5' ); // $ExpectError - filledarrayBy( x, 'float64', 1.0 ); // $ExpectError - filledarrayBy( x, 'float64', false ); // $ExpectError - filledarrayBy( x, 'float64', true ); // $ExpectError - filledarrayBy( x, 'float64', null ); // $ExpectError - filledarrayBy( x, 'float64', undefined ); // $ExpectError - filledarrayBy( x, 'float64', [] ); // $ExpectError - filledarrayBy( x, 'float64', {} ); // $ExpectError - - filledarrayBy( x, 'float64', '5', {} ); // $ExpectError - filledarrayBy( x, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( x, 'float64', false, {} ); // $ExpectError - filledarrayBy( x, 'float64', true, {} ); // $ExpectError - filledarrayBy( x, 'float64', null, {} ); // $ExpectError - filledarrayBy( x, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( x, 'float64', [], {} ); // $ExpectError - filledarrayBy( x, 'float64', {}, {} ); // $ExpectError - - const y = [ 2.0, 2.0, 2.0 ]; - filledarrayBy( y, '5' ); // $ExpectError - filledarrayBy( y, 1.0 ); // $ExpectError - filledarrayBy( y, false ); // $ExpectError - filledarrayBy( y, true ); // $ExpectError - filledarrayBy( y, null ); // $ExpectError - filledarrayBy( y, undefined ); // $ExpectError - filledarrayBy( y, [] ); // $ExpectError - filledarrayBy( y, {} ); // $ExpectError - - filledarrayBy( y, '5', {} ); // $ExpectError - filledarrayBy( y, 1.0, {} ); // $ExpectError - filledarrayBy( y, false, {} ); // $ExpectError - filledarrayBy( y, true, {} ); // $ExpectError - filledarrayBy( y, null, {} ); // $ExpectError - filledarrayBy( y, undefined, {} ); // $ExpectError - filledarrayBy( y, [], {} ); // $ExpectError - filledarrayBy( y, {}, {} ); // $ExpectError - - filledarrayBy( y, 'float64', '5' ); // $ExpectError - filledarrayBy( y, 'float64', 1.0 ); // $ExpectError - filledarrayBy( y, 'float64', false ); // $ExpectError - filledarrayBy( y, 'float64', true ); // $ExpectError - filledarrayBy( y, 'float64', null ); // $ExpectError - filledarrayBy( y, 'float64', undefined ); // $ExpectError - filledarrayBy( y, 'float64', [] ); // $ExpectError - filledarrayBy( y, 'float64', {} ); // $ExpectError - - filledarrayBy( y, 'float64', '5', {} ); // $ExpectError - filledarrayBy( y, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( y, 'float64', false, {} ); // $ExpectError - filledarrayBy( y, 'float64', true, {} ); // $ExpectError - filledarrayBy( y, 'float64', null, {} ); // $ExpectError - filledarrayBy( y, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( y, 'float64', [], {} ); // $ExpectError - filledarrayBy( y, 'float64', {}, {} ); // $ExpectError - - const it = iterator(); - filledarrayBy( it, '5' ); // $ExpectError - filledarrayBy( it, 1.0 ); // $ExpectError - filledarrayBy( it, false ); // $ExpectError - filledarrayBy( it, true ); // $ExpectError - filledarrayBy( it, null ); // $ExpectError - filledarrayBy( it, undefined ); // $ExpectError - filledarrayBy( it, [] ); // $ExpectError - filledarrayBy( it, {} ); // $ExpectError - - filledarrayBy( it, '5', {} ); // $ExpectError - filledarrayBy( it, 1.0, {} ); // $ExpectError - filledarrayBy( it, false, {} ); // $ExpectError - filledarrayBy( it, true, {} ); // $ExpectError - filledarrayBy( it, null, {} ); // $ExpectError - filledarrayBy( it, undefined, {} ); // $ExpectError - filledarrayBy( it, [], {} ); // $ExpectError - filledarrayBy( it, {}, {} ); // $ExpectError - - filledarrayBy( it, 'float64', '5' ); // $ExpectError - filledarrayBy( it, 'float64', 1.0 ); // $ExpectError - filledarrayBy( it, 'float64', false ); // $ExpectError - filledarrayBy( it, 'float64', true ); // $ExpectError - filledarrayBy( it, 'float64', null ); // $ExpectError - filledarrayBy( it, 'float64', undefined ); // $ExpectError - filledarrayBy( it, 'float64', [] ); // $ExpectError - filledarrayBy( it, 'float64', {} ); // $ExpectError - - filledarrayBy( it, 'float64', '5', {} ); // $ExpectError - filledarrayBy( it, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( it, 'float64', false, {} ); // $ExpectError - filledarrayBy( it, 'float64', true, {} ); // $ExpectError - filledarrayBy( it, 'float64', null, {} ); // $ExpectError - filledarrayBy( it, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( it, 'float64', [], {} ); // $ExpectError - filledarrayBy( it, 'float64', {}, {} ); // $ExpectError - - const buf = new ArrayBuffer( 32 ); - filledarrayBy( buf, '5' ); // $ExpectError - filledarrayBy( buf, 1.0 ); // $ExpectError - filledarrayBy( buf, false ); // $ExpectError - filledarrayBy( buf, true ); // $ExpectError - filledarrayBy( buf, null ); // $ExpectError - filledarrayBy( buf, undefined ); // $ExpectError - filledarrayBy( buf, [] ); // $ExpectError - filledarrayBy( buf, {} ); // $ExpectError - - filledarrayBy( buf, '5', {} ); // $ExpectError - filledarrayBy( buf, 1.0, {} ); // $ExpectError - filledarrayBy( buf, false, {} ); // $ExpectError - filledarrayBy( buf, true, {} ); // $ExpectError - filledarrayBy( buf, null, {} ); // $ExpectError - filledarrayBy( buf, undefined, {} ); // $ExpectError - filledarrayBy( buf, [], {} ); // $ExpectError - filledarrayBy( buf, {}, {} ); // $ExpectError - - filledarrayBy( buf, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 'float64', false ); // $ExpectError - filledarrayBy( buf, 'float64', true ); // $ExpectError - filledarrayBy( buf, 'float64', null ); // $ExpectError - filledarrayBy( buf, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 'float64', {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5' ); // $ExpectError - filledarrayBy( buf, 8, 1.0 ); // $ExpectError - filledarrayBy( buf, 8, false ); // $ExpectError - filledarrayBy( buf, 8, true ); // $ExpectError - filledarrayBy( buf, 8, null ); // $ExpectError - filledarrayBy( buf, 8, undefined ); // $ExpectError - filledarrayBy( buf, 8, [] ); // $ExpectError - filledarrayBy( buf, 8, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, false, {} ); // $ExpectError - filledarrayBy( buf, 8, true, {} ); // $ExpectError - filledarrayBy( buf, 8, null, {} ); // $ExpectError - filledarrayBy( buf, 8, undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, [], {} ); // $ExpectError - filledarrayBy( buf, 8, {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 8, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 'float64', false ); // $ExpectError - filledarrayBy( buf, 8, 'float64', true ); // $ExpectError - filledarrayBy( buf, 8, 'float64', null ); // $ExpectError - filledarrayBy( buf, 8, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 8, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 8, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 8, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, '5' ); // $ExpectError - filledarrayBy( buf, 8, 2, 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 2, false ); // $ExpectError - filledarrayBy( buf, 8, 2, true ); // $ExpectError - filledarrayBy( buf, 8, 2, null ); // $ExpectError - filledarrayBy( buf, 8, 2, undefined ); // $ExpectError - filledarrayBy( buf, 8, 2, [] ); // $ExpectError - filledarrayBy( buf, 8, 2, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, false, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, true, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, null, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, [], {} ); // $ExpectError - filledarrayBy( buf, 8, 2, {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', false ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', true ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', null ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', {}, {} ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid length, typed array, array-like object, `ArrayBuffer`, or iterable argument... -{ - filledarrayBy( false, clbk ); // $ExpectError - filledarrayBy( true, clbk ); // $ExpectError - filledarrayBy( null, clbk ); // $ExpectError - filledarrayBy( {}, clbk ); // $ExpectError - - filledarrayBy( false, clbk, {} ); // $ExpectError - filledarrayBy( true, clbk, {} ); // $ExpectError - filledarrayBy( null, clbk, {} ); // $ExpectError - filledarrayBy( {}, clbk, {} ); // $ExpectError - - filledarrayBy( false, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 'float64', clbk ); // $ExpectError - - filledarrayBy( false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, clbk ); // $ExpectError - filledarrayBy( 1.0, 8, clbk ); // $ExpectError - filledarrayBy( false, 8, clbk ); // $ExpectError - filledarrayBy( true, 8, clbk ); // $ExpectError - filledarrayBy( null, 8, clbk ); // $ExpectError - filledarrayBy( undefined, 8, clbk ); // $ExpectError - filledarrayBy( [], 8, clbk ); // $ExpectError - filledarrayBy( {}, 8, clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, clbk ); // $ExpectError - - filledarrayBy( '5', 8, clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, clbk, {} ); // $ExpectError - filledarrayBy( false, 8, clbk, {} ); // $ExpectError - filledarrayBy( true, 8, clbk, {} ); // $ExpectError - filledarrayBy( null, 8, clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, clbk, {} ); // $ExpectError - filledarrayBy( [], 8, clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 'float64', clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( false, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( [], 8, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 'float64', clbk ); // $ExpectError - - filledarrayBy( '5', 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 2, clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 2, clbk ); // $ExpectError - filledarrayBy( false, 8, 2, clbk ); // $ExpectError - filledarrayBy( true, 8, 2, clbk ); // $ExpectError - filledarrayBy( null, 8, 2, clbk ); // $ExpectError - filledarrayBy( undefined, 8, 2, clbk ); // $ExpectError - filledarrayBy( [], 8, 2, clbk ); // $ExpectError - filledarrayBy( {}, 8, 2, clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, clbk ); // $ExpectError - - filledarrayBy( '5', 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( false, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( [], 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, 'float64', clbk ); // $ExpectError - - filledarrayBy( '5', 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a byte offset argument which is not a number... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, false, clbk ); // $ExpectError - filledarrayBy( buf, true, clbk ); // $ExpectError - filledarrayBy( buf, null, clbk ); // $ExpectError - filledarrayBy( buf, [], clbk ); // $ExpectError - filledarrayBy( buf, {}, clbk ); // $ExpectError - - filledarrayBy( buf, false, clbk, {} ); // $ExpectError - filledarrayBy( buf, true, clbk, {} ); // $ExpectError - filledarrayBy( buf, null, clbk, {} ); // $ExpectError - filledarrayBy( buf, [], clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, clbk, {} ); // $ExpectError - - filledarrayBy( buf, '5', 'float64', clbk ); // $ExpectError - filledarrayBy( buf, false, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, true, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, null, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, [], 'float64', clbk ); // $ExpectError - filledarrayBy( buf, {}, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, '5', 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( buf, false, 2, clbk ); // $ExpectError - filledarrayBy( buf, true, 2, clbk ); // $ExpectError - filledarrayBy( buf, null, 2, clbk ); // $ExpectError - filledarrayBy( buf, [], 2, clbk ); // $ExpectError - filledarrayBy( buf, {}, 2, clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, clbk ); // $ExpectError - - filledarrayBy( buf, false, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, clbk, {} ); // $ExpectError - - filledarrayBy( buf, '5', 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, false, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, true, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, null, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, undefined, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, [], 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, {}, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, '5', 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, false, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, undefined, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a view length argument which is not a number... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, 8, false, clbk ); // $ExpectError - filledarrayBy( buf, 8, true, clbk ); // $ExpectError - filledarrayBy( buf, 8, null, clbk ); // $ExpectError - filledarrayBy( buf, 8, [], clbk ); // $ExpectError - filledarrayBy( buf, 8, {}, clbk ); // $ExpectError - - filledarrayBy( buf, 8, false, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, true, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, null, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, [], clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, {}, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, clbk, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5', 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, false, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, true, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, null, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, [], 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, {}, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, 8, '5', 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, [], 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, {}, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided too many arguments... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, 8, 2, 'float64', 1, clbk, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 997a381..0000000 --- a/examples/index.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ).factory; -var dtypes = require( '@stdlib/array-typed-real-dtypes' ); -var filledarrayBy = require( './../lib' ); - -// Create a pseudorandom number generator: -var rand = discreteUniform( 0, 100 ); - -// Get a list of array data types: -var dt = dtypes(); - -// Generate filled arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = filledarrayBy( 10, dt[ i ], rand ); - console.log( arr ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 3fc2784..2156674 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { RealOrComplexTypedArray, DataType } from '@stdlib/types/array'; import { Collection } from '@stdlib/types/object'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..183311e --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-ctors@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill-by@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled-by@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";var w=d();function j(r,e,t){var s,i;for(s=[],i=-1;!r.next().done;)i+=1,s.push(e.call(t,i));return s}function a(r,e,t){var s;for(s=0;s1)throw new TypeError(p("00L05"));if(null===(b=o(g)))throw new TypeError(p("00L2k",g));return new b(0)}if(c<2)throw new TypeError(p("00L05"));if(n(arguments[c-=1]))if(n(arguments[c-1])){if(d=arguments[c],y=arguments[c-=1],0===c)throw new TypeError(p("00L05"))}else y=arguments[c];else{if(!(c>=2))throw new TypeError(p("00L05"));if(d=arguments[c],!n(y=arguments[c-=1]))throw new TypeError(p("00L2n",y))}if((c-=1)>=0&&r(arguments[c])?(g=arguments[c],c-=1):g="float64",null===(b=o(g)))throw new TypeError(p("00L2k",g));if("generic"===g){if(x=arguments[0],0===c){if(e(x)?u=x:t(x)&&(u=x.length),void 0!==u)return m(u,y,d);if(s(x))throw new Error(p("00L04"));if(i(x)){if(!1===w)throw new TypeError(p("00L2l",x));if(!n(x[f]))throw new TypeError(p("00L2m",x));if(x=x[f](),!n(x.next))throw new TypeError(p("00L2m",x));return j(x,y,d)}throw new TypeError(p("00L2m",x))}if(s(x))throw new Error(p("00L04"));throw new TypeError(p("00L2m",x))}if(0===c)if(t(x=arguments[0]))v=new b(x.length);else if(s(x))v=new b(x);else if(e(x))v=new b(x);else{if(!i(x))throw new TypeError(p("00L2m",x));if(!1===w)throw new TypeError(p("00L2l",x));if(!n(x[f]))throw new TypeError(p("00L2m",x));if(x=x[f](),!n(x.next))throw new TypeError(p("00L2m",x));v=new b(h(x))}else v=1===c?new b(arguments[0],arguments[1]):new b(arguments[0],arguments[1],arguments[2]);return v.length>0&&(/^complex/.test(g)?a(v,y,d):l(v.length,v,1,E)),v;function E(r,e){return y.call(d,e)}}export{c as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..12cc856 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.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\nimport { isPrimitive as isString } from '@stdlib/assert-is-string' ;\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer' ;\nimport isCollection from '@stdlib/assert-is-collection' ;\nimport isArrayBuffer from '@stdlib/assert-is-arraybuffer' ;\nimport isObject from '@stdlib/assert-is-object' ;\nimport isFunction from '@stdlib/assert-is-function' ;\nimport ctors from '@stdlib/array-ctors' ;\nimport gfillBy from '@stdlib/blas-ext-base-gfill-by' ;\nimport filledArray from '@stdlib/array-base-filled-by' ;\nimport hasIteratorSymbolSupport from '@stdlib/assert-has-iterator-symbol-support' ;\nimport ITERATOR_SYMBOL from '@stdlib/symbol-iterator' ;\nimport iterLength from '@stdlib/iter-length' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\n\n\n// VARIABLES //\n\nvar HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport();\nvar DEFAULT_DTYPE = 'float64';\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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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( format( '00L05' ) );\n\t\t}\n\t\tctor = ctors( dtype );\n\t\tif ( ctor === null ) {\n\t\t\tthrow new TypeError( format( '00L2k', 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( format( '00L05' ) );\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( format( '00L05' ) );\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( '00L2n', 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( format( '00L05' ) );\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( '00L2k', 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( format( '00L04' ) );\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( '00L2l', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00L2m', 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( '00L2m', 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( '00L2m', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format( '00L04' ) );\n\t\t}\n\t\tthrow new TypeError( format( '00L2m', 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( '00L2l', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00L2m', 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( '00L2m', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00L2m', 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\nexport default filledarrayBy;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","filledArrayIterator","it","clbk","thisArg","arr","i","next","done","push","call","filledAccessors","length","set","filledarrayBy","nargs","dtype","ctor","len","arg","arguments","ctors","isString","TypeError","format","isFunction","isNonNegativeInteger","isCollection","filledArray","isArrayBuffer","Error","isObject","ITERATOR_SYMBOL","iterLength","test","gfillBy","callback","value","aidx"],"mappings":";;wpCAuCA,IAAIA,EAAsBC,IAe1B,SAASC,EAAqBC,EAAIC,EAAMC,GACvC,IAAIC,EACAC,EAKJ,IAFAD,EAAM,GACNC,GAAK,GAEAJ,EAAGK,OACAC,MAGPF,GAAK,EACLD,EAAII,KAAMN,EAAKO,KAAMN,EAASE,IAE/B,OAAOD,EAYR,SAASM,EAAiBN,EAAKF,EAAMC,GACpC,IAAIE,EACJ,IAAMA,EAAI,EAAGA,EAAID,EAAIO,OAAQN,IAC5BD,EAAIQ,IAAKV,EAAKO,KAAMN,EAASE,GAAKA,GAEnC,OAAOD,EA6JR,SAASS,IACR,IAAIV,EACAW,EACAC,EACAb,EACAc,EACAZ,EACAa,EACAC,EAKJ,GAAe,KAHfJ,EAAQK,UAAUR,QAKjB,OAAO,IADPK,EAAOI,EAzNW,YA0ND,GAIlB,GAAKC,EADLN,EAAQI,UAAW,IACM,CAExB,GAAKL,EAAQ,EACZ,MAAM,IAAIQ,UAAWC,EAAQ,UAG9B,GAAc,QADdP,EAAOI,EAAOL,IAEb,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAGvC,OAAO,IAAIC,EAAM,GAGlB,GAAKF,EAAQ,EACZ,MAAM,IAAIQ,UAAWC,EAAQ,UAM9B,GAAKC,EAAYL,UAHjBL,GAAS,IAKR,GAAKU,EAAYL,UAAWL,EAAM,KAMjC,GALAX,EAAUgB,UAAWL,GAErBZ,EAAOiB,UADPL,GAAS,GAIM,IAAVA,EACJ,MAAM,IAAIQ,UAAWC,EAAQ,eAI9BrB,EAAOiB,UAAWL,OAIf,MAAKA,GAAS,GAUlB,MAAM,IAAIQ,UAAWC,EAAQ,UAN7B,GAHApB,EAAUgB,UAAWL,IAGfU,EADNtB,EAAOiB,UADPL,GAAS,IAGR,MAAM,IAAIQ,UAAWC,EAAQ,QAASrB,IAgBxC,IARAY,GAAS,IACK,GAAKO,EAAUF,UAAWL,KACvCC,EAAQI,UAAWL,GACnBA,GAAS,GAETC,EArRkB,UAwRL,QADdC,EAAOI,EAAOL,IAEb,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAGvC,GAAe,YAAVA,EAAsB,CAE1B,GADAG,EAAMC,UAAW,GACF,IAAVL,EAAc,CAMlB,GALKW,EAAsBP,GAC1BD,EAAMC,EACKQ,EAAcR,KACzBD,EAAMC,EAAIP,aAEE,IAARM,EACJ,OAAOU,EAAaV,EAAKf,EAAMC,GAEhC,GAAKyB,EAAeV,GACnB,MAAM,IAAIW,MAAON,EAAQ,UAE1B,GAAKO,EAAUZ,GAAQ,CACtB,IAA6B,IAAxBpB,EACJ,MAAM,IAAIwB,UAAWC,EAAQ,QAASL,IAEvC,IAAMM,EAAYN,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASL,IAGvC,GADAA,EAAMA,EAAKa,MACLP,EAAYN,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,QAASL,IAEvC,OAAOlB,EAAqBkB,EAAKhB,EAAMC,GAExC,MAAM,IAAImB,UAAWC,EAAQ,QAASL,IAChC,GAAKU,EAAeV,GAC1B,MAAM,IAAIW,MAAON,EAAQ,UAE1B,MAAM,IAAID,UAAWC,EAAQ,QAASL,IAEvC,GAAe,IAAVJ,EAEJ,GAAKY,EADLR,EAAMC,UAAW,IAEhBf,EAAM,IAAIY,EAAME,EAAIP,aACd,GAAKiB,EAAeV,GAC1Bd,EAAM,IAAIY,EAAME,QACV,GAAKO,EAAsBP,GACjCd,EAAM,IAAIY,EAAME,OACV,KAAKY,EAAUZ,GAarB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAZtC,IAA6B,IAAxBpB,EACJ,MAAM,IAAIwB,UAAWC,EAAQ,QAASL,IAEvC,IAAMM,EAAYN,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASL,IAGvC,GADAA,EAAMA,EAAKa,MACLP,EAAYN,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,QAASL,IAEvCd,EAAM,IAAIY,EAAMgB,EAAYd,SAK7Bd,EADqB,IAAVU,EACL,IAAIE,EAAMG,UAAU,GAAIA,UAAU,IAElC,IAAIH,EAAMG,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKf,EAAIO,OAAS,IACZ,WAAWsB,KAAMlB,GACrBL,EAAiBN,EAAKF,EAAMC,GAE5B+B,EAAS9B,EAAIO,OAAQP,EAAK,EAAG+B,IAGxB/B,EAYP,SAAS+B,EAAUC,EAAOC,GACzB,OAAOnC,EAAKO,KAAMN,EAASkC"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d115cf0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,192 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -/** -* Create a filled array according to a provided callback function. -* -* @module @stdlib/array-filled-by -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* var arr = filledarrayBy(); -* // returns -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'generic', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( [ 0.5, 0.5 ], clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1; -* } -* -* var arr = filledarrayBy( [ 5, -3 ], 'int32', clbk ); -* // returns [ 1, 1 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk1() { -* return 10; -* } -* -* function clbk2() { -* return 1.0; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, clbk2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk1() { -* return 1.0; -* } -* -* function clbk2() { -* return 2; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, 'uint32', clbk2 ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 'float32', clbk ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, clbk ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, 'int32', clbk ); -* // returns [ 1, 1 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index d6fbe5e..0000000 --- a/lib/main.js +++ /dev/null @@ -1,413 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var isCollection = require( '@stdlib/assert-is-collection' ); -var isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isObject = require( '@stdlib/assert-is-object' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var ctors = require( '@stdlib/array-ctors' ); -var gfillBy = require( '@stdlib/blas-ext-base-gfill-by' ); -var filledArray = require( '@stdlib/array-base-filled-by' ); -var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var iterLength = require( '@stdlib/iter-length' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport(); -var DEFAULT_DTYPE = 'float64'; - - -// FUNCTIONS // - -/** -* Creates a filled "generic" array from an iterator. -* -* @private -* @param {Iterable} it - iterator -* @param {Callback} clbk - callback function -* @param {*} thisArg - callback function execution context -* @returns {Array} filled array -*/ -function filledArrayIterator( it, clbk, thisArg ) { - var arr; - var i; - var v; - - arr = []; - i = -1; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - i += 1; - arr.push( clbk.call( thisArg, i ) ); - } - return arr; -} - -/** -* Fills an array exposing accessors for getting and setting array elements. -* -* @private -* @param {Collection} arr - input array -* @param {Callback} clbk - callback function -* @param {*} thisArg - callback function execution context -* @returns {Collection} input array -*/ -function filledAccessors( arr, clbk, thisArg ) { - var i; - for ( i = 0; i < arr.length; i++ ) { - arr.set( clbk.call( thisArg, i ), i ); - } - return arr; -} - - -// MAIN // - -/** -* Creates a filled array according to a provided callback function. -* -* @param {(NonNegativeInteger|TypedArray|ArrayLikeObject|ArrayBuffer|Iterable)} [arg] - a length, typed array, array-like object, buffer, or iterable -* @param {NonNegativeInteger} [byteOffset=0] - byte offset -* @param {NonNegativeInteger} [length] - view length -* @param {string} [dtype="float64"] - data type -* @param {Callback} [clbk] - callback to invoke -* @param {*} [thisArg] - callback execution context -* @throws {TypeError} must provide a recognized data type -* @throws {TypeError} must provide a length, typed array, array-like object, buffer, or iterable -* @throws {TypeError} callback argument must be a function. -* @throws {Error} creating a generic array from an `ArrayBuffer` is not supported -* @returns {(TypedArray|Array)} array or typed array -* -* @example -* var arr = filledarrayBy(); -* // returns -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'generic', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( [ 0.5, 0.5 ], clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1; -* } -* -* var arr = filledarrayBy( [ 5, -3 ], 'int32', clbk ); -* // returns [ 1, 1 ] -* -* @example -* function clbk1() { -* return 10; -* } -* -* function clbk2() { -* return 1.0; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, clbk2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk1() { -* return 1.0; -* } -* -* function clbk2() { -* return 2; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, 'uint32', clbk2 ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 'float32', clbk ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, clbk ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, 'int32', clbk ); -* // returns [ 1, 1 ] -*/ -function filledarrayBy() { - var thisArg; - var nargs; - var dtype; - var clbk; - var ctor; - var arr; - var len; - var arg; - - nargs = arguments.length; - - // If we weren't provided any arguments, return an empty array... - if ( nargs === 0 ) { - ctor = ctors( DEFAULT_DTYPE ); - return new ctor( 0 ); - } - // Check if we were provided a dtype as the first argument... - dtype = arguments[ 0 ]; - if ( isString( dtype ) ) { - // Invoking this function with arguments `f( dtype, clbk[, thisArg] )` is not allowed (otherwise, we'd need to also allow `f( clbk[, thisArg] )`)... - if ( nargs > 1 ) { - throw new TypeError( format( '00L05' ) ); - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '00L2k', dtype ) ); - } - // Return an empty array having the specified dtype: - return new ctor( 0 ); - } - // For all other supported invocations, we need at least two arguments... - if ( nargs < 2 ) { - throw new TypeError( format( '00L05' ) ); - } - // At this point, we need to do some argument juggling... - nargs -= 1; // henceforth, the number of available arguments is `nargs+1` - - // Determine whether the last argument is a callback or "this" context... - if ( isFunction( arguments[ nargs ] ) ) { - // 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... - if ( isFunction( arguments[ nargs-1 ] ) ) { - thisArg = arguments[ nargs ]; - nargs -= 1; - clbk = arguments[ nargs ]; - - // Check if we were provided only a callback and a "this" context.. - if ( nargs === 0 ) { - throw new TypeError( format( '00L05' ) ); - } - } else { - // "this" context is left undefined... - clbk = arguments[ nargs ]; - } - } - // 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... - else if ( nargs >= 2 ) { - thisArg = arguments[ nargs ]; - nargs -= 1; - clbk = arguments[ nargs ]; - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '00L2n', clbk ) ); - } - } - // If were were only provided 2 arguments and the last argument was not a function, we've been provided an insufficient number of arguments... - else { - throw new TypeError( format( '00L05' ) ); - } - // Now that we've processed the callback arguments, let's continue working backward to see if we've been provided a `dtype` argument... - nargs -= 1; - if ( nargs >= 0 && isString( arguments[ nargs ] ) ) { - dtype = arguments[ nargs ]; - nargs -= 1; - } else { - dtype = DEFAULT_DTYPE; - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '00L2k', dtype ) ); - } - // At this point, we've resolved the output array data type, and now we can actually create the output array... - if ( dtype === 'generic' ) { - arg = arguments[ 0 ]; - if ( nargs === 0 ) { - if ( isNonNegativeInteger( arg ) ) { - len = arg; - } else if ( isCollection( arg ) ) { - len = arg.length; - } - if ( len !== void 0 ) { - return filledArray( len, clbk, thisArg ); - } - if ( isArrayBuffer( arg ) ) { - throw new Error( format( '00L04' ) ); - } - if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( '00L2l', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00L2m', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00L2m', arg ) ); - } - return filledArrayIterator( arg, clbk, thisArg ); - } - throw new TypeError( format( '00L2m', arg ) ); - } else if ( isArrayBuffer( arg ) ) { - throw new Error( format( '00L04' ) ); - } - throw new TypeError( format( '00L2m', arg ) ); - } - if ( nargs === 0 ) { // length || array-like || ArrayBuffer || iterable - arg = arguments[ 0 ]; - if ( isCollection( arg ) ) { - arr = new ctor( arg.length ); - } else if ( isArrayBuffer( arg ) ) { - arr = new ctor( arg ); - } else if ( isNonNegativeInteger( arg ) ) { - arr = new ctor( arg ); - } else if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( '00L2l', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00L2m', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00L2m', arg ) ); - } - arr = new ctor( iterLength( arg ) ); - } else { - throw new TypeError( format( '00L2m', arg ) ); - } - } else if ( nargs === 1 ) { - arr = new ctor( arguments[0], arguments[1] ); // (ArrayBuffer, byteOffset) - } else { - arr = new ctor( arguments[0], arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset, length) - } - if ( arr.length > 0 ) { - if ( /^complex/.test( dtype ) ) { - filledAccessors( arr, clbk, thisArg ); - } else { - gfillBy( arr.length, arr, 1, callback ); - } - } - return arr; - - /** - * Callback which wraps a provided callback and is invoked for each array element. - * - * @private - * @param {*} value - element value - * @param {NonNegativeInteger} aidx - array index - * @param {NonNegativeInteger} sidx - strided index - * @param {Collection} array - input array/collection - * @returns {*} callback return value - */ - function callback( value, aidx ) { - return clbk.call( thisArg, aidx ); - } -} - - -// EXPORTS // - -module.exports = filledarrayBy; diff --git a/package.json b/package.json index 6511a88..498622b 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.2", "description": "Create a filled array according to a provided callback function.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,69 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-filled-by": "^0.0.x", - "@stdlib/array-ctors": "^0.0.x", - "@stdlib/assert-has-iterator-symbol-support": "^0.0.x", - "@stdlib/assert-is-arraybuffer": "^0.0.x", - "@stdlib/assert-is-collection": "^0.0.x", - "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/assert-is-nonnegative-integer": "^0.0.x", - "@stdlib/assert-is-object": "^0.0.x", - "@stdlib/assert-is-string": "^0.0.x", - "@stdlib/blas-ext-base-gfill-by": "^0.0.x", - "@stdlib/iter-length": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x", - "@stdlib/symbol-iterator": "^0.0.x", - "@stdlib/types": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-buffer": "^0.0.x", - "@stdlib/array-complex128": "^0.0.x", - "@stdlib/array-complex64": "^0.0.x", - "@stdlib/array-float32": "^0.0.x", - "@stdlib/array-float64": "^0.0.x", - "@stdlib/array-int16": "^0.0.x", - "@stdlib/array-int32": "^0.0.x", - "@stdlib/array-int8": "^0.0.x", - "@stdlib/array-typed-real-dtypes": "^0.0.x", - "@stdlib/array-uint16": "^0.0.x", - "@stdlib/array-uint32": "^0.0.x", - "@stdlib/array-uint8": "^0.0.x", - "@stdlib/array-uint8c": "^0.0.x", - "@stdlib/assert-instance-of": "^0.0.x", - "@stdlib/assert-is-array": "^0.0.x", - "@stdlib/assert-is-typed-array": "^0.0.x", - "@stdlib/assert-is-typed-array-like": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/complex-float32": "^0.0.x", - "@stdlib/complex-float64": "^0.0.x", - "@stdlib/iter-constant": "^0.0.x", - "@stdlib/math-base-special-pow": "^0.0.x", - "@stdlib/random-base-discrete-uniform": "^0.0.x", - "@stdlib/strided-base-reinterpret-complex128": "^0.0.x", - "@stdlib/strided-base-reinterpret-complex64": "^0.0.x", - "@stdlib/utils-constant-function": "^0.0.x", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..25b0e33 --- /dev/null +++ b/stats.html @@ -0,0 +1,2689 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index b55aa4a..0000000 --- a/test/test.js +++ /dev/null @@ -1,4248 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 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. -*/ - -/* eslint-disable max-len */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -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 ArrayBuffer = require( '@stdlib/array-buffer' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var iterConstant = require( '@stdlib/iter-constant' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var filledarrayBy = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': !hasIteratorSymbolSupport() -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof filledarrayBy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if only provided callback arguments', function test( t ) { - t.throws( clbk1, TypeError, 'throws an error' ); - t.throws( clbk2, TypeError, 'throws an error' ); - t.throws( clbk3, TypeError, 'throws an error' ); - t.end(); - - function clbk1() { - filledarrayBy( constantFunction( 1.0 ) ); - } - - function clbk2() { - filledarrayBy( constantFunction( 1.0 ), {} ); - } - - function clbk3() { - filledarrayBy( constantFunction( 1.0 ), constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (only argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (typed array; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (array-like object)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (array-like object; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 8 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 8 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, 1, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (iterator)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( iterConstant( 1.0 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (iterator; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( iterConstant( 1.0 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if only provided data type and callback arguments', function test( t ) { - t.throws( clbk1, TypeError, 'throws an error' ); - t.throws( clbk2, TypeError, 'throws an error' ); - t.throws( clbk3, TypeError, 'throws an error' ); - t.end(); - - function clbk1() { - filledarrayBy( 'float64', constantFunction( 1.0 ) ); - } - - function clbk2() { - filledarrayBy( 'float64', constantFunction( 1.0 ), {} ); - } - - function clbk3() { - filledarrayBy( 'float64', constantFunction( 1.0 ), constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (array-like object)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (array-like object; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, 1, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, 1, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (no iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (no iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (non-function iterator symbol property)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (non-function iterator symbol property; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (`next` property is not a function)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ) ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (`next` property is not a function; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ), {} ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (no iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (no iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (non-function iterator symbol property)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (non-function iterator symbol property; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (`next` property is not a function)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ) ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (`next` property is not a function; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ), {} ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 1, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 1, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function returns a filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - arr = filledarrayBy(); - - t.strictEqual( instanceOf( arr, Float64Array ), 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=float64)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - arr = filledarrayBy( 'float64' ); - - t.strictEqual( instanceOf( arr, Float64Array ), 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=float32)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( 0 ); - arr = filledarrayBy( 'float32' ); - - t.strictEqual( instanceOf( arr, Float32Array ), 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; - - expected = new Complex128Array( 0 ); - arr = filledarrayBy( 'complex128' ); - - t.strictEqual( instanceOf( arr, Complex128Array ), 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=complex64)', function test( t ) { - var expected; - var arr; - - expected = new Complex64Array( 0 ); - arr = filledarrayBy( 'complex64' ); - - t.strictEqual( instanceOf( arr, Complex64Array ), 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=int32)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( 0 ); - arr = filledarrayBy( 'int32' ); - - t.strictEqual( instanceOf( arr, Int32Array ), 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=uint32)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( 0 ); - arr = filledarrayBy( 'uint32' ); - - t.strictEqual( instanceOf( arr, Uint32Array ), 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=int16)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( 0 ); - arr = filledarrayBy( 'int16' ); - - t.strictEqual( instanceOf( arr, Int16Array ), 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=uint16)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( 0 ); - arr = filledarrayBy( 'uint16' ); - - t.strictEqual( instanceOf( arr, Uint16Array ), 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=int8)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( 0 ); - arr = filledarrayBy( 'int8' ); - - t.strictEqual( instanceOf( arr, Int8Array ), 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=uint8)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( 0 ); - arr = filledarrayBy( 'uint8' ); - - t.strictEqual( instanceOf( arr, Uint8Array ), 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=uint8c)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( 0 ); - arr = filledarrayBy( 'uint8c' ); - - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), 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=generic)', function test( t ) { - var expected; - var arr; - - expected = []; - arr = filledarrayBy( 'generic' ); - - t.strictEqual( instanceOf( arr, Array ), 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 (default, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, length=0)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array(); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 0, clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, clbk, ctx ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (default, length; thisArg=function)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, clbk, context ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this(); // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } - - function context() { - ctx.count += 1; - } -}); - -tape( 'the function returns a filled array (dtype=float64, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, 'float64', clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, length; thisArg=function)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, 'float64', clbk, context ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this(); // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } - - function context() { - ctx.count += 1; - } -}); - -tape( 'the function returns a filled array (dtype=float32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, 'float32', clbk ); - - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex128, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = filledarrayBy( 5, 'complex128', clbk ); - - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = filledarrayBy( 5, 'complex64', clbk ); - - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int32Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int32', clbk ); - - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint32Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint32', clbk ); - - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int16Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int16', clbk ); - - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint16', clbk ); - - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int8Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int8', clbk ); - - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint8', clbk ); - - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint8c', clbk ); - - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = [ 1, 1, 1, 1, 1 ]; - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'generic', clbk ); - - t.strictEqual( instanceOf( arr, Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex128, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = [ 1.0, 2.0 ]; - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = [ 1.0, 2.0 ]; - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int32', clbk ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, typed array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, typed array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex128, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = new Float64Array( [ 1.0, 2.0 ] ); - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = new Float64Array( [ 1.0, 2.0 ] ); - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (default, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex128, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer, byteoffset; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer, byteoffset; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, 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; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 48 ); - out = filledarrayBy( buf, 16, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 24 ); - out = filledarrayBy( buf, 8, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int32', clbk ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint8c', clbk ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, 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; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 64 ); - out = filledarrayBy( buf, 16, 2, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset, length)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 1, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 1, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled array (default, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, iterator; thisArg)', opts, function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - ctx = { - 'count': 0 - }; - indices = []; - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, iterator; thisArg)', opts, function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - ctx = { - 'count': 0 - }; - indices = []; - out = filledarrayBy( arr, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex128, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = iterConstant( new Complex128( 3.0, 3.0 ), { - 'iter': 2 - }); - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = iterConstant( new Complex64( 3.0, 3.0 ), { - 'iter': 2 - }); - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); From 82727621dbb7594e9b92d2a2df774b26f4dbb9ff Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Sep 2022 03:54:05 +0000 Subject: [PATCH 014/117] Transform error messages --- lib/main.js | 38 +++++++++++++++++++------------------- package.json | 2 +- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/lib/main.js b/lib/main.js index d27b055..d6fbe5e 100644 --- a/lib/main.js +++ b/lib/main.js @@ -32,7 +32,7 @@ var filledArray = require( '@stdlib/array-base-filled-by' ); var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); var iterLength = require( '@stdlib/iter-length' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -263,18 +263,18 @@ function filledarrayBy() { if ( isString( dtype ) ) { // Invoking this function with arguments `f( dtype, clbk[, thisArg] )` is not allowed (otherwise, we'd need to also allow `f( clbk[, thisArg] )`)... if ( nargs > 1 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format( '00L05' ) ); } ctor = ctors( dtype ); if ( ctor === null ) { - throw new TypeError( format( 'invalid argument. Must provide a recognized data type. Value: `%s`.', dtype ) ); + throw new TypeError( format( '00L2k', dtype ) ); } // Return an empty array having the specified dtype: return new ctor( 0 ); } // For all other supported invocations, we need at least two arguments... if ( nargs < 2 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format( '00L05' ) ); } // At this point, we need to do some argument juggling... nargs -= 1; // henceforth, the number of available arguments is `nargs+1` @@ -289,7 +289,7 @@ function filledarrayBy() { // Check if we were provided only a callback and a "this" context.. if ( nargs === 0 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format( '00L05' ) ); } } else { // "this" context is left undefined... @@ -302,12 +302,12 @@ function filledarrayBy() { nargs -= 1; clbk = arguments[ nargs ]; if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '00L2n', clbk ) ); } } // If were were only provided 2 arguments and the last argument was not a function, we've been provided an insufficient number of arguments... else { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format( '00L05' ) ); } // Now that we've processed the callback arguments, let's continue working backward to see if we've been provided a `dtype` argument... nargs -= 1; @@ -319,7 +319,7 @@ function filledarrayBy() { } ctor = ctors( dtype ); if ( ctor === null ) { - throw new TypeError( format( 'invalid argument. Must provide a recognized data type. Value: `%s`.', dtype ) ); + throw new TypeError( format( '00L2k', dtype ) ); } // At this point, we've resolved the output array data type, and now we can actually create the output array... if ( dtype === 'generic' ) { @@ -334,26 +334,26 @@ function filledarrayBy() { return filledArray( len, clbk, thisArg ); } if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format( '00L04' ) ); } if ( isObject( arg ) ) { if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.', arg ) ); + throw new TypeError( format( '00L2l', arg ) ); } if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00L2m', arg ) ); } arg = arg[ ITERATOR_SYMBOL ](); if ( !isFunction( arg.next ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00L2m', arg ) ); } return filledArrayIterator( arg, clbk, thisArg ); } - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00L2m', arg ) ); } else if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format( '00L04' ) ); } - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00L2m', arg ) ); } if ( nargs === 0 ) { // length || array-like || ArrayBuffer || iterable arg = arguments[ 0 ]; @@ -365,18 +365,18 @@ function filledarrayBy() { arr = new ctor( arg ); } else if ( isObject( arg ) ) { if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.', arg ) ); + throw new TypeError( format( '00L2l', arg ) ); } if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00L2m', arg ) ); } arg = arg[ ITERATOR_SYMBOL ](); if ( !isFunction( arg.next ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00L2m', arg ) ); } arr = new ctor( iterLength( arg ) ); } else { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00L2m', arg ) ); } } else if ( nargs === 1 ) { arr = new ctor( arguments[0], arguments[1] ); // (ArrayBuffer, byteOffset) diff --git a/package.json b/package.json index b974a7b..6511a88 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "@stdlib/assert-is-string": "^0.0.x", "@stdlib/blas-ext-base-gfill-by": "^0.0.x", "@stdlib/iter-length": "^0.0.x", - "@stdlib/string-format": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x", "@stdlib/symbol-iterator": "^0.0.x", "@stdlib/types": "^0.0.x" }, From 321b06f696a20e1ef22445449b7e9bded87df1a7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Sep 2022 11:27:29 +0000 Subject: [PATCH 015/117] Remove files --- index.d.ts | 427 -------- index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 3121 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 2156674..0000000 --- a/index.d.ts +++ /dev/null @@ -1,427 +0,0 @@ -/* -* @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. -*/ - -// TypeScript Version: 2.0 - -/// - -import { RealOrComplexTypedArray, DataType } from '@stdlib/types/array'; -import { Collection } from '@stdlib/types/object'; -import { IterableIterator } from '@stdlib/types/iter'; - -/** -* Array or typed array. -*/ -type ArrayOrTypedArray = Array | RealOrComplexTypedArray; - -/** -* Nullary callback function. -* -* @returns fill value -*/ -type Nullary = () => any; - -/** -* Unary callback function. -* -* @param i - current array index -* @returns fill value -*/ -type Unary = ( i: number ) => any; - -/** -* Callback function. -* -* @param i - current array index -* @returns fill value -*/ -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 -* -* @example -* var arr = filledarrayBy(); -* // returns -* -* @example -* var arr = filledarrayBy( 'float32' ); -* // returns -*/ -declare function filledarrayBy( dtype?: DataType ): ArrayOrTypedArray; // tslint:disable-line:unified-signatures - -/** -* Creates a filled array according to a provided callback function and having a specified `length`. -* -* @param length - array length -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* -* var arr = filledarrayBy( 5, constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( length: number, clbk: Callback, thisArg?: any ): ArrayOrTypedArray; // tslint:disable-line:max-line-length unified-signatures - -/** -* 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 -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* -* var arr = filledarrayBy( 5, 'float64', constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( length: number, dtype: DataType, clbk: Callback, thisArg?: any ): ArrayOrTypedArray; // tslint:disable-line:max-line-length unified-signatures - -/** -* Creates a filled array from another `array` according to a provided callback function. -* -* @param array - typed array or array-like object -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* -* 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; // tslint:disable-line:max-line-length 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 -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* -* 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; // tslint:disable-line:max-line-length unified-signatures - -/** -* Creates a filled array from an iterable according to a callback function. -* -* @param iterable - iterable -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* var iterConstant = require( `@stdlib/iter/constant` ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarrayBy( it, constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( iterable: IterableIterator, callback: Callback, thisArg?: any ): ArrayOrTypedArray; // tslint:disable-line:max-line-length 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 -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* var iterConstant = require( `@stdlib/iter/constant` ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* 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; // tslint:disable-line:max-line-length unified-signatures - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; // tslint:disable-line:max-line-length - -/** -* 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. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; // tslint:disable-line:max-line-length unified-signatures - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; // tslint:disable-line:max-line-length - -/** -* 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. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; // tslint:disable-line:max-line-length unified-signatures - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; // tslint:disable-line:max-line-length 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. -* -* @param buffer - `ArrayBuffer` -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; // tslint:disable-line:max-line-length unified-signatures - - -// EXPORTS // - -export = filledarrayBy; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 183311e..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-ctors@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill-by@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled-by@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";var w=d();function j(r,e,t){var s,i;for(s=[],i=-1;!r.next().done;)i+=1,s.push(e.call(t,i));return s}function a(r,e,t){var s;for(s=0;s1)throw new TypeError(p("00L05"));if(null===(b=o(g)))throw new TypeError(p("00L2k",g));return new b(0)}if(c<2)throw new TypeError(p("00L05"));if(n(arguments[c-=1]))if(n(arguments[c-1])){if(d=arguments[c],y=arguments[c-=1],0===c)throw new TypeError(p("00L05"))}else y=arguments[c];else{if(!(c>=2))throw new TypeError(p("00L05"));if(d=arguments[c],!n(y=arguments[c-=1]))throw new TypeError(p("00L2n",y))}if((c-=1)>=0&&r(arguments[c])?(g=arguments[c],c-=1):g="float64",null===(b=o(g)))throw new TypeError(p("00L2k",g));if("generic"===g){if(x=arguments[0],0===c){if(e(x)?u=x:t(x)&&(u=x.length),void 0!==u)return m(u,y,d);if(s(x))throw new Error(p("00L04"));if(i(x)){if(!1===w)throw new TypeError(p("00L2l",x));if(!n(x[f]))throw new TypeError(p("00L2m",x));if(x=x[f](),!n(x.next))throw new TypeError(p("00L2m",x));return j(x,y,d)}throw new TypeError(p("00L2m",x))}if(s(x))throw new Error(p("00L04"));throw new TypeError(p("00L2m",x))}if(0===c)if(t(x=arguments[0]))v=new b(x.length);else if(s(x))v=new b(x);else if(e(x))v=new b(x);else{if(!i(x))throw new TypeError(p("00L2m",x));if(!1===w)throw new TypeError(p("00L2l",x));if(!n(x[f]))throw new TypeError(p("00L2m",x));if(x=x[f](),!n(x.next))throw new TypeError(p("00L2m",x));v=new b(h(x))}else v=1===c?new b(arguments[0],arguments[1]):new b(arguments[0],arguments[1],arguments[2]);return v.length>0&&(/^complex/.test(g)?a(v,y,d):l(v.length,v,1,E)),v;function E(r,e){return y.call(d,e)}}export{c as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 12cc856..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.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\nimport { isPrimitive as isString } from '@stdlib/assert-is-string' ;\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer' ;\nimport isCollection from '@stdlib/assert-is-collection' ;\nimport isArrayBuffer from '@stdlib/assert-is-arraybuffer' ;\nimport isObject from '@stdlib/assert-is-object' ;\nimport isFunction from '@stdlib/assert-is-function' ;\nimport ctors from '@stdlib/array-ctors' ;\nimport gfillBy from '@stdlib/blas-ext-base-gfill-by' ;\nimport filledArray from '@stdlib/array-base-filled-by' ;\nimport hasIteratorSymbolSupport from '@stdlib/assert-has-iterator-symbol-support' ;\nimport ITERATOR_SYMBOL from '@stdlib/symbol-iterator' ;\nimport iterLength from '@stdlib/iter-length' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\n\n\n// VARIABLES //\n\nvar HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport();\nvar DEFAULT_DTYPE = 'float64';\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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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( format( '00L05' ) );\n\t\t}\n\t\tctor = ctors( dtype );\n\t\tif ( ctor === null ) {\n\t\t\tthrow new TypeError( format( '00L2k', 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( format( '00L05' ) );\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( format( '00L05' ) );\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( '00L2n', 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( format( '00L05' ) );\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( '00L2k', 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( format( '00L04' ) );\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( '00L2l', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00L2m', 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( '00L2m', 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( '00L2m', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format( '00L04' ) );\n\t\t}\n\t\tthrow new TypeError( format( '00L2m', 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( '00L2l', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00L2m', 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( '00L2m', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00L2m', 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\nexport default filledarrayBy;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","filledArrayIterator","it","clbk","thisArg","arr","i","next","done","push","call","filledAccessors","length","set","filledarrayBy","nargs","dtype","ctor","len","arg","arguments","ctors","isString","TypeError","format","isFunction","isNonNegativeInteger","isCollection","filledArray","isArrayBuffer","Error","isObject","ITERATOR_SYMBOL","iterLength","test","gfillBy","callback","value","aidx"],"mappings":";;wpCAuCA,IAAIA,EAAsBC,IAe1B,SAASC,EAAqBC,EAAIC,EAAMC,GACvC,IAAIC,EACAC,EAKJ,IAFAD,EAAM,GACNC,GAAK,GAEAJ,EAAGK,OACAC,MAGPF,GAAK,EACLD,EAAII,KAAMN,EAAKO,KAAMN,EAASE,IAE/B,OAAOD,EAYR,SAASM,EAAiBN,EAAKF,EAAMC,GACpC,IAAIE,EACJ,IAAMA,EAAI,EAAGA,EAAID,EAAIO,OAAQN,IAC5BD,EAAIQ,IAAKV,EAAKO,KAAMN,EAASE,GAAKA,GAEnC,OAAOD,EA6JR,SAASS,IACR,IAAIV,EACAW,EACAC,EACAb,EACAc,EACAZ,EACAa,EACAC,EAKJ,GAAe,KAHfJ,EAAQK,UAAUR,QAKjB,OAAO,IADPK,EAAOI,EAzNW,YA0ND,GAIlB,GAAKC,EADLN,EAAQI,UAAW,IACM,CAExB,GAAKL,EAAQ,EACZ,MAAM,IAAIQ,UAAWC,EAAQ,UAG9B,GAAc,QADdP,EAAOI,EAAOL,IAEb,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAGvC,OAAO,IAAIC,EAAM,GAGlB,GAAKF,EAAQ,EACZ,MAAM,IAAIQ,UAAWC,EAAQ,UAM9B,GAAKC,EAAYL,UAHjBL,GAAS,IAKR,GAAKU,EAAYL,UAAWL,EAAM,KAMjC,GALAX,EAAUgB,UAAWL,GAErBZ,EAAOiB,UADPL,GAAS,GAIM,IAAVA,EACJ,MAAM,IAAIQ,UAAWC,EAAQ,eAI9BrB,EAAOiB,UAAWL,OAIf,MAAKA,GAAS,GAUlB,MAAM,IAAIQ,UAAWC,EAAQ,UAN7B,GAHApB,EAAUgB,UAAWL,IAGfU,EADNtB,EAAOiB,UADPL,GAAS,IAGR,MAAM,IAAIQ,UAAWC,EAAQ,QAASrB,IAgBxC,IARAY,GAAS,IACK,GAAKO,EAAUF,UAAWL,KACvCC,EAAQI,UAAWL,GACnBA,GAAS,GAETC,EArRkB,UAwRL,QADdC,EAAOI,EAAOL,IAEb,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAGvC,GAAe,YAAVA,EAAsB,CAE1B,GADAG,EAAMC,UAAW,GACF,IAAVL,EAAc,CAMlB,GALKW,EAAsBP,GAC1BD,EAAMC,EACKQ,EAAcR,KACzBD,EAAMC,EAAIP,aAEE,IAARM,EACJ,OAAOU,EAAaV,EAAKf,EAAMC,GAEhC,GAAKyB,EAAeV,GACnB,MAAM,IAAIW,MAAON,EAAQ,UAE1B,GAAKO,EAAUZ,GAAQ,CACtB,IAA6B,IAAxBpB,EACJ,MAAM,IAAIwB,UAAWC,EAAQ,QAASL,IAEvC,IAAMM,EAAYN,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASL,IAGvC,GADAA,EAAMA,EAAKa,MACLP,EAAYN,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,QAASL,IAEvC,OAAOlB,EAAqBkB,EAAKhB,EAAMC,GAExC,MAAM,IAAImB,UAAWC,EAAQ,QAASL,IAChC,GAAKU,EAAeV,GAC1B,MAAM,IAAIW,MAAON,EAAQ,UAE1B,MAAM,IAAID,UAAWC,EAAQ,QAASL,IAEvC,GAAe,IAAVJ,EAEJ,GAAKY,EADLR,EAAMC,UAAW,IAEhBf,EAAM,IAAIY,EAAME,EAAIP,aACd,GAAKiB,EAAeV,GAC1Bd,EAAM,IAAIY,EAAME,QACV,GAAKO,EAAsBP,GACjCd,EAAM,IAAIY,EAAME,OACV,KAAKY,EAAUZ,GAarB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAZtC,IAA6B,IAAxBpB,EACJ,MAAM,IAAIwB,UAAWC,EAAQ,QAASL,IAEvC,IAAMM,EAAYN,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASL,IAGvC,GADAA,EAAMA,EAAKa,MACLP,EAAYN,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,QAASL,IAEvCd,EAAM,IAAIY,EAAMgB,EAAYd,SAK7Bd,EADqB,IAAVU,EACL,IAAIE,EAAMG,UAAU,GAAIA,UAAU,IAElC,IAAIH,EAAMG,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKf,EAAIO,OAAS,IACZ,WAAWsB,KAAMlB,GACrBL,EAAiBN,EAAKF,EAAMC,GAE5B+B,EAAS9B,EAAIO,OAAQP,EAAK,EAAG+B,IAGxB/B,EAYP,SAAS+B,EAAUC,EAAOC,GACzB,OAAOnC,EAAKO,KAAMN,EAASkC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 25b0e33..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From c0d6bfc9ff6b11b1dfc2ee6f4f518c9fade51324 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Sep 2022 11:28:33 +0000 Subject: [PATCH 016/117] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 760 ---- .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 178 - .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 41 +- benchmark/benchmark.js | 319 -- benchmark/benchmark.length.complex128.js | 98 - benchmark/benchmark.length.complex64.js | 98 - benchmark/benchmark.length.float32.js | 97 - benchmark/benchmark.length.float64.js | 97 - benchmark/benchmark.length.generic.js | 97 - benchmark/benchmark.length.int16.js | 97 - benchmark/benchmark.length.int32.js | 97 - benchmark/benchmark.length.int8.js | 97 - benchmark/benchmark.length.uint16.js | 97 - benchmark/benchmark.length.uint32.js | 97 - benchmark/benchmark.length.uint8.js | 97 - benchmark/benchmark.length.uint8c.js | 97 - branches.md | 53 - docs/repl.txt | 174 - docs/types/test.ts | 606 --- examples/index.js | 37 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 192 - lib/main.js | 413 -- package.json | 90 +- stats.html | 2689 +++++++++++++ test/test.js | 4248 --------------------- 49 files changed, 2714 insertions(+), 10225 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.length.complex128.js delete mode 100644 benchmark/benchmark.length.complex64.js delete mode 100644 benchmark/benchmark.length.float32.js delete mode 100644 benchmark/benchmark.length.float64.js delete mode 100644 benchmark/benchmark.length.generic.js delete mode 100644 benchmark/benchmark.length.int16.js delete mode 100644 benchmark/benchmark.length.int32.js delete mode 100644 benchmark/benchmark.length.int8.js delete mode 100644 benchmark/benchmark.length.uint16.js delete mode 100644 benchmark/benchmark.length.uint32.js delete mode 100644 benchmark/benchmark.length.uint8.js delete mode 100644 benchmark/benchmark.length.uint8c.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 734dad5..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-09-01T01:51:41.986Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 8be0b82..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 29bf533..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index a7a7f51..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.9.0 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index df9d9d7..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 39b1613..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 7ca169c..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '0 8 * * 6' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "::set-output name=package_name::$name" - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "::set-output name=data::$data" - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v2 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v2 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 5094681..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,760 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "::set-output name=alias::${alias}" - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -273,7 +266,7 @@ for ( i = 0; i < dt.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 421b48e..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,319 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); -var isArray = require( '@stdlib/assert-is-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var pkg = require( './../package.json' ).name; -var filledarrayBy = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 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=float64', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'float64', 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=float32', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'float32', 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; - var i; - - clbk = constantFunction( new Complex128( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'complex128', 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=complex64', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( new Complex64( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'complex64', 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=int32', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int32', 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=uint32', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint32', 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=int16', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int16', 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=uint16', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint16', 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=int8', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int8', 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=uint8', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint8', 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=uint8c', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint8c', 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=generic', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'generic', clbk ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.length.complex128.js b/benchmark/benchmark.length.complex128.js deleted file mode 100644 index 671de86..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var Complex128 = require( '@stdlib/complex-float64' ); -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( new Complex128( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'complex128', 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=complex128,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.complex64.js b/benchmark/benchmark.length.complex64.js deleted file mode 100644 index 52da4e3..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var Complex64 = require( '@stdlib/complex-float32' ); -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( new Complex64( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'complex64', 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=complex64,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.float32.js b/benchmark/benchmark.length.float32.js deleted file mode 100644 index 9b4ef9b..0000000 --- a/benchmark/benchmark.length.float32.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'float32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=float32,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.float64.js b/benchmark/benchmark.length.float64.js deleted file mode 100644 index 66cb6b6..0000000 --- a/benchmark/benchmark.length.float64.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'float64', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=float64,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.generic.js b/benchmark/benchmark.length.generic.js deleted file mode 100644 index 5194c1b..0000000 --- a/benchmark/benchmark.length.generic.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isArray = require( '@stdlib/assert-is-array' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'generic', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isArray( 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=generic,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int16.js b/benchmark/benchmark.length.int16.js deleted file mode 100644 index 6669b28..0000000 --- a/benchmark/benchmark.length.int16.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int16', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=int16,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int32.js b/benchmark/benchmark.length.int32.js deleted file mode 100644 index e9c5c88..0000000 --- a/benchmark/benchmark.length.int32.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=int32,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int8.js b/benchmark/benchmark.length.int8.js deleted file mode 100644 index 14bbadf..0000000 --- a/benchmark/benchmark.length.int8.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int8', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=int8,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint16.js b/benchmark/benchmark.length.uint16.js deleted file mode 100644 index d03b23e..0000000 --- a/benchmark/benchmark.length.uint16.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint16', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint16,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint32.js b/benchmark/benchmark.length.uint32.js deleted file mode 100644 index 1382134..0000000 --- a/benchmark/benchmark.length.uint32.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint32,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint8.js b/benchmark/benchmark.length.uint8.js deleted file mode 100644 index c135d6c..0000000 --- a/benchmark/benchmark.length.uint8.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint8', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint8,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint8c.js b/benchmark/benchmark.length.uint8c.js deleted file mode 100644 index 2f7523a..0000000 --- a/benchmark/benchmark.length.uint8c.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint8c', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint8c,len='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 18101fd..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by" -click B href "https://github.com/stdlib-js/array-filled-by/tree/main" -click C href "https://github.com/stdlib-js/array-filled-by/tree/production" -click D href "https://github.com/stdlib-js/array-filled-by/tree/esm" -click E href "https://github.com/stdlib-js/array-filled-by/tree/deno" -click F href "https://github.com/stdlib-js/array-filled-by/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by -[production-url]: https://github.com/stdlib-js/array-filled-by/tree/production -[deno-url]: https://github.com/stdlib-js/array-filled-by/tree/deno -[umd-url]: https://github.com/stdlib-js/array-filled-by/tree/umd -[esm-url]: https://github.com/stdlib-js/array-filled-by/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 5a68984..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,174 +0,0 @@ - -{{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) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr = {{alias}}() - - > arr = {{alias}}( 'float32' ) - - - -{{alias}}( length[, dtype], clbk[, thisArg] ) - Returns a filled array according to a provided callback function and having - a specified length. - - Parameters - ---------- - length: integer - Array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > function clbk() { return 1.0; }; - > var arr = {{alias}}( 5, clbk ) - [ 1.0, 1.0, 1.0, 1.0, 1.0 ] - > arr = {{alias}}( 5, 'int32', clbk ) - [ 1, 1, 1, 1, 1 ] - - -{{alias}}( array[, dtype], clbk[, thisArg] ) - Creates a filled array from another array (or array-like object) according - to a provided callback function. - - Parameters - ---------- - array: ArrayLikeObject - Array from which to generate another array. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias}}( [ 0.5, 0.5, 0.5 ], {{alias:@stdlib/utils/constant-function}}( 2.0 ) ) - [ 2.0, 2.0, 2.0 ] - > var arr2 = {{alias}}( arr1, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( iterable[, dtype], clbk[, thisArg] ) - Creates a filled array from an iterable according to a provided callback - function. - - Parameters - ---------- - iterable: Iterable - Iterable from which to generate an array. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias:@stdlib/iter/constant}}( 3.0, {'iter': 3} ); - > var arr2 = {{alias}}( arr1, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( buffer[, byteOffset[, length]][, dtype], clbk[, thisArg] ) - Returns a filled typed array view of an ArrayBuffer according to a provided - callback function. - - The 'generic' array data type is *not* supported. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( buf, 0, 4, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0, 1.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 394ac49..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,606 +0,0 @@ -/* -* @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. -*/ - -/// - -import { IterableIterator } from '@stdlib/types/iter'; -import filledarrayBy = require( './index' ); - - -/** -* Returns an iterator protocol-compliant object. -* -* @returns iterator protocol-compliant object -*/ -function iterator(): IterableIterator { - const obj: IterableIterator = { - [Symbol.iterator]: iterator, - 'next': next - }; - return obj; -} - -/** -* Implements the iterator protocol `next` method. -* -* @returns iterator protocol-compliant object -*/ -function next(): any { - return { - 'value': 1.0, - 'done': false - }; -} - -/** -* Callback function. -* -* @param i - current array index -* @returns return value -*/ -function clbk( i: number ): number { - return i; -} - - -// TESTS // - -// The function returns an array or typed array... -{ - filledarrayBy(); // $ExpectType ArrayOrTypedArray - filledarrayBy( 'float32' ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( 10, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( 10, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( 10, 'int32', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( 10, 'int32', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const x = new Float64Array( 10 ); - filledarrayBy( x, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( x, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( x, 'uint8', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( x, 'uint8', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const y = [ 2.0, 2.0, 2.0 ]; - filledarrayBy( y, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( y, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( y, 'float64', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( y, 'float64', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const it = iterator(); - filledarrayBy( it, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( it, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( it, 'uint8c', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( it, 'uint8c', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const buf = new ArrayBuffer( 32 ); - filledarrayBy( buf, clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 'uint32', clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 'uint32', clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 8, clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 8, clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 8, 'uint16', clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 8, 'uint16', clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 8, 2, clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 8, 2, clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 8, 2, 'int16', clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 8, 2, 'int16', clbk, {} ); // $ExpectType RealOrComplexTypedArray -} - -// The compiler throws an error if a callback function argument is not a function... -{ - filledarrayBy( 'float64', '5' ); // $ExpectError - filledarrayBy( 'float64', 1.0 ); // $ExpectError - filledarrayBy( 'float64', false ); // $ExpectError - filledarrayBy( 'float64', true ); // $ExpectError - filledarrayBy( 'float64', null ); // $ExpectError - filledarrayBy( 'float64', undefined ); // $ExpectError - filledarrayBy( 'float64', [] ); // $ExpectError - filledarrayBy( 'float64', {} ); // $ExpectError - - filledarrayBy( 'float64', '5', {} ); // $ExpectError - filledarrayBy( 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( 'float64', false, {} ); // $ExpectError - filledarrayBy( 'float64', true, {} ); // $ExpectError - filledarrayBy( 'float64', null, {} ); // $ExpectError - filledarrayBy( 'float64', undefined, {} ); // $ExpectError - filledarrayBy( 'float64', [], {} ); // $ExpectError - filledarrayBy( 'float64', {}, {} ); // $ExpectError - - filledarrayBy( 10, '5' ); // $ExpectError - filledarrayBy( 10, 1.0 ); // $ExpectError - filledarrayBy( 10, false ); // $ExpectError - filledarrayBy( 10, true ); // $ExpectError - filledarrayBy( 10, null ); // $ExpectError - filledarrayBy( 10, undefined ); // $ExpectError - filledarrayBy( 10, [] ); // $ExpectError - filledarrayBy( 10, {} ); // $ExpectError - - filledarrayBy( 10, '5', {} ); // $ExpectError - filledarrayBy( 10, 1.0, {} ); // $ExpectError - filledarrayBy( 10, false, {} ); // $ExpectError - filledarrayBy( 10, true, {} ); // $ExpectError - filledarrayBy( 10, null, {} ); // $ExpectError - filledarrayBy( 10, undefined, {} ); // $ExpectError - filledarrayBy( 10, [], {} ); // $ExpectError - filledarrayBy( 10, {}, {} ); // $ExpectError - - filledarrayBy( 10, 'float64', '5' ); // $ExpectError - filledarrayBy( 10, 'float64', 1.0 ); // $ExpectError - filledarrayBy( 10, 'float64', false ); // $ExpectError - filledarrayBy( 10, 'float64', true ); // $ExpectError - filledarrayBy( 10, 'float64', null ); // $ExpectError - filledarrayBy( 10, 'float64', undefined ); // $ExpectError - filledarrayBy( 10, 'float64', [] ); // $ExpectError - filledarrayBy( 10, 'float64', {} ); // $ExpectError - - filledarrayBy( 10, 'float64', '5', {} ); // $ExpectError - filledarrayBy( 10, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( 10, 'float64', false, {} ); // $ExpectError - filledarrayBy( 10, 'float64', true, {} ); // $ExpectError - filledarrayBy( 10, 'float64', null, {} ); // $ExpectError - filledarrayBy( 10, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( 10, 'float64', [], {} ); // $ExpectError - filledarrayBy( 10, 'float64', {}, {} ); // $ExpectError - - const x = new Float64Array( 10 ); - filledarrayBy( x, '5' ); // $ExpectError - filledarrayBy( x, 1.0 ); // $ExpectError - filledarrayBy( x, false ); // $ExpectError - filledarrayBy( x, true ); // $ExpectError - filledarrayBy( x, null ); // $ExpectError - filledarrayBy( x, undefined ); // $ExpectError - filledarrayBy( x, [] ); // $ExpectError - filledarrayBy( x, {} ); // $ExpectError - - filledarrayBy( x, '5', {} ); // $ExpectError - filledarrayBy( x, 1.0, {} ); // $ExpectError - filledarrayBy( x, false, {} ); // $ExpectError - filledarrayBy( x, true, {} ); // $ExpectError - filledarrayBy( x, null, {} ); // $ExpectError - filledarrayBy( x, undefined, {} ); // $ExpectError - filledarrayBy( x, [], {} ); // $ExpectError - filledarrayBy( x, {}, {} ); // $ExpectError - - filledarrayBy( x, 'float64', '5' ); // $ExpectError - filledarrayBy( x, 'float64', 1.0 ); // $ExpectError - filledarrayBy( x, 'float64', false ); // $ExpectError - filledarrayBy( x, 'float64', true ); // $ExpectError - filledarrayBy( x, 'float64', null ); // $ExpectError - filledarrayBy( x, 'float64', undefined ); // $ExpectError - filledarrayBy( x, 'float64', [] ); // $ExpectError - filledarrayBy( x, 'float64', {} ); // $ExpectError - - filledarrayBy( x, 'float64', '5', {} ); // $ExpectError - filledarrayBy( x, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( x, 'float64', false, {} ); // $ExpectError - filledarrayBy( x, 'float64', true, {} ); // $ExpectError - filledarrayBy( x, 'float64', null, {} ); // $ExpectError - filledarrayBy( x, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( x, 'float64', [], {} ); // $ExpectError - filledarrayBy( x, 'float64', {}, {} ); // $ExpectError - - const y = [ 2.0, 2.0, 2.0 ]; - filledarrayBy( y, '5' ); // $ExpectError - filledarrayBy( y, 1.0 ); // $ExpectError - filledarrayBy( y, false ); // $ExpectError - filledarrayBy( y, true ); // $ExpectError - filledarrayBy( y, null ); // $ExpectError - filledarrayBy( y, undefined ); // $ExpectError - filledarrayBy( y, [] ); // $ExpectError - filledarrayBy( y, {} ); // $ExpectError - - filledarrayBy( y, '5', {} ); // $ExpectError - filledarrayBy( y, 1.0, {} ); // $ExpectError - filledarrayBy( y, false, {} ); // $ExpectError - filledarrayBy( y, true, {} ); // $ExpectError - filledarrayBy( y, null, {} ); // $ExpectError - filledarrayBy( y, undefined, {} ); // $ExpectError - filledarrayBy( y, [], {} ); // $ExpectError - filledarrayBy( y, {}, {} ); // $ExpectError - - filledarrayBy( y, 'float64', '5' ); // $ExpectError - filledarrayBy( y, 'float64', 1.0 ); // $ExpectError - filledarrayBy( y, 'float64', false ); // $ExpectError - filledarrayBy( y, 'float64', true ); // $ExpectError - filledarrayBy( y, 'float64', null ); // $ExpectError - filledarrayBy( y, 'float64', undefined ); // $ExpectError - filledarrayBy( y, 'float64', [] ); // $ExpectError - filledarrayBy( y, 'float64', {} ); // $ExpectError - - filledarrayBy( y, 'float64', '5', {} ); // $ExpectError - filledarrayBy( y, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( y, 'float64', false, {} ); // $ExpectError - filledarrayBy( y, 'float64', true, {} ); // $ExpectError - filledarrayBy( y, 'float64', null, {} ); // $ExpectError - filledarrayBy( y, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( y, 'float64', [], {} ); // $ExpectError - filledarrayBy( y, 'float64', {}, {} ); // $ExpectError - - const it = iterator(); - filledarrayBy( it, '5' ); // $ExpectError - filledarrayBy( it, 1.0 ); // $ExpectError - filledarrayBy( it, false ); // $ExpectError - filledarrayBy( it, true ); // $ExpectError - filledarrayBy( it, null ); // $ExpectError - filledarrayBy( it, undefined ); // $ExpectError - filledarrayBy( it, [] ); // $ExpectError - filledarrayBy( it, {} ); // $ExpectError - - filledarrayBy( it, '5', {} ); // $ExpectError - filledarrayBy( it, 1.0, {} ); // $ExpectError - filledarrayBy( it, false, {} ); // $ExpectError - filledarrayBy( it, true, {} ); // $ExpectError - filledarrayBy( it, null, {} ); // $ExpectError - filledarrayBy( it, undefined, {} ); // $ExpectError - filledarrayBy( it, [], {} ); // $ExpectError - filledarrayBy( it, {}, {} ); // $ExpectError - - filledarrayBy( it, 'float64', '5' ); // $ExpectError - filledarrayBy( it, 'float64', 1.0 ); // $ExpectError - filledarrayBy( it, 'float64', false ); // $ExpectError - filledarrayBy( it, 'float64', true ); // $ExpectError - filledarrayBy( it, 'float64', null ); // $ExpectError - filledarrayBy( it, 'float64', undefined ); // $ExpectError - filledarrayBy( it, 'float64', [] ); // $ExpectError - filledarrayBy( it, 'float64', {} ); // $ExpectError - - filledarrayBy( it, 'float64', '5', {} ); // $ExpectError - filledarrayBy( it, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( it, 'float64', false, {} ); // $ExpectError - filledarrayBy( it, 'float64', true, {} ); // $ExpectError - filledarrayBy( it, 'float64', null, {} ); // $ExpectError - filledarrayBy( it, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( it, 'float64', [], {} ); // $ExpectError - filledarrayBy( it, 'float64', {}, {} ); // $ExpectError - - const buf = new ArrayBuffer( 32 ); - filledarrayBy( buf, '5' ); // $ExpectError - filledarrayBy( buf, 1.0 ); // $ExpectError - filledarrayBy( buf, false ); // $ExpectError - filledarrayBy( buf, true ); // $ExpectError - filledarrayBy( buf, null ); // $ExpectError - filledarrayBy( buf, undefined ); // $ExpectError - filledarrayBy( buf, [] ); // $ExpectError - filledarrayBy( buf, {} ); // $ExpectError - - filledarrayBy( buf, '5', {} ); // $ExpectError - filledarrayBy( buf, 1.0, {} ); // $ExpectError - filledarrayBy( buf, false, {} ); // $ExpectError - filledarrayBy( buf, true, {} ); // $ExpectError - filledarrayBy( buf, null, {} ); // $ExpectError - filledarrayBy( buf, undefined, {} ); // $ExpectError - filledarrayBy( buf, [], {} ); // $ExpectError - filledarrayBy( buf, {}, {} ); // $ExpectError - - filledarrayBy( buf, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 'float64', false ); // $ExpectError - filledarrayBy( buf, 'float64', true ); // $ExpectError - filledarrayBy( buf, 'float64', null ); // $ExpectError - filledarrayBy( buf, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 'float64', {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5' ); // $ExpectError - filledarrayBy( buf, 8, 1.0 ); // $ExpectError - filledarrayBy( buf, 8, false ); // $ExpectError - filledarrayBy( buf, 8, true ); // $ExpectError - filledarrayBy( buf, 8, null ); // $ExpectError - filledarrayBy( buf, 8, undefined ); // $ExpectError - filledarrayBy( buf, 8, [] ); // $ExpectError - filledarrayBy( buf, 8, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, false, {} ); // $ExpectError - filledarrayBy( buf, 8, true, {} ); // $ExpectError - filledarrayBy( buf, 8, null, {} ); // $ExpectError - filledarrayBy( buf, 8, undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, [], {} ); // $ExpectError - filledarrayBy( buf, 8, {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 8, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 'float64', false ); // $ExpectError - filledarrayBy( buf, 8, 'float64', true ); // $ExpectError - filledarrayBy( buf, 8, 'float64', null ); // $ExpectError - filledarrayBy( buf, 8, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 8, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 8, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 8, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, '5' ); // $ExpectError - filledarrayBy( buf, 8, 2, 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 2, false ); // $ExpectError - filledarrayBy( buf, 8, 2, true ); // $ExpectError - filledarrayBy( buf, 8, 2, null ); // $ExpectError - filledarrayBy( buf, 8, 2, undefined ); // $ExpectError - filledarrayBy( buf, 8, 2, [] ); // $ExpectError - filledarrayBy( buf, 8, 2, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, false, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, true, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, null, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, [], {} ); // $ExpectError - filledarrayBy( buf, 8, 2, {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', false ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', true ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', null ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', {}, {} ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid length, typed array, array-like object, `ArrayBuffer`, or iterable argument... -{ - filledarrayBy( false, clbk ); // $ExpectError - filledarrayBy( true, clbk ); // $ExpectError - filledarrayBy( null, clbk ); // $ExpectError - filledarrayBy( {}, clbk ); // $ExpectError - - filledarrayBy( false, clbk, {} ); // $ExpectError - filledarrayBy( true, clbk, {} ); // $ExpectError - filledarrayBy( null, clbk, {} ); // $ExpectError - filledarrayBy( {}, clbk, {} ); // $ExpectError - - filledarrayBy( false, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 'float64', clbk ); // $ExpectError - - filledarrayBy( false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, clbk ); // $ExpectError - filledarrayBy( 1.0, 8, clbk ); // $ExpectError - filledarrayBy( false, 8, clbk ); // $ExpectError - filledarrayBy( true, 8, clbk ); // $ExpectError - filledarrayBy( null, 8, clbk ); // $ExpectError - filledarrayBy( undefined, 8, clbk ); // $ExpectError - filledarrayBy( [], 8, clbk ); // $ExpectError - filledarrayBy( {}, 8, clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, clbk ); // $ExpectError - - filledarrayBy( '5', 8, clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, clbk, {} ); // $ExpectError - filledarrayBy( false, 8, clbk, {} ); // $ExpectError - filledarrayBy( true, 8, clbk, {} ); // $ExpectError - filledarrayBy( null, 8, clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, clbk, {} ); // $ExpectError - filledarrayBy( [], 8, clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 'float64', clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( false, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( [], 8, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 'float64', clbk ); // $ExpectError - - filledarrayBy( '5', 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 2, clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 2, clbk ); // $ExpectError - filledarrayBy( false, 8, 2, clbk ); // $ExpectError - filledarrayBy( true, 8, 2, clbk ); // $ExpectError - filledarrayBy( null, 8, 2, clbk ); // $ExpectError - filledarrayBy( undefined, 8, 2, clbk ); // $ExpectError - filledarrayBy( [], 8, 2, clbk ); // $ExpectError - filledarrayBy( {}, 8, 2, clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, clbk ); // $ExpectError - - filledarrayBy( '5', 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( false, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( [], 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, 'float64', clbk ); // $ExpectError - - filledarrayBy( '5', 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a byte offset argument which is not a number... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, false, clbk ); // $ExpectError - filledarrayBy( buf, true, clbk ); // $ExpectError - filledarrayBy( buf, null, clbk ); // $ExpectError - filledarrayBy( buf, [], clbk ); // $ExpectError - filledarrayBy( buf, {}, clbk ); // $ExpectError - - filledarrayBy( buf, false, clbk, {} ); // $ExpectError - filledarrayBy( buf, true, clbk, {} ); // $ExpectError - filledarrayBy( buf, null, clbk, {} ); // $ExpectError - filledarrayBy( buf, [], clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, clbk, {} ); // $ExpectError - - filledarrayBy( buf, '5', 'float64', clbk ); // $ExpectError - filledarrayBy( buf, false, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, true, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, null, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, [], 'float64', clbk ); // $ExpectError - filledarrayBy( buf, {}, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, '5', 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( buf, false, 2, clbk ); // $ExpectError - filledarrayBy( buf, true, 2, clbk ); // $ExpectError - filledarrayBy( buf, null, 2, clbk ); // $ExpectError - filledarrayBy( buf, [], 2, clbk ); // $ExpectError - filledarrayBy( buf, {}, 2, clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, clbk ); // $ExpectError - - filledarrayBy( buf, false, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, clbk, {} ); // $ExpectError - - filledarrayBy( buf, '5', 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, false, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, true, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, null, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, undefined, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, [], 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, {}, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, '5', 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, false, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, undefined, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a view length argument which is not a number... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, 8, false, clbk ); // $ExpectError - filledarrayBy( buf, 8, true, clbk ); // $ExpectError - filledarrayBy( buf, 8, null, clbk ); // $ExpectError - filledarrayBy( buf, 8, [], clbk ); // $ExpectError - filledarrayBy( buf, 8, {}, clbk ); // $ExpectError - - filledarrayBy( buf, 8, false, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, true, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, null, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, [], clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, {}, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, clbk, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5', 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, false, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, true, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, null, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, [], 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, {}, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, 8, '5', 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, [], 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, {}, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided too many arguments... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, 8, 2, 'float64', 1, clbk, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 997a381..0000000 --- a/examples/index.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ).factory; -var dtypes = require( '@stdlib/array-typed-real-dtypes' ); -var filledarrayBy = require( './../lib' ); - -// Create a pseudorandom number generator: -var rand = discreteUniform( 0, 100 ); - -// Get a list of array data types: -var dt = dtypes(); - -// Generate filled arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = filledarrayBy( 10, dt[ i ], rand ); - console.log( arr ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 3fc2784..2156674 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { RealOrComplexTypedArray, DataType } from '@stdlib/types/array'; import { Collection } from '@stdlib/types/object'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..ce0d7c1 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-ctors@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill-by@v0.0.10-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled-by@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";var w=d();function j(r,e,t){var s,i;for(s=[],i=-1;!r.next().done;)i+=1,s.push(e.call(t,i));return s}function a(r,e,t){var s;for(s=0;s1)throw new TypeError(p("00L05"));if(null===(b=o(g)))throw new TypeError(p("00L2k",g));return new b(0)}if(c<2)throw new TypeError(p("00L05"));if(n(arguments[c-=1]))if(n(arguments[c-1])){if(d=arguments[c],y=arguments[c-=1],0===c)throw new TypeError(p("00L05"))}else y=arguments[c];else{if(!(c>=2))throw new TypeError(p("00L05"));if(d=arguments[c],!n(y=arguments[c-=1]))throw new TypeError(p("00L2n",y))}if((c-=1)>=0&&r(arguments[c])?(g=arguments[c],c-=1):g="float64",null===(b=o(g)))throw new TypeError(p("00L2k",g));if("generic"===g){if(x=arguments[0],0===c){if(e(x)?u=x:t(x)&&(u=x.length),void 0!==u)return m(u,y,d);if(s(x))throw new Error(p("00L04"));if(i(x)){if(!1===w)throw new TypeError(p("00L2l",x));if(!n(x[f]))throw new TypeError(p("00L2m",x));if(x=x[f](),!n(x.next))throw new TypeError(p("00L2m",x));return j(x,y,d)}throw new TypeError(p("00L2m",x))}if(s(x))throw new Error(p("00L04"));throw new TypeError(p("00L2m",x))}if(0===c)if(t(x=arguments[0]))v=new b(x.length);else if(s(x))v=new b(x);else if(e(x))v=new b(x);else{if(!i(x))throw new TypeError(p("00L2m",x));if(!1===w)throw new TypeError(p("00L2l",x));if(!n(x[f]))throw new TypeError(p("00L2m",x));if(x=x[f](),!n(x.next))throw new TypeError(p("00L2m",x));v=new b(h(x))}else v=1===c?new b(arguments[0],arguments[1]):new b(arguments[0],arguments[1],arguments[2]);return v.length>0&&(/^complex/.test(g)?a(v,y,d):l(v.length,v,1,E)),v;function E(r,e){return y.call(d,e)}}export{c as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..bc9d089 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.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\nimport { isPrimitive as isString } from '@stdlib/assert-is-string' ;\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer' ;\nimport isCollection from '@stdlib/assert-is-collection' ;\nimport isArrayBuffer from '@stdlib/assert-is-arraybuffer' ;\nimport isObject from '@stdlib/assert-is-object' ;\nimport isFunction from '@stdlib/assert-is-function' ;\nimport ctors from '@stdlib/array-ctors' ;\nimport gfillBy from '@stdlib/blas-ext-base-gfill-by' ;\nimport filledArray from '@stdlib/array-base-filled-by' ;\nimport hasIteratorSymbolSupport from '@stdlib/assert-has-iterator-symbol-support' ;\nimport ITERATOR_SYMBOL from '@stdlib/symbol-iterator' ;\nimport iterLength from '@stdlib/iter-length' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\n\n\n// VARIABLES //\n\nvar HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport();\nvar DEFAULT_DTYPE = 'float64';\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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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( format( '00L05' ) );\n\t\t}\n\t\tctor = ctors( dtype );\n\t\tif ( ctor === null ) {\n\t\t\tthrow new TypeError( format( '00L2k', 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( format( '00L05' ) );\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( format( '00L05' ) );\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( '00L2n', 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( format( '00L05' ) );\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( '00L2k', 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( format( '00L04' ) );\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( '00L2l', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00L2m', 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( '00L2m', 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( '00L2m', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format( '00L04' ) );\n\t\t}\n\t\tthrow new TypeError( format( '00L2m', 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( '00L2l', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00L2m', 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( '00L2m', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00L2m', 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\nexport default filledarrayBy;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","filledArrayIterator","it","clbk","thisArg","arr","i","next","done","push","call","filledAccessors","length","set","filledarrayBy","nargs","dtype","ctor","len","arg","arguments","ctors","isString","TypeError","format","isFunction","isNonNegativeInteger","isCollection","filledArray","isArrayBuffer","Error","isObject","ITERATOR_SYMBOL","iterLength","test","gfillBy","callback","value","aidx"],"mappings":";;gqCAuCA,IAAIA,EAAsBC,IAe1B,SAASC,EAAqBC,EAAIC,EAAMC,GACvC,IAAIC,EACAC,EAKJ,IAFAD,EAAM,GACNC,GAAK,GAEAJ,EAAGK,OACAC,MAGPF,GAAK,EACLD,EAAII,KAAMN,EAAKO,KAAMN,EAASE,IAE/B,OAAOD,EAYR,SAASM,EAAiBN,EAAKF,EAAMC,GACpC,IAAIE,EACJ,IAAMA,EAAI,EAAGA,EAAID,EAAIO,OAAQN,IAC5BD,EAAIQ,IAAKV,EAAKO,KAAMN,EAASE,GAAKA,GAEnC,OAAOD,EA6JR,SAASS,IACR,IAAIV,EACAW,EACAC,EACAb,EACAc,EACAZ,EACAa,EACAC,EAKJ,GAAe,KAHfJ,EAAQK,UAAUR,QAKjB,OAAO,IADPK,EAAOI,EAzNW,YA0ND,GAIlB,GAAKC,EADLN,EAAQI,UAAW,IACM,CAExB,GAAKL,EAAQ,EACZ,MAAM,IAAIQ,UAAWC,EAAQ,UAG9B,GAAc,QADdP,EAAOI,EAAOL,IAEb,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAGvC,OAAO,IAAIC,EAAM,GAGlB,GAAKF,EAAQ,EACZ,MAAM,IAAIQ,UAAWC,EAAQ,UAM9B,GAAKC,EAAYL,UAHjBL,GAAS,IAKR,GAAKU,EAAYL,UAAWL,EAAM,KAMjC,GALAX,EAAUgB,UAAWL,GAErBZ,EAAOiB,UADPL,GAAS,GAIM,IAAVA,EACJ,MAAM,IAAIQ,UAAWC,EAAQ,eAI9BrB,EAAOiB,UAAWL,OAIf,MAAKA,GAAS,GAUlB,MAAM,IAAIQ,UAAWC,EAAQ,UAN7B,GAHApB,EAAUgB,UAAWL,IAGfU,EADNtB,EAAOiB,UADPL,GAAS,IAGR,MAAM,IAAIQ,UAAWC,EAAQ,QAASrB,IAgBxC,IARAY,GAAS,IACK,GAAKO,EAAUF,UAAWL,KACvCC,EAAQI,UAAWL,GACnBA,GAAS,GAETC,EArRkB,UAwRL,QADdC,EAAOI,EAAOL,IAEb,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAGvC,GAAe,YAAVA,EAAsB,CAE1B,GADAG,EAAMC,UAAW,GACF,IAAVL,EAAc,CAMlB,GALKW,EAAsBP,GAC1BD,EAAMC,EACKQ,EAAcR,KACzBD,EAAMC,EAAIP,aAEE,IAARM,EACJ,OAAOU,EAAaV,EAAKf,EAAMC,GAEhC,GAAKyB,EAAeV,GACnB,MAAM,IAAIW,MAAON,EAAQ,UAE1B,GAAKO,EAAUZ,GAAQ,CACtB,IAA6B,IAAxBpB,EACJ,MAAM,IAAIwB,UAAWC,EAAQ,QAASL,IAEvC,IAAMM,EAAYN,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASL,IAGvC,GADAA,EAAMA,EAAKa,MACLP,EAAYN,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,QAASL,IAEvC,OAAOlB,EAAqBkB,EAAKhB,EAAMC,GAExC,MAAM,IAAImB,UAAWC,EAAQ,QAASL,IAChC,GAAKU,EAAeV,GAC1B,MAAM,IAAIW,MAAON,EAAQ,UAE1B,MAAM,IAAID,UAAWC,EAAQ,QAASL,IAEvC,GAAe,IAAVJ,EAEJ,GAAKY,EADLR,EAAMC,UAAW,IAEhBf,EAAM,IAAIY,EAAME,EAAIP,aACd,GAAKiB,EAAeV,GAC1Bd,EAAM,IAAIY,EAAME,QACV,GAAKO,EAAsBP,GACjCd,EAAM,IAAIY,EAAME,OACV,KAAKY,EAAUZ,GAarB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAZtC,IAA6B,IAAxBpB,EACJ,MAAM,IAAIwB,UAAWC,EAAQ,QAASL,IAEvC,IAAMM,EAAYN,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASL,IAGvC,GADAA,EAAMA,EAAKa,MACLP,EAAYN,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,QAASL,IAEvCd,EAAM,IAAIY,EAAMgB,EAAYd,SAK7Bd,EADqB,IAAVU,EACL,IAAIE,EAAMG,UAAU,GAAIA,UAAU,IAElC,IAAIH,EAAMG,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKf,EAAIO,OAAS,IACZ,WAAWsB,KAAMlB,GACrBL,EAAiBN,EAAKF,EAAMC,GAE5B+B,EAAS9B,EAAIO,OAAQP,EAAK,EAAG+B,IAGxB/B,EAYP,SAAS+B,EAAUC,EAAOC,GACzB,OAAOnC,EAAKO,KAAMN,EAASkC"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d115cf0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,192 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -/** -* Create a filled array according to a provided callback function. -* -* @module @stdlib/array-filled-by -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* var arr = filledarrayBy(); -* // returns -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'generic', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( [ 0.5, 0.5 ], clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1; -* } -* -* var arr = filledarrayBy( [ 5, -3 ], 'int32', clbk ); -* // returns [ 1, 1 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk1() { -* return 10; -* } -* -* function clbk2() { -* return 1.0; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, clbk2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk1() { -* return 1.0; -* } -* -* function clbk2() { -* return 2; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, 'uint32', clbk2 ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 'float32', clbk ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, clbk ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, 'int32', clbk ); -* // returns [ 1, 1 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index d6fbe5e..0000000 --- a/lib/main.js +++ /dev/null @@ -1,413 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var isCollection = require( '@stdlib/assert-is-collection' ); -var isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isObject = require( '@stdlib/assert-is-object' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var ctors = require( '@stdlib/array-ctors' ); -var gfillBy = require( '@stdlib/blas-ext-base-gfill-by' ); -var filledArray = require( '@stdlib/array-base-filled-by' ); -var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var iterLength = require( '@stdlib/iter-length' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport(); -var DEFAULT_DTYPE = 'float64'; - - -// FUNCTIONS // - -/** -* Creates a filled "generic" array from an iterator. -* -* @private -* @param {Iterable} it - iterator -* @param {Callback} clbk - callback function -* @param {*} thisArg - callback function execution context -* @returns {Array} filled array -*/ -function filledArrayIterator( it, clbk, thisArg ) { - var arr; - var i; - var v; - - arr = []; - i = -1; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - i += 1; - arr.push( clbk.call( thisArg, i ) ); - } - return arr; -} - -/** -* Fills an array exposing accessors for getting and setting array elements. -* -* @private -* @param {Collection} arr - input array -* @param {Callback} clbk - callback function -* @param {*} thisArg - callback function execution context -* @returns {Collection} input array -*/ -function filledAccessors( arr, clbk, thisArg ) { - var i; - for ( i = 0; i < arr.length; i++ ) { - arr.set( clbk.call( thisArg, i ), i ); - } - return arr; -} - - -// MAIN // - -/** -* Creates a filled array according to a provided callback function. -* -* @param {(NonNegativeInteger|TypedArray|ArrayLikeObject|ArrayBuffer|Iterable)} [arg] - a length, typed array, array-like object, buffer, or iterable -* @param {NonNegativeInteger} [byteOffset=0] - byte offset -* @param {NonNegativeInteger} [length] - view length -* @param {string} [dtype="float64"] - data type -* @param {Callback} [clbk] - callback to invoke -* @param {*} [thisArg] - callback execution context -* @throws {TypeError} must provide a recognized data type -* @throws {TypeError} must provide a length, typed array, array-like object, buffer, or iterable -* @throws {TypeError} callback argument must be a function. -* @throws {Error} creating a generic array from an `ArrayBuffer` is not supported -* @returns {(TypedArray|Array)} array or typed array -* -* @example -* var arr = filledarrayBy(); -* // returns -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'generic', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( [ 0.5, 0.5 ], clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1; -* } -* -* var arr = filledarrayBy( [ 5, -3 ], 'int32', clbk ); -* // returns [ 1, 1 ] -* -* @example -* function clbk1() { -* return 10; -* } -* -* function clbk2() { -* return 1.0; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, clbk2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk1() { -* return 1.0; -* } -* -* function clbk2() { -* return 2; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, 'uint32', clbk2 ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 'float32', clbk ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, clbk ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, 'int32', clbk ); -* // returns [ 1, 1 ] -*/ -function filledarrayBy() { - var thisArg; - var nargs; - var dtype; - var clbk; - var ctor; - var arr; - var len; - var arg; - - nargs = arguments.length; - - // If we weren't provided any arguments, return an empty array... - if ( nargs === 0 ) { - ctor = ctors( DEFAULT_DTYPE ); - return new ctor( 0 ); - } - // Check if we were provided a dtype as the first argument... - dtype = arguments[ 0 ]; - if ( isString( dtype ) ) { - // Invoking this function with arguments `f( dtype, clbk[, thisArg] )` is not allowed (otherwise, we'd need to also allow `f( clbk[, thisArg] )`)... - if ( nargs > 1 ) { - throw new TypeError( format( '00L05' ) ); - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '00L2k', dtype ) ); - } - // Return an empty array having the specified dtype: - return new ctor( 0 ); - } - // For all other supported invocations, we need at least two arguments... - if ( nargs < 2 ) { - throw new TypeError( format( '00L05' ) ); - } - // At this point, we need to do some argument juggling... - nargs -= 1; // henceforth, the number of available arguments is `nargs+1` - - // Determine whether the last argument is a callback or "this" context... - if ( isFunction( arguments[ nargs ] ) ) { - // 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... - if ( isFunction( arguments[ nargs-1 ] ) ) { - thisArg = arguments[ nargs ]; - nargs -= 1; - clbk = arguments[ nargs ]; - - // Check if we were provided only a callback and a "this" context.. - if ( nargs === 0 ) { - throw new TypeError( format( '00L05' ) ); - } - } else { - // "this" context is left undefined... - clbk = arguments[ nargs ]; - } - } - // 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... - else if ( nargs >= 2 ) { - thisArg = arguments[ nargs ]; - nargs -= 1; - clbk = arguments[ nargs ]; - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '00L2n', clbk ) ); - } - } - // If were were only provided 2 arguments and the last argument was not a function, we've been provided an insufficient number of arguments... - else { - throw new TypeError( format( '00L05' ) ); - } - // Now that we've processed the callback arguments, let's continue working backward to see if we've been provided a `dtype` argument... - nargs -= 1; - if ( nargs >= 0 && isString( arguments[ nargs ] ) ) { - dtype = arguments[ nargs ]; - nargs -= 1; - } else { - dtype = DEFAULT_DTYPE; - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '00L2k', dtype ) ); - } - // At this point, we've resolved the output array data type, and now we can actually create the output array... - if ( dtype === 'generic' ) { - arg = arguments[ 0 ]; - if ( nargs === 0 ) { - if ( isNonNegativeInteger( arg ) ) { - len = arg; - } else if ( isCollection( arg ) ) { - len = arg.length; - } - if ( len !== void 0 ) { - return filledArray( len, clbk, thisArg ); - } - if ( isArrayBuffer( arg ) ) { - throw new Error( format( '00L04' ) ); - } - if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( '00L2l', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00L2m', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00L2m', arg ) ); - } - return filledArrayIterator( arg, clbk, thisArg ); - } - throw new TypeError( format( '00L2m', arg ) ); - } else if ( isArrayBuffer( arg ) ) { - throw new Error( format( '00L04' ) ); - } - throw new TypeError( format( '00L2m', arg ) ); - } - if ( nargs === 0 ) { // length || array-like || ArrayBuffer || iterable - arg = arguments[ 0 ]; - if ( isCollection( arg ) ) { - arr = new ctor( arg.length ); - } else if ( isArrayBuffer( arg ) ) { - arr = new ctor( arg ); - } else if ( isNonNegativeInteger( arg ) ) { - arr = new ctor( arg ); - } else if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( '00L2l', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00L2m', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00L2m', arg ) ); - } - arr = new ctor( iterLength( arg ) ); - } else { - throw new TypeError( format( '00L2m', arg ) ); - } - } else if ( nargs === 1 ) { - arr = new ctor( arguments[0], arguments[1] ); // (ArrayBuffer, byteOffset) - } else { - arr = new ctor( arguments[0], arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset, length) - } - if ( arr.length > 0 ) { - if ( /^complex/.test( dtype ) ) { - filledAccessors( arr, clbk, thisArg ); - } else { - gfillBy( arr.length, arr, 1, callback ); - } - } - return arr; - - /** - * Callback which wraps a provided callback and is invoked for each array element. - * - * @private - * @param {*} value - element value - * @param {NonNegativeInteger} aidx - array index - * @param {NonNegativeInteger} sidx - strided index - * @param {Collection} array - input array/collection - * @returns {*} callback return value - */ - function callback( value, aidx ) { - return clbk.call( thisArg, aidx ); - } -} - - -// EXPORTS // - -module.exports = filledarrayBy; diff --git a/package.json b/package.json index 6511a88..498622b 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.2", "description": "Create a filled array according to a provided callback function.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,69 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-filled-by": "^0.0.x", - "@stdlib/array-ctors": "^0.0.x", - "@stdlib/assert-has-iterator-symbol-support": "^0.0.x", - "@stdlib/assert-is-arraybuffer": "^0.0.x", - "@stdlib/assert-is-collection": "^0.0.x", - "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/assert-is-nonnegative-integer": "^0.0.x", - "@stdlib/assert-is-object": "^0.0.x", - "@stdlib/assert-is-string": "^0.0.x", - "@stdlib/blas-ext-base-gfill-by": "^0.0.x", - "@stdlib/iter-length": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x", - "@stdlib/symbol-iterator": "^0.0.x", - "@stdlib/types": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-buffer": "^0.0.x", - "@stdlib/array-complex128": "^0.0.x", - "@stdlib/array-complex64": "^0.0.x", - "@stdlib/array-float32": "^0.0.x", - "@stdlib/array-float64": "^0.0.x", - "@stdlib/array-int16": "^0.0.x", - "@stdlib/array-int32": "^0.0.x", - "@stdlib/array-int8": "^0.0.x", - "@stdlib/array-typed-real-dtypes": "^0.0.x", - "@stdlib/array-uint16": "^0.0.x", - "@stdlib/array-uint32": "^0.0.x", - "@stdlib/array-uint8": "^0.0.x", - "@stdlib/array-uint8c": "^0.0.x", - "@stdlib/assert-instance-of": "^0.0.x", - "@stdlib/assert-is-array": "^0.0.x", - "@stdlib/assert-is-typed-array": "^0.0.x", - "@stdlib/assert-is-typed-array-like": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/complex-float32": "^0.0.x", - "@stdlib/complex-float64": "^0.0.x", - "@stdlib/iter-constant": "^0.0.x", - "@stdlib/math-base-special-pow": "^0.0.x", - "@stdlib/random-base-discrete-uniform": "^0.0.x", - "@stdlib/strided-base-reinterpret-complex128": "^0.0.x", - "@stdlib/strided-base-reinterpret-complex64": "^0.0.x", - "@stdlib/utils-constant-function": "^0.0.x", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..9296e42 --- /dev/null +++ b/stats.html @@ -0,0 +1,2689 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index b55aa4a..0000000 --- a/test/test.js +++ /dev/null @@ -1,4248 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 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. -*/ - -/* eslint-disable max-len */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -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 ArrayBuffer = require( '@stdlib/array-buffer' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var iterConstant = require( '@stdlib/iter-constant' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var filledarrayBy = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': !hasIteratorSymbolSupport() -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof filledarrayBy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if only provided callback arguments', function test( t ) { - t.throws( clbk1, TypeError, 'throws an error' ); - t.throws( clbk2, TypeError, 'throws an error' ); - t.throws( clbk3, TypeError, 'throws an error' ); - t.end(); - - function clbk1() { - filledarrayBy( constantFunction( 1.0 ) ); - } - - function clbk2() { - filledarrayBy( constantFunction( 1.0 ), {} ); - } - - function clbk3() { - filledarrayBy( constantFunction( 1.0 ), constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (only argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (typed array; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (array-like object)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (array-like object; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 8 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 8 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, 1, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (iterator)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( iterConstant( 1.0 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (iterator; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( iterConstant( 1.0 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if only provided data type and callback arguments', function test( t ) { - t.throws( clbk1, TypeError, 'throws an error' ); - t.throws( clbk2, TypeError, 'throws an error' ); - t.throws( clbk3, TypeError, 'throws an error' ); - t.end(); - - function clbk1() { - filledarrayBy( 'float64', constantFunction( 1.0 ) ); - } - - function clbk2() { - filledarrayBy( 'float64', constantFunction( 1.0 ), {} ); - } - - function clbk3() { - filledarrayBy( 'float64', constantFunction( 1.0 ), constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (array-like object)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (array-like object; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, 1, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, 1, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (no iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (no iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (non-function iterator symbol property)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (non-function iterator symbol property; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (`next` property is not a function)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ) ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (`next` property is not a function; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ), {} ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (no iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (no iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (non-function iterator symbol property)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (non-function iterator symbol property; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (`next` property is not a function)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ) ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (`next` property is not a function; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ), {} ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 1, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 1, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function returns a filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - arr = filledarrayBy(); - - t.strictEqual( instanceOf( arr, Float64Array ), 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=float64)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - arr = filledarrayBy( 'float64' ); - - t.strictEqual( instanceOf( arr, Float64Array ), 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=float32)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( 0 ); - arr = filledarrayBy( 'float32' ); - - t.strictEqual( instanceOf( arr, Float32Array ), 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; - - expected = new Complex128Array( 0 ); - arr = filledarrayBy( 'complex128' ); - - t.strictEqual( instanceOf( arr, Complex128Array ), 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=complex64)', function test( t ) { - var expected; - var arr; - - expected = new Complex64Array( 0 ); - arr = filledarrayBy( 'complex64' ); - - t.strictEqual( instanceOf( arr, Complex64Array ), 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=int32)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( 0 ); - arr = filledarrayBy( 'int32' ); - - t.strictEqual( instanceOf( arr, Int32Array ), 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=uint32)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( 0 ); - arr = filledarrayBy( 'uint32' ); - - t.strictEqual( instanceOf( arr, Uint32Array ), 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=int16)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( 0 ); - arr = filledarrayBy( 'int16' ); - - t.strictEqual( instanceOf( arr, Int16Array ), 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=uint16)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( 0 ); - arr = filledarrayBy( 'uint16' ); - - t.strictEqual( instanceOf( arr, Uint16Array ), 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=int8)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( 0 ); - arr = filledarrayBy( 'int8' ); - - t.strictEqual( instanceOf( arr, Int8Array ), 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=uint8)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( 0 ); - arr = filledarrayBy( 'uint8' ); - - t.strictEqual( instanceOf( arr, Uint8Array ), 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=uint8c)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( 0 ); - arr = filledarrayBy( 'uint8c' ); - - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), 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=generic)', function test( t ) { - var expected; - var arr; - - expected = []; - arr = filledarrayBy( 'generic' ); - - t.strictEqual( instanceOf( arr, Array ), 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 (default, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, length=0)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array(); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 0, clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, clbk, ctx ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (default, length; thisArg=function)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, clbk, context ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this(); // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } - - function context() { - ctx.count += 1; - } -}); - -tape( 'the function returns a filled array (dtype=float64, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, 'float64', clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, length; thisArg=function)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, 'float64', clbk, context ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this(); // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } - - function context() { - ctx.count += 1; - } -}); - -tape( 'the function returns a filled array (dtype=float32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, 'float32', clbk ); - - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex128, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = filledarrayBy( 5, 'complex128', clbk ); - - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = filledarrayBy( 5, 'complex64', clbk ); - - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int32Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int32', clbk ); - - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint32Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint32', clbk ); - - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int16Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int16', clbk ); - - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint16', clbk ); - - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int8Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int8', clbk ); - - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint8', clbk ); - - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint8c', clbk ); - - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = [ 1, 1, 1, 1, 1 ]; - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'generic', clbk ); - - t.strictEqual( instanceOf( arr, Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex128, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = [ 1.0, 2.0 ]; - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = [ 1.0, 2.0 ]; - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int32', clbk ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, typed array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, typed array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex128, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = new Float64Array( [ 1.0, 2.0 ] ); - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = new Float64Array( [ 1.0, 2.0 ] ); - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (default, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex128, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer, byteoffset; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer, byteoffset; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, 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; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 48 ); - out = filledarrayBy( buf, 16, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 24 ); - out = filledarrayBy( buf, 8, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int32', clbk ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint8c', clbk ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, 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; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 64 ); - out = filledarrayBy( buf, 16, 2, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset, length)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 1, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 1, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled array (default, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, iterator; thisArg)', opts, function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - ctx = { - 'count': 0 - }; - indices = []; - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, iterator; thisArg)', opts, function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - ctx = { - 'count': 0 - }; - indices = []; - out = filledarrayBy( arr, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex128, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = iterConstant( new Complex128( 3.0, 3.0 ), { - 'iter': 2 - }); - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = iterConstant( new Complex64( 3.0, 3.0 ), { - 'iter': 2 - }); - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); From efa11345be5cd76f4d70d92ba0c91050b4e7c1f1 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Oct 2022 02:22:27 +0000 Subject: [PATCH 017/117] Transform error messages --- lib/main.js | 38 +++++++++++++++++++------------------- package.json | 2 +- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/lib/main.js b/lib/main.js index d27b055..d6fbe5e 100644 --- a/lib/main.js +++ b/lib/main.js @@ -32,7 +32,7 @@ var filledArray = require( '@stdlib/array-base-filled-by' ); var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); var iterLength = require( '@stdlib/iter-length' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -263,18 +263,18 @@ function filledarrayBy() { if ( isString( dtype ) ) { // Invoking this function with arguments `f( dtype, clbk[, thisArg] )` is not allowed (otherwise, we'd need to also allow `f( clbk[, thisArg] )`)... if ( nargs > 1 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format( '00L05' ) ); } ctor = ctors( dtype ); if ( ctor === null ) { - throw new TypeError( format( 'invalid argument. Must provide a recognized data type. Value: `%s`.', dtype ) ); + throw new TypeError( format( '00L2k', dtype ) ); } // Return an empty array having the specified dtype: return new ctor( 0 ); } // For all other supported invocations, we need at least two arguments... if ( nargs < 2 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format( '00L05' ) ); } // At this point, we need to do some argument juggling... nargs -= 1; // henceforth, the number of available arguments is `nargs+1` @@ -289,7 +289,7 @@ function filledarrayBy() { // Check if we were provided only a callback and a "this" context.. if ( nargs === 0 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format( '00L05' ) ); } } else { // "this" context is left undefined... @@ -302,12 +302,12 @@ function filledarrayBy() { nargs -= 1; clbk = arguments[ nargs ]; if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '00L2n', clbk ) ); } } // If were were only provided 2 arguments and the last argument was not a function, we've been provided an insufficient number of arguments... else { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format( '00L05' ) ); } // Now that we've processed the callback arguments, let's continue working backward to see if we've been provided a `dtype` argument... nargs -= 1; @@ -319,7 +319,7 @@ function filledarrayBy() { } ctor = ctors( dtype ); if ( ctor === null ) { - throw new TypeError( format( 'invalid argument. Must provide a recognized data type. Value: `%s`.', dtype ) ); + throw new TypeError( format( '00L2k', dtype ) ); } // At this point, we've resolved the output array data type, and now we can actually create the output array... if ( dtype === 'generic' ) { @@ -334,26 +334,26 @@ function filledarrayBy() { return filledArray( len, clbk, thisArg ); } if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format( '00L04' ) ); } if ( isObject( arg ) ) { if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.', arg ) ); + throw new TypeError( format( '00L2l', arg ) ); } if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00L2m', arg ) ); } arg = arg[ ITERATOR_SYMBOL ](); if ( !isFunction( arg.next ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00L2m', arg ) ); } return filledArrayIterator( arg, clbk, thisArg ); } - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00L2m', arg ) ); } else if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format( '00L04' ) ); } - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00L2m', arg ) ); } if ( nargs === 0 ) { // length || array-like || ArrayBuffer || iterable arg = arguments[ 0 ]; @@ -365,18 +365,18 @@ function filledarrayBy() { arr = new ctor( arg ); } else if ( isObject( arg ) ) { if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.', arg ) ); + throw new TypeError( format( '00L2l', arg ) ); } if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00L2m', arg ) ); } arg = arg[ ITERATOR_SYMBOL ](); if ( !isFunction( arg.next ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00L2m', arg ) ); } arr = new ctor( iterLength( arg ) ); } else { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00L2m', arg ) ); } } else if ( nargs === 1 ) { arr = new ctor( arguments[0], arguments[1] ); // (ArrayBuffer, byteOffset) diff --git a/package.json b/package.json index b974a7b..6511a88 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "@stdlib/assert-is-string": "^0.0.x", "@stdlib/blas-ext-base-gfill-by": "^0.0.x", "@stdlib/iter-length": "^0.0.x", - "@stdlib/string-format": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x", "@stdlib/symbol-iterator": "^0.0.x", "@stdlib/types": "^0.0.x" }, From a8ee9c4aa79f0e9def2373ffdad2de262f6f354d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Oct 2022 19:01:06 +0000 Subject: [PATCH 018/117] Remove files --- index.d.ts | 427 -------- index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 3121 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 2156674..0000000 --- a/index.d.ts +++ /dev/null @@ -1,427 +0,0 @@ -/* -* @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. -*/ - -// TypeScript Version: 2.0 - -/// - -import { RealOrComplexTypedArray, DataType } from '@stdlib/types/array'; -import { Collection } from '@stdlib/types/object'; -import { IterableIterator } from '@stdlib/types/iter'; - -/** -* Array or typed array. -*/ -type ArrayOrTypedArray = Array | RealOrComplexTypedArray; - -/** -* Nullary callback function. -* -* @returns fill value -*/ -type Nullary = () => any; - -/** -* Unary callback function. -* -* @param i - current array index -* @returns fill value -*/ -type Unary = ( i: number ) => any; - -/** -* Callback function. -* -* @param i - current array index -* @returns fill value -*/ -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 -* -* @example -* var arr = filledarrayBy(); -* // returns -* -* @example -* var arr = filledarrayBy( 'float32' ); -* // returns -*/ -declare function filledarrayBy( dtype?: DataType ): ArrayOrTypedArray; // tslint:disable-line:unified-signatures - -/** -* Creates a filled array according to a provided callback function and having a specified `length`. -* -* @param length - array length -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* -* var arr = filledarrayBy( 5, constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( length: number, clbk: Callback, thisArg?: any ): ArrayOrTypedArray; // tslint:disable-line:max-line-length unified-signatures - -/** -* 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 -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* -* var arr = filledarrayBy( 5, 'float64', constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( length: number, dtype: DataType, clbk: Callback, thisArg?: any ): ArrayOrTypedArray; // tslint:disable-line:max-line-length unified-signatures - -/** -* Creates a filled array from another `array` according to a provided callback function. -* -* @param array - typed array or array-like object -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* -* 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; // tslint:disable-line:max-line-length 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 -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* -* 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; // tslint:disable-line:max-line-length unified-signatures - -/** -* Creates a filled array from an iterable according to a callback function. -* -* @param iterable - iterable -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* var iterConstant = require( `@stdlib/iter/constant` ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarrayBy( it, constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( iterable: IterableIterator, callback: Callback, thisArg?: any ): ArrayOrTypedArray; // tslint:disable-line:max-line-length 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 -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* var iterConstant = require( `@stdlib/iter/constant` ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* 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; // tslint:disable-line:max-line-length unified-signatures - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; // tslint:disable-line:max-line-length - -/** -* 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. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; // tslint:disable-line:max-line-length unified-signatures - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; // tslint:disable-line:max-line-length - -/** -* 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. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; // tslint:disable-line:max-line-length unified-signatures - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; // tslint:disable-line:max-line-length 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. -* -* @param buffer - `ArrayBuffer` -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; // tslint:disable-line:max-line-length unified-signatures - - -// EXPORTS // - -export = filledarrayBy; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index ce0d7c1..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-ctors@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill-by@v0.0.10-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled-by@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";var w=d();function j(r,e,t){var s,i;for(s=[],i=-1;!r.next().done;)i+=1,s.push(e.call(t,i));return s}function a(r,e,t){var s;for(s=0;s1)throw new TypeError(p("00L05"));if(null===(b=o(g)))throw new TypeError(p("00L2k",g));return new b(0)}if(c<2)throw new TypeError(p("00L05"));if(n(arguments[c-=1]))if(n(arguments[c-1])){if(d=arguments[c],y=arguments[c-=1],0===c)throw new TypeError(p("00L05"))}else y=arguments[c];else{if(!(c>=2))throw new TypeError(p("00L05"));if(d=arguments[c],!n(y=arguments[c-=1]))throw new TypeError(p("00L2n",y))}if((c-=1)>=0&&r(arguments[c])?(g=arguments[c],c-=1):g="float64",null===(b=o(g)))throw new TypeError(p("00L2k",g));if("generic"===g){if(x=arguments[0],0===c){if(e(x)?u=x:t(x)&&(u=x.length),void 0!==u)return m(u,y,d);if(s(x))throw new Error(p("00L04"));if(i(x)){if(!1===w)throw new TypeError(p("00L2l",x));if(!n(x[f]))throw new TypeError(p("00L2m",x));if(x=x[f](),!n(x.next))throw new TypeError(p("00L2m",x));return j(x,y,d)}throw new TypeError(p("00L2m",x))}if(s(x))throw new Error(p("00L04"));throw new TypeError(p("00L2m",x))}if(0===c)if(t(x=arguments[0]))v=new b(x.length);else if(s(x))v=new b(x);else if(e(x))v=new b(x);else{if(!i(x))throw new TypeError(p("00L2m",x));if(!1===w)throw new TypeError(p("00L2l",x));if(!n(x[f]))throw new TypeError(p("00L2m",x));if(x=x[f](),!n(x.next))throw new TypeError(p("00L2m",x));v=new b(h(x))}else v=1===c?new b(arguments[0],arguments[1]):new b(arguments[0],arguments[1],arguments[2]);return v.length>0&&(/^complex/.test(g)?a(v,y,d):l(v.length,v,1,E)),v;function E(r,e){return y.call(d,e)}}export{c as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index bc9d089..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.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\nimport { isPrimitive as isString } from '@stdlib/assert-is-string' ;\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer' ;\nimport isCollection from '@stdlib/assert-is-collection' ;\nimport isArrayBuffer from '@stdlib/assert-is-arraybuffer' ;\nimport isObject from '@stdlib/assert-is-object' ;\nimport isFunction from '@stdlib/assert-is-function' ;\nimport ctors from '@stdlib/array-ctors' ;\nimport gfillBy from '@stdlib/blas-ext-base-gfill-by' ;\nimport filledArray from '@stdlib/array-base-filled-by' ;\nimport hasIteratorSymbolSupport from '@stdlib/assert-has-iterator-symbol-support' ;\nimport ITERATOR_SYMBOL from '@stdlib/symbol-iterator' ;\nimport iterLength from '@stdlib/iter-length' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\n\n\n// VARIABLES //\n\nvar HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport();\nvar DEFAULT_DTYPE = 'float64';\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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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( format( '00L05' ) );\n\t\t}\n\t\tctor = ctors( dtype );\n\t\tif ( ctor === null ) {\n\t\t\tthrow new TypeError( format( '00L2k', 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( format( '00L05' ) );\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( format( '00L05' ) );\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( '00L2n', 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( format( '00L05' ) );\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( '00L2k', 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( format( '00L04' ) );\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( '00L2l', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00L2m', 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( '00L2m', 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( '00L2m', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format( '00L04' ) );\n\t\t}\n\t\tthrow new TypeError( format( '00L2m', 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( '00L2l', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00L2m', 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( '00L2m', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00L2m', 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\nexport default filledarrayBy;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","filledArrayIterator","it","clbk","thisArg","arr","i","next","done","push","call","filledAccessors","length","set","filledarrayBy","nargs","dtype","ctor","len","arg","arguments","ctors","isString","TypeError","format","isFunction","isNonNegativeInteger","isCollection","filledArray","isArrayBuffer","Error","isObject","ITERATOR_SYMBOL","iterLength","test","gfillBy","callback","value","aidx"],"mappings":";;gqCAuCA,IAAIA,EAAsBC,IAe1B,SAASC,EAAqBC,EAAIC,EAAMC,GACvC,IAAIC,EACAC,EAKJ,IAFAD,EAAM,GACNC,GAAK,GAEAJ,EAAGK,OACAC,MAGPF,GAAK,EACLD,EAAII,KAAMN,EAAKO,KAAMN,EAASE,IAE/B,OAAOD,EAYR,SAASM,EAAiBN,EAAKF,EAAMC,GACpC,IAAIE,EACJ,IAAMA,EAAI,EAAGA,EAAID,EAAIO,OAAQN,IAC5BD,EAAIQ,IAAKV,EAAKO,KAAMN,EAASE,GAAKA,GAEnC,OAAOD,EA6JR,SAASS,IACR,IAAIV,EACAW,EACAC,EACAb,EACAc,EACAZ,EACAa,EACAC,EAKJ,GAAe,KAHfJ,EAAQK,UAAUR,QAKjB,OAAO,IADPK,EAAOI,EAzNW,YA0ND,GAIlB,GAAKC,EADLN,EAAQI,UAAW,IACM,CAExB,GAAKL,EAAQ,EACZ,MAAM,IAAIQ,UAAWC,EAAQ,UAG9B,GAAc,QADdP,EAAOI,EAAOL,IAEb,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAGvC,OAAO,IAAIC,EAAM,GAGlB,GAAKF,EAAQ,EACZ,MAAM,IAAIQ,UAAWC,EAAQ,UAM9B,GAAKC,EAAYL,UAHjBL,GAAS,IAKR,GAAKU,EAAYL,UAAWL,EAAM,KAMjC,GALAX,EAAUgB,UAAWL,GAErBZ,EAAOiB,UADPL,GAAS,GAIM,IAAVA,EACJ,MAAM,IAAIQ,UAAWC,EAAQ,eAI9BrB,EAAOiB,UAAWL,OAIf,MAAKA,GAAS,GAUlB,MAAM,IAAIQ,UAAWC,EAAQ,UAN7B,GAHApB,EAAUgB,UAAWL,IAGfU,EADNtB,EAAOiB,UADPL,GAAS,IAGR,MAAM,IAAIQ,UAAWC,EAAQ,QAASrB,IAgBxC,IARAY,GAAS,IACK,GAAKO,EAAUF,UAAWL,KACvCC,EAAQI,UAAWL,GACnBA,GAAS,GAETC,EArRkB,UAwRL,QADdC,EAAOI,EAAOL,IAEb,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAGvC,GAAe,YAAVA,EAAsB,CAE1B,GADAG,EAAMC,UAAW,GACF,IAAVL,EAAc,CAMlB,GALKW,EAAsBP,GAC1BD,EAAMC,EACKQ,EAAcR,KACzBD,EAAMC,EAAIP,aAEE,IAARM,EACJ,OAAOU,EAAaV,EAAKf,EAAMC,GAEhC,GAAKyB,EAAeV,GACnB,MAAM,IAAIW,MAAON,EAAQ,UAE1B,GAAKO,EAAUZ,GAAQ,CACtB,IAA6B,IAAxBpB,EACJ,MAAM,IAAIwB,UAAWC,EAAQ,QAASL,IAEvC,IAAMM,EAAYN,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASL,IAGvC,GADAA,EAAMA,EAAKa,MACLP,EAAYN,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,QAASL,IAEvC,OAAOlB,EAAqBkB,EAAKhB,EAAMC,GAExC,MAAM,IAAImB,UAAWC,EAAQ,QAASL,IAChC,GAAKU,EAAeV,GAC1B,MAAM,IAAIW,MAAON,EAAQ,UAE1B,MAAM,IAAID,UAAWC,EAAQ,QAASL,IAEvC,GAAe,IAAVJ,EAEJ,GAAKY,EADLR,EAAMC,UAAW,IAEhBf,EAAM,IAAIY,EAAME,EAAIP,aACd,GAAKiB,EAAeV,GAC1Bd,EAAM,IAAIY,EAAME,QACV,GAAKO,EAAsBP,GACjCd,EAAM,IAAIY,EAAME,OACV,KAAKY,EAAUZ,GAarB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAZtC,IAA6B,IAAxBpB,EACJ,MAAM,IAAIwB,UAAWC,EAAQ,QAASL,IAEvC,IAAMM,EAAYN,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASL,IAGvC,GADAA,EAAMA,EAAKa,MACLP,EAAYN,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,QAASL,IAEvCd,EAAM,IAAIY,EAAMgB,EAAYd,SAK7Bd,EADqB,IAAVU,EACL,IAAIE,EAAMG,UAAU,GAAIA,UAAU,IAElC,IAAIH,EAAMG,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKf,EAAIO,OAAS,IACZ,WAAWsB,KAAMlB,GACrBL,EAAiBN,EAAKF,EAAMC,GAE5B+B,EAAS9B,EAAIO,OAAQP,EAAK,EAAG+B,IAGxB/B,EAYP,SAAS+B,EAAUC,EAAOC,GACzB,OAAOnC,EAAKO,KAAMN,EAASkC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 9296e42..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From b2f86af59a6c3c695e4e909ee577e71e2847d940 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Oct 2022 19:01:55 +0000 Subject: [PATCH 019/117] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 760 ---- .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 178 - .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 41 +- benchmark/benchmark.js | 319 -- benchmark/benchmark.length.complex128.js | 98 - benchmark/benchmark.length.complex64.js | 98 - benchmark/benchmark.length.float32.js | 97 - benchmark/benchmark.length.float64.js | 97 - benchmark/benchmark.length.generic.js | 97 - benchmark/benchmark.length.int16.js | 97 - benchmark/benchmark.length.int32.js | 97 - benchmark/benchmark.length.int8.js | 97 - benchmark/benchmark.length.uint16.js | 97 - benchmark/benchmark.length.uint32.js | 97 - benchmark/benchmark.length.uint8.js | 97 - benchmark/benchmark.length.uint8c.js | 97 - branches.md | 53 - docs/repl.txt | 174 - docs/types/test.ts | 606 --- examples/index.js | 37 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 192 - lib/main.js | 413 -- package.json | 90 +- stats.html | 2689 +++++++++++++ test/test.js | 4248 --------------------- 49 files changed, 2714 insertions(+), 10225 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.length.complex128.js delete mode 100644 benchmark/benchmark.length.complex64.js delete mode 100644 benchmark/benchmark.length.float32.js delete mode 100644 benchmark/benchmark.length.float64.js delete mode 100644 benchmark/benchmark.length.generic.js delete mode 100644 benchmark/benchmark.length.int16.js delete mode 100644 benchmark/benchmark.length.int32.js delete mode 100644 benchmark/benchmark.length.int8.js delete mode 100644 benchmark/benchmark.length.uint16.js delete mode 100644 benchmark/benchmark.length.uint32.js delete mode 100644 benchmark/benchmark.length.uint8.js delete mode 100644 benchmark/benchmark.length.uint8c.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 58fdd08..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-10-01T02:20:11.631Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 8be0b82..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 29bf533..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index a7a7f51..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.9.0 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index df9d9d7..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 39b1613..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 7ca169c..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '0 8 * * 6' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "::set-output name=package_name::$name" - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "::set-output name=data::$data" - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v2 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v2 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 5094681..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,760 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "::set-output name=alias::${alias}" - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -273,7 +266,7 @@ for ( i = 0; i < dt.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 421b48e..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,319 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); -var isArray = require( '@stdlib/assert-is-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var pkg = require( './../package.json' ).name; -var filledarrayBy = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 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=float64', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'float64', 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=float32', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'float32', 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; - var i; - - clbk = constantFunction( new Complex128( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'complex128', 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=complex64', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( new Complex64( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'complex64', 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=int32', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int32', 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=uint32', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint32', 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=int16', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int16', 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=uint16', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint16', 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=int8', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int8', 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=uint8', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint8', 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=uint8c', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint8c', 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=generic', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'generic', clbk ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.length.complex128.js b/benchmark/benchmark.length.complex128.js deleted file mode 100644 index 671de86..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var Complex128 = require( '@stdlib/complex-float64' ); -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( new Complex128( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'complex128', 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=complex128,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.complex64.js b/benchmark/benchmark.length.complex64.js deleted file mode 100644 index 52da4e3..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var Complex64 = require( '@stdlib/complex-float32' ); -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( new Complex64( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'complex64', 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=complex64,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.float32.js b/benchmark/benchmark.length.float32.js deleted file mode 100644 index 9b4ef9b..0000000 --- a/benchmark/benchmark.length.float32.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'float32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=float32,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.float64.js b/benchmark/benchmark.length.float64.js deleted file mode 100644 index 66cb6b6..0000000 --- a/benchmark/benchmark.length.float64.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'float64', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=float64,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.generic.js b/benchmark/benchmark.length.generic.js deleted file mode 100644 index 5194c1b..0000000 --- a/benchmark/benchmark.length.generic.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isArray = require( '@stdlib/assert-is-array' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'generic', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isArray( 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=generic,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int16.js b/benchmark/benchmark.length.int16.js deleted file mode 100644 index 6669b28..0000000 --- a/benchmark/benchmark.length.int16.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int16', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=int16,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int32.js b/benchmark/benchmark.length.int32.js deleted file mode 100644 index e9c5c88..0000000 --- a/benchmark/benchmark.length.int32.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=int32,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int8.js b/benchmark/benchmark.length.int8.js deleted file mode 100644 index 14bbadf..0000000 --- a/benchmark/benchmark.length.int8.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int8', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=int8,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint16.js b/benchmark/benchmark.length.uint16.js deleted file mode 100644 index d03b23e..0000000 --- a/benchmark/benchmark.length.uint16.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint16', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint16,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint32.js b/benchmark/benchmark.length.uint32.js deleted file mode 100644 index 1382134..0000000 --- a/benchmark/benchmark.length.uint32.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint32,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint8.js b/benchmark/benchmark.length.uint8.js deleted file mode 100644 index c135d6c..0000000 --- a/benchmark/benchmark.length.uint8.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint8', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint8,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint8c.js b/benchmark/benchmark.length.uint8c.js deleted file mode 100644 index 2f7523a..0000000 --- a/benchmark/benchmark.length.uint8c.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint8c', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint8c,len='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 18101fd..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by" -click B href "https://github.com/stdlib-js/array-filled-by/tree/main" -click C href "https://github.com/stdlib-js/array-filled-by/tree/production" -click D href "https://github.com/stdlib-js/array-filled-by/tree/esm" -click E href "https://github.com/stdlib-js/array-filled-by/tree/deno" -click F href "https://github.com/stdlib-js/array-filled-by/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by -[production-url]: https://github.com/stdlib-js/array-filled-by/tree/production -[deno-url]: https://github.com/stdlib-js/array-filled-by/tree/deno -[umd-url]: https://github.com/stdlib-js/array-filled-by/tree/umd -[esm-url]: https://github.com/stdlib-js/array-filled-by/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 5a68984..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,174 +0,0 @@ - -{{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) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr = {{alias}}() - - > arr = {{alias}}( 'float32' ) - - - -{{alias}}( length[, dtype], clbk[, thisArg] ) - Returns a filled array according to a provided callback function and having - a specified length. - - Parameters - ---------- - length: integer - Array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > function clbk() { return 1.0; }; - > var arr = {{alias}}( 5, clbk ) - [ 1.0, 1.0, 1.0, 1.0, 1.0 ] - > arr = {{alias}}( 5, 'int32', clbk ) - [ 1, 1, 1, 1, 1 ] - - -{{alias}}( array[, dtype], clbk[, thisArg] ) - Creates a filled array from another array (or array-like object) according - to a provided callback function. - - Parameters - ---------- - array: ArrayLikeObject - Array from which to generate another array. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias}}( [ 0.5, 0.5, 0.5 ], {{alias:@stdlib/utils/constant-function}}( 2.0 ) ) - [ 2.0, 2.0, 2.0 ] - > var arr2 = {{alias}}( arr1, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( iterable[, dtype], clbk[, thisArg] ) - Creates a filled array from an iterable according to a provided callback - function. - - Parameters - ---------- - iterable: Iterable - Iterable from which to generate an array. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias:@stdlib/iter/constant}}( 3.0, {'iter': 3} ); - > var arr2 = {{alias}}( arr1, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( buffer[, byteOffset[, length]][, dtype], clbk[, thisArg] ) - Returns a filled typed array view of an ArrayBuffer according to a provided - callback function. - - The 'generic' array data type is *not* supported. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( buf, 0, 4, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0, 1.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 394ac49..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,606 +0,0 @@ -/* -* @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. -*/ - -/// - -import { IterableIterator } from '@stdlib/types/iter'; -import filledarrayBy = require( './index' ); - - -/** -* Returns an iterator protocol-compliant object. -* -* @returns iterator protocol-compliant object -*/ -function iterator(): IterableIterator { - const obj: IterableIterator = { - [Symbol.iterator]: iterator, - 'next': next - }; - return obj; -} - -/** -* Implements the iterator protocol `next` method. -* -* @returns iterator protocol-compliant object -*/ -function next(): any { - return { - 'value': 1.0, - 'done': false - }; -} - -/** -* Callback function. -* -* @param i - current array index -* @returns return value -*/ -function clbk( i: number ): number { - return i; -} - - -// TESTS // - -// The function returns an array or typed array... -{ - filledarrayBy(); // $ExpectType ArrayOrTypedArray - filledarrayBy( 'float32' ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( 10, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( 10, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( 10, 'int32', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( 10, 'int32', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const x = new Float64Array( 10 ); - filledarrayBy( x, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( x, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( x, 'uint8', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( x, 'uint8', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const y = [ 2.0, 2.0, 2.0 ]; - filledarrayBy( y, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( y, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( y, 'float64', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( y, 'float64', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const it = iterator(); - filledarrayBy( it, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( it, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( it, 'uint8c', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( it, 'uint8c', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const buf = new ArrayBuffer( 32 ); - filledarrayBy( buf, clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 'uint32', clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 'uint32', clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 8, clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 8, clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 8, 'uint16', clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 8, 'uint16', clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 8, 2, clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 8, 2, clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 8, 2, 'int16', clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 8, 2, 'int16', clbk, {} ); // $ExpectType RealOrComplexTypedArray -} - -// The compiler throws an error if a callback function argument is not a function... -{ - filledarrayBy( 'float64', '5' ); // $ExpectError - filledarrayBy( 'float64', 1.0 ); // $ExpectError - filledarrayBy( 'float64', false ); // $ExpectError - filledarrayBy( 'float64', true ); // $ExpectError - filledarrayBy( 'float64', null ); // $ExpectError - filledarrayBy( 'float64', undefined ); // $ExpectError - filledarrayBy( 'float64', [] ); // $ExpectError - filledarrayBy( 'float64', {} ); // $ExpectError - - filledarrayBy( 'float64', '5', {} ); // $ExpectError - filledarrayBy( 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( 'float64', false, {} ); // $ExpectError - filledarrayBy( 'float64', true, {} ); // $ExpectError - filledarrayBy( 'float64', null, {} ); // $ExpectError - filledarrayBy( 'float64', undefined, {} ); // $ExpectError - filledarrayBy( 'float64', [], {} ); // $ExpectError - filledarrayBy( 'float64', {}, {} ); // $ExpectError - - filledarrayBy( 10, '5' ); // $ExpectError - filledarrayBy( 10, 1.0 ); // $ExpectError - filledarrayBy( 10, false ); // $ExpectError - filledarrayBy( 10, true ); // $ExpectError - filledarrayBy( 10, null ); // $ExpectError - filledarrayBy( 10, undefined ); // $ExpectError - filledarrayBy( 10, [] ); // $ExpectError - filledarrayBy( 10, {} ); // $ExpectError - - filledarrayBy( 10, '5', {} ); // $ExpectError - filledarrayBy( 10, 1.0, {} ); // $ExpectError - filledarrayBy( 10, false, {} ); // $ExpectError - filledarrayBy( 10, true, {} ); // $ExpectError - filledarrayBy( 10, null, {} ); // $ExpectError - filledarrayBy( 10, undefined, {} ); // $ExpectError - filledarrayBy( 10, [], {} ); // $ExpectError - filledarrayBy( 10, {}, {} ); // $ExpectError - - filledarrayBy( 10, 'float64', '5' ); // $ExpectError - filledarrayBy( 10, 'float64', 1.0 ); // $ExpectError - filledarrayBy( 10, 'float64', false ); // $ExpectError - filledarrayBy( 10, 'float64', true ); // $ExpectError - filledarrayBy( 10, 'float64', null ); // $ExpectError - filledarrayBy( 10, 'float64', undefined ); // $ExpectError - filledarrayBy( 10, 'float64', [] ); // $ExpectError - filledarrayBy( 10, 'float64', {} ); // $ExpectError - - filledarrayBy( 10, 'float64', '5', {} ); // $ExpectError - filledarrayBy( 10, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( 10, 'float64', false, {} ); // $ExpectError - filledarrayBy( 10, 'float64', true, {} ); // $ExpectError - filledarrayBy( 10, 'float64', null, {} ); // $ExpectError - filledarrayBy( 10, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( 10, 'float64', [], {} ); // $ExpectError - filledarrayBy( 10, 'float64', {}, {} ); // $ExpectError - - const x = new Float64Array( 10 ); - filledarrayBy( x, '5' ); // $ExpectError - filledarrayBy( x, 1.0 ); // $ExpectError - filledarrayBy( x, false ); // $ExpectError - filledarrayBy( x, true ); // $ExpectError - filledarrayBy( x, null ); // $ExpectError - filledarrayBy( x, undefined ); // $ExpectError - filledarrayBy( x, [] ); // $ExpectError - filledarrayBy( x, {} ); // $ExpectError - - filledarrayBy( x, '5', {} ); // $ExpectError - filledarrayBy( x, 1.0, {} ); // $ExpectError - filledarrayBy( x, false, {} ); // $ExpectError - filledarrayBy( x, true, {} ); // $ExpectError - filledarrayBy( x, null, {} ); // $ExpectError - filledarrayBy( x, undefined, {} ); // $ExpectError - filledarrayBy( x, [], {} ); // $ExpectError - filledarrayBy( x, {}, {} ); // $ExpectError - - filledarrayBy( x, 'float64', '5' ); // $ExpectError - filledarrayBy( x, 'float64', 1.0 ); // $ExpectError - filledarrayBy( x, 'float64', false ); // $ExpectError - filledarrayBy( x, 'float64', true ); // $ExpectError - filledarrayBy( x, 'float64', null ); // $ExpectError - filledarrayBy( x, 'float64', undefined ); // $ExpectError - filledarrayBy( x, 'float64', [] ); // $ExpectError - filledarrayBy( x, 'float64', {} ); // $ExpectError - - filledarrayBy( x, 'float64', '5', {} ); // $ExpectError - filledarrayBy( x, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( x, 'float64', false, {} ); // $ExpectError - filledarrayBy( x, 'float64', true, {} ); // $ExpectError - filledarrayBy( x, 'float64', null, {} ); // $ExpectError - filledarrayBy( x, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( x, 'float64', [], {} ); // $ExpectError - filledarrayBy( x, 'float64', {}, {} ); // $ExpectError - - const y = [ 2.0, 2.0, 2.0 ]; - filledarrayBy( y, '5' ); // $ExpectError - filledarrayBy( y, 1.0 ); // $ExpectError - filledarrayBy( y, false ); // $ExpectError - filledarrayBy( y, true ); // $ExpectError - filledarrayBy( y, null ); // $ExpectError - filledarrayBy( y, undefined ); // $ExpectError - filledarrayBy( y, [] ); // $ExpectError - filledarrayBy( y, {} ); // $ExpectError - - filledarrayBy( y, '5', {} ); // $ExpectError - filledarrayBy( y, 1.0, {} ); // $ExpectError - filledarrayBy( y, false, {} ); // $ExpectError - filledarrayBy( y, true, {} ); // $ExpectError - filledarrayBy( y, null, {} ); // $ExpectError - filledarrayBy( y, undefined, {} ); // $ExpectError - filledarrayBy( y, [], {} ); // $ExpectError - filledarrayBy( y, {}, {} ); // $ExpectError - - filledarrayBy( y, 'float64', '5' ); // $ExpectError - filledarrayBy( y, 'float64', 1.0 ); // $ExpectError - filledarrayBy( y, 'float64', false ); // $ExpectError - filledarrayBy( y, 'float64', true ); // $ExpectError - filledarrayBy( y, 'float64', null ); // $ExpectError - filledarrayBy( y, 'float64', undefined ); // $ExpectError - filledarrayBy( y, 'float64', [] ); // $ExpectError - filledarrayBy( y, 'float64', {} ); // $ExpectError - - filledarrayBy( y, 'float64', '5', {} ); // $ExpectError - filledarrayBy( y, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( y, 'float64', false, {} ); // $ExpectError - filledarrayBy( y, 'float64', true, {} ); // $ExpectError - filledarrayBy( y, 'float64', null, {} ); // $ExpectError - filledarrayBy( y, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( y, 'float64', [], {} ); // $ExpectError - filledarrayBy( y, 'float64', {}, {} ); // $ExpectError - - const it = iterator(); - filledarrayBy( it, '5' ); // $ExpectError - filledarrayBy( it, 1.0 ); // $ExpectError - filledarrayBy( it, false ); // $ExpectError - filledarrayBy( it, true ); // $ExpectError - filledarrayBy( it, null ); // $ExpectError - filledarrayBy( it, undefined ); // $ExpectError - filledarrayBy( it, [] ); // $ExpectError - filledarrayBy( it, {} ); // $ExpectError - - filledarrayBy( it, '5', {} ); // $ExpectError - filledarrayBy( it, 1.0, {} ); // $ExpectError - filledarrayBy( it, false, {} ); // $ExpectError - filledarrayBy( it, true, {} ); // $ExpectError - filledarrayBy( it, null, {} ); // $ExpectError - filledarrayBy( it, undefined, {} ); // $ExpectError - filledarrayBy( it, [], {} ); // $ExpectError - filledarrayBy( it, {}, {} ); // $ExpectError - - filledarrayBy( it, 'float64', '5' ); // $ExpectError - filledarrayBy( it, 'float64', 1.0 ); // $ExpectError - filledarrayBy( it, 'float64', false ); // $ExpectError - filledarrayBy( it, 'float64', true ); // $ExpectError - filledarrayBy( it, 'float64', null ); // $ExpectError - filledarrayBy( it, 'float64', undefined ); // $ExpectError - filledarrayBy( it, 'float64', [] ); // $ExpectError - filledarrayBy( it, 'float64', {} ); // $ExpectError - - filledarrayBy( it, 'float64', '5', {} ); // $ExpectError - filledarrayBy( it, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( it, 'float64', false, {} ); // $ExpectError - filledarrayBy( it, 'float64', true, {} ); // $ExpectError - filledarrayBy( it, 'float64', null, {} ); // $ExpectError - filledarrayBy( it, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( it, 'float64', [], {} ); // $ExpectError - filledarrayBy( it, 'float64', {}, {} ); // $ExpectError - - const buf = new ArrayBuffer( 32 ); - filledarrayBy( buf, '5' ); // $ExpectError - filledarrayBy( buf, 1.0 ); // $ExpectError - filledarrayBy( buf, false ); // $ExpectError - filledarrayBy( buf, true ); // $ExpectError - filledarrayBy( buf, null ); // $ExpectError - filledarrayBy( buf, undefined ); // $ExpectError - filledarrayBy( buf, [] ); // $ExpectError - filledarrayBy( buf, {} ); // $ExpectError - - filledarrayBy( buf, '5', {} ); // $ExpectError - filledarrayBy( buf, 1.0, {} ); // $ExpectError - filledarrayBy( buf, false, {} ); // $ExpectError - filledarrayBy( buf, true, {} ); // $ExpectError - filledarrayBy( buf, null, {} ); // $ExpectError - filledarrayBy( buf, undefined, {} ); // $ExpectError - filledarrayBy( buf, [], {} ); // $ExpectError - filledarrayBy( buf, {}, {} ); // $ExpectError - - filledarrayBy( buf, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 'float64', false ); // $ExpectError - filledarrayBy( buf, 'float64', true ); // $ExpectError - filledarrayBy( buf, 'float64', null ); // $ExpectError - filledarrayBy( buf, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 'float64', {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5' ); // $ExpectError - filledarrayBy( buf, 8, 1.0 ); // $ExpectError - filledarrayBy( buf, 8, false ); // $ExpectError - filledarrayBy( buf, 8, true ); // $ExpectError - filledarrayBy( buf, 8, null ); // $ExpectError - filledarrayBy( buf, 8, undefined ); // $ExpectError - filledarrayBy( buf, 8, [] ); // $ExpectError - filledarrayBy( buf, 8, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, false, {} ); // $ExpectError - filledarrayBy( buf, 8, true, {} ); // $ExpectError - filledarrayBy( buf, 8, null, {} ); // $ExpectError - filledarrayBy( buf, 8, undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, [], {} ); // $ExpectError - filledarrayBy( buf, 8, {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 8, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 'float64', false ); // $ExpectError - filledarrayBy( buf, 8, 'float64', true ); // $ExpectError - filledarrayBy( buf, 8, 'float64', null ); // $ExpectError - filledarrayBy( buf, 8, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 8, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 8, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 8, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, '5' ); // $ExpectError - filledarrayBy( buf, 8, 2, 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 2, false ); // $ExpectError - filledarrayBy( buf, 8, 2, true ); // $ExpectError - filledarrayBy( buf, 8, 2, null ); // $ExpectError - filledarrayBy( buf, 8, 2, undefined ); // $ExpectError - filledarrayBy( buf, 8, 2, [] ); // $ExpectError - filledarrayBy( buf, 8, 2, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, false, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, true, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, null, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, [], {} ); // $ExpectError - filledarrayBy( buf, 8, 2, {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', false ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', true ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', null ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', {}, {} ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid length, typed array, array-like object, `ArrayBuffer`, or iterable argument... -{ - filledarrayBy( false, clbk ); // $ExpectError - filledarrayBy( true, clbk ); // $ExpectError - filledarrayBy( null, clbk ); // $ExpectError - filledarrayBy( {}, clbk ); // $ExpectError - - filledarrayBy( false, clbk, {} ); // $ExpectError - filledarrayBy( true, clbk, {} ); // $ExpectError - filledarrayBy( null, clbk, {} ); // $ExpectError - filledarrayBy( {}, clbk, {} ); // $ExpectError - - filledarrayBy( false, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 'float64', clbk ); // $ExpectError - - filledarrayBy( false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, clbk ); // $ExpectError - filledarrayBy( 1.0, 8, clbk ); // $ExpectError - filledarrayBy( false, 8, clbk ); // $ExpectError - filledarrayBy( true, 8, clbk ); // $ExpectError - filledarrayBy( null, 8, clbk ); // $ExpectError - filledarrayBy( undefined, 8, clbk ); // $ExpectError - filledarrayBy( [], 8, clbk ); // $ExpectError - filledarrayBy( {}, 8, clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, clbk ); // $ExpectError - - filledarrayBy( '5', 8, clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, clbk, {} ); // $ExpectError - filledarrayBy( false, 8, clbk, {} ); // $ExpectError - filledarrayBy( true, 8, clbk, {} ); // $ExpectError - filledarrayBy( null, 8, clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, clbk, {} ); // $ExpectError - filledarrayBy( [], 8, clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 'float64', clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( false, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( [], 8, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 'float64', clbk ); // $ExpectError - - filledarrayBy( '5', 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 2, clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 2, clbk ); // $ExpectError - filledarrayBy( false, 8, 2, clbk ); // $ExpectError - filledarrayBy( true, 8, 2, clbk ); // $ExpectError - filledarrayBy( null, 8, 2, clbk ); // $ExpectError - filledarrayBy( undefined, 8, 2, clbk ); // $ExpectError - filledarrayBy( [], 8, 2, clbk ); // $ExpectError - filledarrayBy( {}, 8, 2, clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, clbk ); // $ExpectError - - filledarrayBy( '5', 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( false, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( [], 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, 'float64', clbk ); // $ExpectError - - filledarrayBy( '5', 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a byte offset argument which is not a number... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, false, clbk ); // $ExpectError - filledarrayBy( buf, true, clbk ); // $ExpectError - filledarrayBy( buf, null, clbk ); // $ExpectError - filledarrayBy( buf, [], clbk ); // $ExpectError - filledarrayBy( buf, {}, clbk ); // $ExpectError - - filledarrayBy( buf, false, clbk, {} ); // $ExpectError - filledarrayBy( buf, true, clbk, {} ); // $ExpectError - filledarrayBy( buf, null, clbk, {} ); // $ExpectError - filledarrayBy( buf, [], clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, clbk, {} ); // $ExpectError - - filledarrayBy( buf, '5', 'float64', clbk ); // $ExpectError - filledarrayBy( buf, false, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, true, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, null, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, [], 'float64', clbk ); // $ExpectError - filledarrayBy( buf, {}, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, '5', 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( buf, false, 2, clbk ); // $ExpectError - filledarrayBy( buf, true, 2, clbk ); // $ExpectError - filledarrayBy( buf, null, 2, clbk ); // $ExpectError - filledarrayBy( buf, [], 2, clbk ); // $ExpectError - filledarrayBy( buf, {}, 2, clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, clbk ); // $ExpectError - - filledarrayBy( buf, false, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, clbk, {} ); // $ExpectError - - filledarrayBy( buf, '5', 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, false, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, true, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, null, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, undefined, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, [], 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, {}, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, '5', 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, false, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, undefined, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a view length argument which is not a number... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, 8, false, clbk ); // $ExpectError - filledarrayBy( buf, 8, true, clbk ); // $ExpectError - filledarrayBy( buf, 8, null, clbk ); // $ExpectError - filledarrayBy( buf, 8, [], clbk ); // $ExpectError - filledarrayBy( buf, 8, {}, clbk ); // $ExpectError - - filledarrayBy( buf, 8, false, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, true, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, null, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, [], clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, {}, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, clbk, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5', 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, false, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, true, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, null, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, [], 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, {}, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, 8, '5', 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, [], 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, {}, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided too many arguments... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, 8, 2, 'float64', 1, clbk, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 997a381..0000000 --- a/examples/index.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ).factory; -var dtypes = require( '@stdlib/array-typed-real-dtypes' ); -var filledarrayBy = require( './../lib' ); - -// Create a pseudorandom number generator: -var rand = discreteUniform( 0, 100 ); - -// Get a list of array data types: -var dt = dtypes(); - -// Generate filled arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = filledarrayBy( 10, dt[ i ], rand ); - console.log( arr ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 3fc2784..2156674 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { RealOrComplexTypedArray, DataType } from '@stdlib/types/array'; import { Collection } from '@stdlib/types/object'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..ce0d7c1 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-ctors@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill-by@v0.0.10-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled-by@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";var w=d();function j(r,e,t){var s,i;for(s=[],i=-1;!r.next().done;)i+=1,s.push(e.call(t,i));return s}function a(r,e,t){var s;for(s=0;s1)throw new TypeError(p("00L05"));if(null===(b=o(g)))throw new TypeError(p("00L2k",g));return new b(0)}if(c<2)throw new TypeError(p("00L05"));if(n(arguments[c-=1]))if(n(arguments[c-1])){if(d=arguments[c],y=arguments[c-=1],0===c)throw new TypeError(p("00L05"))}else y=arguments[c];else{if(!(c>=2))throw new TypeError(p("00L05"));if(d=arguments[c],!n(y=arguments[c-=1]))throw new TypeError(p("00L2n",y))}if((c-=1)>=0&&r(arguments[c])?(g=arguments[c],c-=1):g="float64",null===(b=o(g)))throw new TypeError(p("00L2k",g));if("generic"===g){if(x=arguments[0],0===c){if(e(x)?u=x:t(x)&&(u=x.length),void 0!==u)return m(u,y,d);if(s(x))throw new Error(p("00L04"));if(i(x)){if(!1===w)throw new TypeError(p("00L2l",x));if(!n(x[f]))throw new TypeError(p("00L2m",x));if(x=x[f](),!n(x.next))throw new TypeError(p("00L2m",x));return j(x,y,d)}throw new TypeError(p("00L2m",x))}if(s(x))throw new Error(p("00L04"));throw new TypeError(p("00L2m",x))}if(0===c)if(t(x=arguments[0]))v=new b(x.length);else if(s(x))v=new b(x);else if(e(x))v=new b(x);else{if(!i(x))throw new TypeError(p("00L2m",x));if(!1===w)throw new TypeError(p("00L2l",x));if(!n(x[f]))throw new TypeError(p("00L2m",x));if(x=x[f](),!n(x.next))throw new TypeError(p("00L2m",x));v=new b(h(x))}else v=1===c?new b(arguments[0],arguments[1]):new b(arguments[0],arguments[1],arguments[2]);return v.length>0&&(/^complex/.test(g)?a(v,y,d):l(v.length,v,1,E)),v;function E(r,e){return y.call(d,e)}}export{c as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..bc9d089 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.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\nimport { isPrimitive as isString } from '@stdlib/assert-is-string' ;\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer' ;\nimport isCollection from '@stdlib/assert-is-collection' ;\nimport isArrayBuffer from '@stdlib/assert-is-arraybuffer' ;\nimport isObject from '@stdlib/assert-is-object' ;\nimport isFunction from '@stdlib/assert-is-function' ;\nimport ctors from '@stdlib/array-ctors' ;\nimport gfillBy from '@stdlib/blas-ext-base-gfill-by' ;\nimport filledArray from '@stdlib/array-base-filled-by' ;\nimport hasIteratorSymbolSupport from '@stdlib/assert-has-iterator-symbol-support' ;\nimport ITERATOR_SYMBOL from '@stdlib/symbol-iterator' ;\nimport iterLength from '@stdlib/iter-length' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\n\n\n// VARIABLES //\n\nvar HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport();\nvar DEFAULT_DTYPE = 'float64';\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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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( format( '00L05' ) );\n\t\t}\n\t\tctor = ctors( dtype );\n\t\tif ( ctor === null ) {\n\t\t\tthrow new TypeError( format( '00L2k', 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( format( '00L05' ) );\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( format( '00L05' ) );\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( '00L2n', 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( format( '00L05' ) );\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( '00L2k', 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( format( '00L04' ) );\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( '00L2l', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00L2m', 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( '00L2m', 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( '00L2m', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format( '00L04' ) );\n\t\t}\n\t\tthrow new TypeError( format( '00L2m', 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( '00L2l', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00L2m', 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( '00L2m', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00L2m', 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\nexport default filledarrayBy;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","filledArrayIterator","it","clbk","thisArg","arr","i","next","done","push","call","filledAccessors","length","set","filledarrayBy","nargs","dtype","ctor","len","arg","arguments","ctors","isString","TypeError","format","isFunction","isNonNegativeInteger","isCollection","filledArray","isArrayBuffer","Error","isObject","ITERATOR_SYMBOL","iterLength","test","gfillBy","callback","value","aidx"],"mappings":";;gqCAuCA,IAAIA,EAAsBC,IAe1B,SAASC,EAAqBC,EAAIC,EAAMC,GACvC,IAAIC,EACAC,EAKJ,IAFAD,EAAM,GACNC,GAAK,GAEAJ,EAAGK,OACAC,MAGPF,GAAK,EACLD,EAAII,KAAMN,EAAKO,KAAMN,EAASE,IAE/B,OAAOD,EAYR,SAASM,EAAiBN,EAAKF,EAAMC,GACpC,IAAIE,EACJ,IAAMA,EAAI,EAAGA,EAAID,EAAIO,OAAQN,IAC5BD,EAAIQ,IAAKV,EAAKO,KAAMN,EAASE,GAAKA,GAEnC,OAAOD,EA6JR,SAASS,IACR,IAAIV,EACAW,EACAC,EACAb,EACAc,EACAZ,EACAa,EACAC,EAKJ,GAAe,KAHfJ,EAAQK,UAAUR,QAKjB,OAAO,IADPK,EAAOI,EAzNW,YA0ND,GAIlB,GAAKC,EADLN,EAAQI,UAAW,IACM,CAExB,GAAKL,EAAQ,EACZ,MAAM,IAAIQ,UAAWC,EAAQ,UAG9B,GAAc,QADdP,EAAOI,EAAOL,IAEb,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAGvC,OAAO,IAAIC,EAAM,GAGlB,GAAKF,EAAQ,EACZ,MAAM,IAAIQ,UAAWC,EAAQ,UAM9B,GAAKC,EAAYL,UAHjBL,GAAS,IAKR,GAAKU,EAAYL,UAAWL,EAAM,KAMjC,GALAX,EAAUgB,UAAWL,GAErBZ,EAAOiB,UADPL,GAAS,GAIM,IAAVA,EACJ,MAAM,IAAIQ,UAAWC,EAAQ,eAI9BrB,EAAOiB,UAAWL,OAIf,MAAKA,GAAS,GAUlB,MAAM,IAAIQ,UAAWC,EAAQ,UAN7B,GAHApB,EAAUgB,UAAWL,IAGfU,EADNtB,EAAOiB,UADPL,GAAS,IAGR,MAAM,IAAIQ,UAAWC,EAAQ,QAASrB,IAgBxC,IARAY,GAAS,IACK,GAAKO,EAAUF,UAAWL,KACvCC,EAAQI,UAAWL,GACnBA,GAAS,GAETC,EArRkB,UAwRL,QADdC,EAAOI,EAAOL,IAEb,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAGvC,GAAe,YAAVA,EAAsB,CAE1B,GADAG,EAAMC,UAAW,GACF,IAAVL,EAAc,CAMlB,GALKW,EAAsBP,GAC1BD,EAAMC,EACKQ,EAAcR,KACzBD,EAAMC,EAAIP,aAEE,IAARM,EACJ,OAAOU,EAAaV,EAAKf,EAAMC,GAEhC,GAAKyB,EAAeV,GACnB,MAAM,IAAIW,MAAON,EAAQ,UAE1B,GAAKO,EAAUZ,GAAQ,CACtB,IAA6B,IAAxBpB,EACJ,MAAM,IAAIwB,UAAWC,EAAQ,QAASL,IAEvC,IAAMM,EAAYN,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASL,IAGvC,GADAA,EAAMA,EAAKa,MACLP,EAAYN,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,QAASL,IAEvC,OAAOlB,EAAqBkB,EAAKhB,EAAMC,GAExC,MAAM,IAAImB,UAAWC,EAAQ,QAASL,IAChC,GAAKU,EAAeV,GAC1B,MAAM,IAAIW,MAAON,EAAQ,UAE1B,MAAM,IAAID,UAAWC,EAAQ,QAASL,IAEvC,GAAe,IAAVJ,EAEJ,GAAKY,EADLR,EAAMC,UAAW,IAEhBf,EAAM,IAAIY,EAAME,EAAIP,aACd,GAAKiB,EAAeV,GAC1Bd,EAAM,IAAIY,EAAME,QACV,GAAKO,EAAsBP,GACjCd,EAAM,IAAIY,EAAME,OACV,KAAKY,EAAUZ,GAarB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAZtC,IAA6B,IAAxBpB,EACJ,MAAM,IAAIwB,UAAWC,EAAQ,QAASL,IAEvC,IAAMM,EAAYN,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASL,IAGvC,GADAA,EAAMA,EAAKa,MACLP,EAAYN,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,QAASL,IAEvCd,EAAM,IAAIY,EAAMgB,EAAYd,SAK7Bd,EADqB,IAAVU,EACL,IAAIE,EAAMG,UAAU,GAAIA,UAAU,IAElC,IAAIH,EAAMG,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKf,EAAIO,OAAS,IACZ,WAAWsB,KAAMlB,GACrBL,EAAiBN,EAAKF,EAAMC,GAE5B+B,EAAS9B,EAAIO,OAAQP,EAAK,EAAG+B,IAGxB/B,EAYP,SAAS+B,EAAUC,EAAOC,GACzB,OAAOnC,EAAKO,KAAMN,EAASkC"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d115cf0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,192 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -/** -* Create a filled array according to a provided callback function. -* -* @module @stdlib/array-filled-by -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* var arr = filledarrayBy(); -* // returns -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'generic', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( [ 0.5, 0.5 ], clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1; -* } -* -* var arr = filledarrayBy( [ 5, -3 ], 'int32', clbk ); -* // returns [ 1, 1 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk1() { -* return 10; -* } -* -* function clbk2() { -* return 1.0; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, clbk2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk1() { -* return 1.0; -* } -* -* function clbk2() { -* return 2; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, 'uint32', clbk2 ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 'float32', clbk ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, clbk ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, 'int32', clbk ); -* // returns [ 1, 1 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index d6fbe5e..0000000 --- a/lib/main.js +++ /dev/null @@ -1,413 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var isCollection = require( '@stdlib/assert-is-collection' ); -var isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isObject = require( '@stdlib/assert-is-object' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var ctors = require( '@stdlib/array-ctors' ); -var gfillBy = require( '@stdlib/blas-ext-base-gfill-by' ); -var filledArray = require( '@stdlib/array-base-filled-by' ); -var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var iterLength = require( '@stdlib/iter-length' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport(); -var DEFAULT_DTYPE = 'float64'; - - -// FUNCTIONS // - -/** -* Creates a filled "generic" array from an iterator. -* -* @private -* @param {Iterable} it - iterator -* @param {Callback} clbk - callback function -* @param {*} thisArg - callback function execution context -* @returns {Array} filled array -*/ -function filledArrayIterator( it, clbk, thisArg ) { - var arr; - var i; - var v; - - arr = []; - i = -1; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - i += 1; - arr.push( clbk.call( thisArg, i ) ); - } - return arr; -} - -/** -* Fills an array exposing accessors for getting and setting array elements. -* -* @private -* @param {Collection} arr - input array -* @param {Callback} clbk - callback function -* @param {*} thisArg - callback function execution context -* @returns {Collection} input array -*/ -function filledAccessors( arr, clbk, thisArg ) { - var i; - for ( i = 0; i < arr.length; i++ ) { - arr.set( clbk.call( thisArg, i ), i ); - } - return arr; -} - - -// MAIN // - -/** -* Creates a filled array according to a provided callback function. -* -* @param {(NonNegativeInteger|TypedArray|ArrayLikeObject|ArrayBuffer|Iterable)} [arg] - a length, typed array, array-like object, buffer, or iterable -* @param {NonNegativeInteger} [byteOffset=0] - byte offset -* @param {NonNegativeInteger} [length] - view length -* @param {string} [dtype="float64"] - data type -* @param {Callback} [clbk] - callback to invoke -* @param {*} [thisArg] - callback execution context -* @throws {TypeError} must provide a recognized data type -* @throws {TypeError} must provide a length, typed array, array-like object, buffer, or iterable -* @throws {TypeError} callback argument must be a function. -* @throws {Error} creating a generic array from an `ArrayBuffer` is not supported -* @returns {(TypedArray|Array)} array or typed array -* -* @example -* var arr = filledarrayBy(); -* // returns -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'generic', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( [ 0.5, 0.5 ], clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1; -* } -* -* var arr = filledarrayBy( [ 5, -3 ], 'int32', clbk ); -* // returns [ 1, 1 ] -* -* @example -* function clbk1() { -* return 10; -* } -* -* function clbk2() { -* return 1.0; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, clbk2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk1() { -* return 1.0; -* } -* -* function clbk2() { -* return 2; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, 'uint32', clbk2 ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 'float32', clbk ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, clbk ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, 'int32', clbk ); -* // returns [ 1, 1 ] -*/ -function filledarrayBy() { - var thisArg; - var nargs; - var dtype; - var clbk; - var ctor; - var arr; - var len; - var arg; - - nargs = arguments.length; - - // If we weren't provided any arguments, return an empty array... - if ( nargs === 0 ) { - ctor = ctors( DEFAULT_DTYPE ); - return new ctor( 0 ); - } - // Check if we were provided a dtype as the first argument... - dtype = arguments[ 0 ]; - if ( isString( dtype ) ) { - // Invoking this function with arguments `f( dtype, clbk[, thisArg] )` is not allowed (otherwise, we'd need to also allow `f( clbk[, thisArg] )`)... - if ( nargs > 1 ) { - throw new TypeError( format( '00L05' ) ); - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '00L2k', dtype ) ); - } - // Return an empty array having the specified dtype: - return new ctor( 0 ); - } - // For all other supported invocations, we need at least two arguments... - if ( nargs < 2 ) { - throw new TypeError( format( '00L05' ) ); - } - // At this point, we need to do some argument juggling... - nargs -= 1; // henceforth, the number of available arguments is `nargs+1` - - // Determine whether the last argument is a callback or "this" context... - if ( isFunction( arguments[ nargs ] ) ) { - // 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... - if ( isFunction( arguments[ nargs-1 ] ) ) { - thisArg = arguments[ nargs ]; - nargs -= 1; - clbk = arguments[ nargs ]; - - // Check if we were provided only a callback and a "this" context.. - if ( nargs === 0 ) { - throw new TypeError( format( '00L05' ) ); - } - } else { - // "this" context is left undefined... - clbk = arguments[ nargs ]; - } - } - // 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... - else if ( nargs >= 2 ) { - thisArg = arguments[ nargs ]; - nargs -= 1; - clbk = arguments[ nargs ]; - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '00L2n', clbk ) ); - } - } - // If were were only provided 2 arguments and the last argument was not a function, we've been provided an insufficient number of arguments... - else { - throw new TypeError( format( '00L05' ) ); - } - // Now that we've processed the callback arguments, let's continue working backward to see if we've been provided a `dtype` argument... - nargs -= 1; - if ( nargs >= 0 && isString( arguments[ nargs ] ) ) { - dtype = arguments[ nargs ]; - nargs -= 1; - } else { - dtype = DEFAULT_DTYPE; - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '00L2k', dtype ) ); - } - // At this point, we've resolved the output array data type, and now we can actually create the output array... - if ( dtype === 'generic' ) { - arg = arguments[ 0 ]; - if ( nargs === 0 ) { - if ( isNonNegativeInteger( arg ) ) { - len = arg; - } else if ( isCollection( arg ) ) { - len = arg.length; - } - if ( len !== void 0 ) { - return filledArray( len, clbk, thisArg ); - } - if ( isArrayBuffer( arg ) ) { - throw new Error( format( '00L04' ) ); - } - if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( '00L2l', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00L2m', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00L2m', arg ) ); - } - return filledArrayIterator( arg, clbk, thisArg ); - } - throw new TypeError( format( '00L2m', arg ) ); - } else if ( isArrayBuffer( arg ) ) { - throw new Error( format( '00L04' ) ); - } - throw new TypeError( format( '00L2m', arg ) ); - } - if ( nargs === 0 ) { // length || array-like || ArrayBuffer || iterable - arg = arguments[ 0 ]; - if ( isCollection( arg ) ) { - arr = new ctor( arg.length ); - } else if ( isArrayBuffer( arg ) ) { - arr = new ctor( arg ); - } else if ( isNonNegativeInteger( arg ) ) { - arr = new ctor( arg ); - } else if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( '00L2l', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00L2m', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00L2m', arg ) ); - } - arr = new ctor( iterLength( arg ) ); - } else { - throw new TypeError( format( '00L2m', arg ) ); - } - } else if ( nargs === 1 ) { - arr = new ctor( arguments[0], arguments[1] ); // (ArrayBuffer, byteOffset) - } else { - arr = new ctor( arguments[0], arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset, length) - } - if ( arr.length > 0 ) { - if ( /^complex/.test( dtype ) ) { - filledAccessors( arr, clbk, thisArg ); - } else { - gfillBy( arr.length, arr, 1, callback ); - } - } - return arr; - - /** - * Callback which wraps a provided callback and is invoked for each array element. - * - * @private - * @param {*} value - element value - * @param {NonNegativeInteger} aidx - array index - * @param {NonNegativeInteger} sidx - strided index - * @param {Collection} array - input array/collection - * @returns {*} callback return value - */ - function callback( value, aidx ) { - return clbk.call( thisArg, aidx ); - } -} - - -// EXPORTS // - -module.exports = filledarrayBy; diff --git a/package.json b/package.json index 6511a88..498622b 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.2", "description": "Create a filled array according to a provided callback function.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,69 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-filled-by": "^0.0.x", - "@stdlib/array-ctors": "^0.0.x", - "@stdlib/assert-has-iterator-symbol-support": "^0.0.x", - "@stdlib/assert-is-arraybuffer": "^0.0.x", - "@stdlib/assert-is-collection": "^0.0.x", - "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/assert-is-nonnegative-integer": "^0.0.x", - "@stdlib/assert-is-object": "^0.0.x", - "@stdlib/assert-is-string": "^0.0.x", - "@stdlib/blas-ext-base-gfill-by": "^0.0.x", - "@stdlib/iter-length": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x", - "@stdlib/symbol-iterator": "^0.0.x", - "@stdlib/types": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-buffer": "^0.0.x", - "@stdlib/array-complex128": "^0.0.x", - "@stdlib/array-complex64": "^0.0.x", - "@stdlib/array-float32": "^0.0.x", - "@stdlib/array-float64": "^0.0.x", - "@stdlib/array-int16": "^0.0.x", - "@stdlib/array-int32": "^0.0.x", - "@stdlib/array-int8": "^0.0.x", - "@stdlib/array-typed-real-dtypes": "^0.0.x", - "@stdlib/array-uint16": "^0.0.x", - "@stdlib/array-uint32": "^0.0.x", - "@stdlib/array-uint8": "^0.0.x", - "@stdlib/array-uint8c": "^0.0.x", - "@stdlib/assert-instance-of": "^0.0.x", - "@stdlib/assert-is-array": "^0.0.x", - "@stdlib/assert-is-typed-array": "^0.0.x", - "@stdlib/assert-is-typed-array-like": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/complex-float32": "^0.0.x", - "@stdlib/complex-float64": "^0.0.x", - "@stdlib/iter-constant": "^0.0.x", - "@stdlib/math-base-special-pow": "^0.0.x", - "@stdlib/random-base-discrete-uniform": "^0.0.x", - "@stdlib/strided-base-reinterpret-complex128": "^0.0.x", - "@stdlib/strided-base-reinterpret-complex64": "^0.0.x", - "@stdlib/utils-constant-function": "^0.0.x", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..2ce5ced --- /dev/null +++ b/stats.html @@ -0,0 +1,2689 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index b55aa4a..0000000 --- a/test/test.js +++ /dev/null @@ -1,4248 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 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. -*/ - -/* eslint-disable max-len */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -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 ArrayBuffer = require( '@stdlib/array-buffer' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var iterConstant = require( '@stdlib/iter-constant' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var filledarrayBy = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': !hasIteratorSymbolSupport() -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof filledarrayBy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if only provided callback arguments', function test( t ) { - t.throws( clbk1, TypeError, 'throws an error' ); - t.throws( clbk2, TypeError, 'throws an error' ); - t.throws( clbk3, TypeError, 'throws an error' ); - t.end(); - - function clbk1() { - filledarrayBy( constantFunction( 1.0 ) ); - } - - function clbk2() { - filledarrayBy( constantFunction( 1.0 ), {} ); - } - - function clbk3() { - filledarrayBy( constantFunction( 1.0 ), constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (only argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (typed array; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (array-like object)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (array-like object; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 8 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 8 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, 1, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (iterator)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( iterConstant( 1.0 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (iterator; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( iterConstant( 1.0 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if only provided data type and callback arguments', function test( t ) { - t.throws( clbk1, TypeError, 'throws an error' ); - t.throws( clbk2, TypeError, 'throws an error' ); - t.throws( clbk3, TypeError, 'throws an error' ); - t.end(); - - function clbk1() { - filledarrayBy( 'float64', constantFunction( 1.0 ) ); - } - - function clbk2() { - filledarrayBy( 'float64', constantFunction( 1.0 ), {} ); - } - - function clbk3() { - filledarrayBy( 'float64', constantFunction( 1.0 ), constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (array-like object)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (array-like object; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, 1, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, 1, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (no iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (no iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (non-function iterator symbol property)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (non-function iterator symbol property; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (`next` property is not a function)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ) ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (`next` property is not a function; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ), {} ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (no iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (no iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (non-function iterator symbol property)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (non-function iterator symbol property; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (`next` property is not a function)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ) ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (`next` property is not a function; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ), {} ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 1, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 1, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function returns a filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - arr = filledarrayBy(); - - t.strictEqual( instanceOf( arr, Float64Array ), 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=float64)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - arr = filledarrayBy( 'float64' ); - - t.strictEqual( instanceOf( arr, Float64Array ), 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=float32)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( 0 ); - arr = filledarrayBy( 'float32' ); - - t.strictEqual( instanceOf( arr, Float32Array ), 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; - - expected = new Complex128Array( 0 ); - arr = filledarrayBy( 'complex128' ); - - t.strictEqual( instanceOf( arr, Complex128Array ), 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=complex64)', function test( t ) { - var expected; - var arr; - - expected = new Complex64Array( 0 ); - arr = filledarrayBy( 'complex64' ); - - t.strictEqual( instanceOf( arr, Complex64Array ), 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=int32)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( 0 ); - arr = filledarrayBy( 'int32' ); - - t.strictEqual( instanceOf( arr, Int32Array ), 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=uint32)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( 0 ); - arr = filledarrayBy( 'uint32' ); - - t.strictEqual( instanceOf( arr, Uint32Array ), 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=int16)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( 0 ); - arr = filledarrayBy( 'int16' ); - - t.strictEqual( instanceOf( arr, Int16Array ), 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=uint16)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( 0 ); - arr = filledarrayBy( 'uint16' ); - - t.strictEqual( instanceOf( arr, Uint16Array ), 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=int8)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( 0 ); - arr = filledarrayBy( 'int8' ); - - t.strictEqual( instanceOf( arr, Int8Array ), 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=uint8)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( 0 ); - arr = filledarrayBy( 'uint8' ); - - t.strictEqual( instanceOf( arr, Uint8Array ), 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=uint8c)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( 0 ); - arr = filledarrayBy( 'uint8c' ); - - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), 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=generic)', function test( t ) { - var expected; - var arr; - - expected = []; - arr = filledarrayBy( 'generic' ); - - t.strictEqual( instanceOf( arr, Array ), 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 (default, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, length=0)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array(); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 0, clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, clbk, ctx ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (default, length; thisArg=function)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, clbk, context ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this(); // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } - - function context() { - ctx.count += 1; - } -}); - -tape( 'the function returns a filled array (dtype=float64, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, 'float64', clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, length; thisArg=function)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, 'float64', clbk, context ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this(); // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } - - function context() { - ctx.count += 1; - } -}); - -tape( 'the function returns a filled array (dtype=float32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, 'float32', clbk ); - - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex128, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = filledarrayBy( 5, 'complex128', clbk ); - - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = filledarrayBy( 5, 'complex64', clbk ); - - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int32Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int32', clbk ); - - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint32Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint32', clbk ); - - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int16Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int16', clbk ); - - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint16', clbk ); - - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int8Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int8', clbk ); - - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint8', clbk ); - - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint8c', clbk ); - - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = [ 1, 1, 1, 1, 1 ]; - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'generic', clbk ); - - t.strictEqual( instanceOf( arr, Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex128, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = [ 1.0, 2.0 ]; - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = [ 1.0, 2.0 ]; - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int32', clbk ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, typed array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, typed array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex128, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = new Float64Array( [ 1.0, 2.0 ] ); - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = new Float64Array( [ 1.0, 2.0 ] ); - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (default, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex128, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer, byteoffset; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer, byteoffset; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, 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; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 48 ); - out = filledarrayBy( buf, 16, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 24 ); - out = filledarrayBy( buf, 8, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int32', clbk ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint8c', clbk ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, 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; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 64 ); - out = filledarrayBy( buf, 16, 2, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset, length)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 1, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 1, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled array (default, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, iterator; thisArg)', opts, function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - ctx = { - 'count': 0 - }; - indices = []; - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, iterator; thisArg)', opts, function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - ctx = { - 'count': 0 - }; - indices = []; - out = filledarrayBy( arr, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex128, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = iterConstant( new Complex128( 3.0, 3.0 ), { - 'iter': 2 - }); - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = iterConstant( new Complex64( 3.0, 3.0 ), { - 'iter': 2 - }); - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); From 28618f45cf76416a557ec27add4e9f42a4439171 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Nov 2022 04:06:43 +0000 Subject: [PATCH 020/117] Transform error messages --- lib/main.js | 38 +++++++++++++++++++------------------- package.json | 2 +- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/lib/main.js b/lib/main.js index d27b055..d6fbe5e 100644 --- a/lib/main.js +++ b/lib/main.js @@ -32,7 +32,7 @@ var filledArray = require( '@stdlib/array-base-filled-by' ); var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); var iterLength = require( '@stdlib/iter-length' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -263,18 +263,18 @@ function filledarrayBy() { if ( isString( dtype ) ) { // Invoking this function with arguments `f( dtype, clbk[, thisArg] )` is not allowed (otherwise, we'd need to also allow `f( clbk[, thisArg] )`)... if ( nargs > 1 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format( '00L05' ) ); } ctor = ctors( dtype ); if ( ctor === null ) { - throw new TypeError( format( 'invalid argument. Must provide a recognized data type. Value: `%s`.', dtype ) ); + throw new TypeError( format( '00L2k', dtype ) ); } // Return an empty array having the specified dtype: return new ctor( 0 ); } // For all other supported invocations, we need at least two arguments... if ( nargs < 2 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format( '00L05' ) ); } // At this point, we need to do some argument juggling... nargs -= 1; // henceforth, the number of available arguments is `nargs+1` @@ -289,7 +289,7 @@ function filledarrayBy() { // Check if we were provided only a callback and a "this" context.. if ( nargs === 0 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format( '00L05' ) ); } } else { // "this" context is left undefined... @@ -302,12 +302,12 @@ function filledarrayBy() { nargs -= 1; clbk = arguments[ nargs ]; if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '00L2n', clbk ) ); } } // If were were only provided 2 arguments and the last argument was not a function, we've been provided an insufficient number of arguments... else { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format( '00L05' ) ); } // Now that we've processed the callback arguments, let's continue working backward to see if we've been provided a `dtype` argument... nargs -= 1; @@ -319,7 +319,7 @@ function filledarrayBy() { } ctor = ctors( dtype ); if ( ctor === null ) { - throw new TypeError( format( 'invalid argument. Must provide a recognized data type. Value: `%s`.', dtype ) ); + throw new TypeError( format( '00L2k', dtype ) ); } // At this point, we've resolved the output array data type, and now we can actually create the output array... if ( dtype === 'generic' ) { @@ -334,26 +334,26 @@ function filledarrayBy() { return filledArray( len, clbk, thisArg ); } if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format( '00L04' ) ); } if ( isObject( arg ) ) { if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.', arg ) ); + throw new TypeError( format( '00L2l', arg ) ); } if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00L2m', arg ) ); } arg = arg[ ITERATOR_SYMBOL ](); if ( !isFunction( arg.next ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00L2m', arg ) ); } return filledArrayIterator( arg, clbk, thisArg ); } - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00L2m', arg ) ); } else if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format( '00L04' ) ); } - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00L2m', arg ) ); } if ( nargs === 0 ) { // length || array-like || ArrayBuffer || iterable arg = arguments[ 0 ]; @@ -365,18 +365,18 @@ function filledarrayBy() { arr = new ctor( arg ); } else if ( isObject( arg ) ) { if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.', arg ) ); + throw new TypeError( format( '00L2l', arg ) ); } if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00L2m', arg ) ); } arg = arg[ ITERATOR_SYMBOL ](); if ( !isFunction( arg.next ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00L2m', arg ) ); } arr = new ctor( iterLength( arg ) ); } else { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00L2m', arg ) ); } } else if ( nargs === 1 ) { arr = new ctor( arguments[0], arguments[1] ); // (ArrayBuffer, byteOffset) diff --git a/package.json b/package.json index b974a7b..6511a88 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "@stdlib/assert-is-string": "^0.0.x", "@stdlib/blas-ext-base-gfill-by": "^0.0.x", "@stdlib/iter-length": "^0.0.x", - "@stdlib/string-format": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x", "@stdlib/symbol-iterator": "^0.0.x", "@stdlib/types": "^0.0.x" }, From 35f08e342a480befbd3db183578aee3acf0638cc Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Nov 2022 15:18:00 +0000 Subject: [PATCH 021/117] Remove files --- index.d.ts | 427 -------- index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 3121 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 2156674..0000000 --- a/index.d.ts +++ /dev/null @@ -1,427 +0,0 @@ -/* -* @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. -*/ - -// TypeScript Version: 2.0 - -/// - -import { RealOrComplexTypedArray, DataType } from '@stdlib/types/array'; -import { Collection } from '@stdlib/types/object'; -import { IterableIterator } from '@stdlib/types/iter'; - -/** -* Array or typed array. -*/ -type ArrayOrTypedArray = Array | RealOrComplexTypedArray; - -/** -* Nullary callback function. -* -* @returns fill value -*/ -type Nullary = () => any; - -/** -* Unary callback function. -* -* @param i - current array index -* @returns fill value -*/ -type Unary = ( i: number ) => any; - -/** -* Callback function. -* -* @param i - current array index -* @returns fill value -*/ -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 -* -* @example -* var arr = filledarrayBy(); -* // returns -* -* @example -* var arr = filledarrayBy( 'float32' ); -* // returns -*/ -declare function filledarrayBy( dtype?: DataType ): ArrayOrTypedArray; // tslint:disable-line:unified-signatures - -/** -* Creates a filled array according to a provided callback function and having a specified `length`. -* -* @param length - array length -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* -* var arr = filledarrayBy( 5, constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( length: number, clbk: Callback, thisArg?: any ): ArrayOrTypedArray; // tslint:disable-line:max-line-length unified-signatures - -/** -* 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 -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* -* var arr = filledarrayBy( 5, 'float64', constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( length: number, dtype: DataType, clbk: Callback, thisArg?: any ): ArrayOrTypedArray; // tslint:disable-line:max-line-length unified-signatures - -/** -* Creates a filled array from another `array` according to a provided callback function. -* -* @param array - typed array or array-like object -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* -* 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; // tslint:disable-line:max-line-length 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 -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* -* 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; // tslint:disable-line:max-line-length unified-signatures - -/** -* Creates a filled array from an iterable according to a callback function. -* -* @param iterable - iterable -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* var iterConstant = require( `@stdlib/iter/constant` ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarrayBy( it, constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( iterable: IterableIterator, callback: Callback, thisArg?: any ): ArrayOrTypedArray; // tslint:disable-line:max-line-length 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 -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* var iterConstant = require( `@stdlib/iter/constant` ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* 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; // tslint:disable-line:max-line-length unified-signatures - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; // tslint:disable-line:max-line-length - -/** -* 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. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; // tslint:disable-line:max-line-length unified-signatures - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; // tslint:disable-line:max-line-length - -/** -* 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. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; // tslint:disable-line:max-line-length unified-signatures - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; // tslint:disable-line:max-line-length 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. -* -* @param buffer - `ArrayBuffer` -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; // tslint:disable-line:max-line-length unified-signatures - - -// EXPORTS // - -export = filledarrayBy; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index ce0d7c1..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-ctors@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill-by@v0.0.10-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled-by@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";var w=d();function j(r,e,t){var s,i;for(s=[],i=-1;!r.next().done;)i+=1,s.push(e.call(t,i));return s}function a(r,e,t){var s;for(s=0;s1)throw new TypeError(p("00L05"));if(null===(b=o(g)))throw new TypeError(p("00L2k",g));return new b(0)}if(c<2)throw new TypeError(p("00L05"));if(n(arguments[c-=1]))if(n(arguments[c-1])){if(d=arguments[c],y=arguments[c-=1],0===c)throw new TypeError(p("00L05"))}else y=arguments[c];else{if(!(c>=2))throw new TypeError(p("00L05"));if(d=arguments[c],!n(y=arguments[c-=1]))throw new TypeError(p("00L2n",y))}if((c-=1)>=0&&r(arguments[c])?(g=arguments[c],c-=1):g="float64",null===(b=o(g)))throw new TypeError(p("00L2k",g));if("generic"===g){if(x=arguments[0],0===c){if(e(x)?u=x:t(x)&&(u=x.length),void 0!==u)return m(u,y,d);if(s(x))throw new Error(p("00L04"));if(i(x)){if(!1===w)throw new TypeError(p("00L2l",x));if(!n(x[f]))throw new TypeError(p("00L2m",x));if(x=x[f](),!n(x.next))throw new TypeError(p("00L2m",x));return j(x,y,d)}throw new TypeError(p("00L2m",x))}if(s(x))throw new Error(p("00L04"));throw new TypeError(p("00L2m",x))}if(0===c)if(t(x=arguments[0]))v=new b(x.length);else if(s(x))v=new b(x);else if(e(x))v=new b(x);else{if(!i(x))throw new TypeError(p("00L2m",x));if(!1===w)throw new TypeError(p("00L2l",x));if(!n(x[f]))throw new TypeError(p("00L2m",x));if(x=x[f](),!n(x.next))throw new TypeError(p("00L2m",x));v=new b(h(x))}else v=1===c?new b(arguments[0],arguments[1]):new b(arguments[0],arguments[1],arguments[2]);return v.length>0&&(/^complex/.test(g)?a(v,y,d):l(v.length,v,1,E)),v;function E(r,e){return y.call(d,e)}}export{c as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index bc9d089..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.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\nimport { isPrimitive as isString } from '@stdlib/assert-is-string' ;\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer' ;\nimport isCollection from '@stdlib/assert-is-collection' ;\nimport isArrayBuffer from '@stdlib/assert-is-arraybuffer' ;\nimport isObject from '@stdlib/assert-is-object' ;\nimport isFunction from '@stdlib/assert-is-function' ;\nimport ctors from '@stdlib/array-ctors' ;\nimport gfillBy from '@stdlib/blas-ext-base-gfill-by' ;\nimport filledArray from '@stdlib/array-base-filled-by' ;\nimport hasIteratorSymbolSupport from '@stdlib/assert-has-iterator-symbol-support' ;\nimport ITERATOR_SYMBOL from '@stdlib/symbol-iterator' ;\nimport iterLength from '@stdlib/iter-length' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\n\n\n// VARIABLES //\n\nvar HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport();\nvar DEFAULT_DTYPE = 'float64';\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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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( format( '00L05' ) );\n\t\t}\n\t\tctor = ctors( dtype );\n\t\tif ( ctor === null ) {\n\t\t\tthrow new TypeError( format( '00L2k', 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( format( '00L05' ) );\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( format( '00L05' ) );\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( '00L2n', 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( format( '00L05' ) );\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( '00L2k', 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( format( '00L04' ) );\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( '00L2l', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00L2m', 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( '00L2m', 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( '00L2m', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format( '00L04' ) );\n\t\t}\n\t\tthrow new TypeError( format( '00L2m', 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( '00L2l', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00L2m', 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( '00L2m', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00L2m', 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\nexport default filledarrayBy;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","filledArrayIterator","it","clbk","thisArg","arr","i","next","done","push","call","filledAccessors","length","set","filledarrayBy","nargs","dtype","ctor","len","arg","arguments","ctors","isString","TypeError","format","isFunction","isNonNegativeInteger","isCollection","filledArray","isArrayBuffer","Error","isObject","ITERATOR_SYMBOL","iterLength","test","gfillBy","callback","value","aidx"],"mappings":";;gqCAuCA,IAAIA,EAAsBC,IAe1B,SAASC,EAAqBC,EAAIC,EAAMC,GACvC,IAAIC,EACAC,EAKJ,IAFAD,EAAM,GACNC,GAAK,GAEAJ,EAAGK,OACAC,MAGPF,GAAK,EACLD,EAAII,KAAMN,EAAKO,KAAMN,EAASE,IAE/B,OAAOD,EAYR,SAASM,EAAiBN,EAAKF,EAAMC,GACpC,IAAIE,EACJ,IAAMA,EAAI,EAAGA,EAAID,EAAIO,OAAQN,IAC5BD,EAAIQ,IAAKV,EAAKO,KAAMN,EAASE,GAAKA,GAEnC,OAAOD,EA6JR,SAASS,IACR,IAAIV,EACAW,EACAC,EACAb,EACAc,EACAZ,EACAa,EACAC,EAKJ,GAAe,KAHfJ,EAAQK,UAAUR,QAKjB,OAAO,IADPK,EAAOI,EAzNW,YA0ND,GAIlB,GAAKC,EADLN,EAAQI,UAAW,IACM,CAExB,GAAKL,EAAQ,EACZ,MAAM,IAAIQ,UAAWC,EAAQ,UAG9B,GAAc,QADdP,EAAOI,EAAOL,IAEb,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAGvC,OAAO,IAAIC,EAAM,GAGlB,GAAKF,EAAQ,EACZ,MAAM,IAAIQ,UAAWC,EAAQ,UAM9B,GAAKC,EAAYL,UAHjBL,GAAS,IAKR,GAAKU,EAAYL,UAAWL,EAAM,KAMjC,GALAX,EAAUgB,UAAWL,GAErBZ,EAAOiB,UADPL,GAAS,GAIM,IAAVA,EACJ,MAAM,IAAIQ,UAAWC,EAAQ,eAI9BrB,EAAOiB,UAAWL,OAIf,MAAKA,GAAS,GAUlB,MAAM,IAAIQ,UAAWC,EAAQ,UAN7B,GAHApB,EAAUgB,UAAWL,IAGfU,EADNtB,EAAOiB,UADPL,GAAS,IAGR,MAAM,IAAIQ,UAAWC,EAAQ,QAASrB,IAgBxC,IARAY,GAAS,IACK,GAAKO,EAAUF,UAAWL,KACvCC,EAAQI,UAAWL,GACnBA,GAAS,GAETC,EArRkB,UAwRL,QADdC,EAAOI,EAAOL,IAEb,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAGvC,GAAe,YAAVA,EAAsB,CAE1B,GADAG,EAAMC,UAAW,GACF,IAAVL,EAAc,CAMlB,GALKW,EAAsBP,GAC1BD,EAAMC,EACKQ,EAAcR,KACzBD,EAAMC,EAAIP,aAEE,IAARM,EACJ,OAAOU,EAAaV,EAAKf,EAAMC,GAEhC,GAAKyB,EAAeV,GACnB,MAAM,IAAIW,MAAON,EAAQ,UAE1B,GAAKO,EAAUZ,GAAQ,CACtB,IAA6B,IAAxBpB,EACJ,MAAM,IAAIwB,UAAWC,EAAQ,QAASL,IAEvC,IAAMM,EAAYN,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASL,IAGvC,GADAA,EAAMA,EAAKa,MACLP,EAAYN,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,QAASL,IAEvC,OAAOlB,EAAqBkB,EAAKhB,EAAMC,GAExC,MAAM,IAAImB,UAAWC,EAAQ,QAASL,IAChC,GAAKU,EAAeV,GAC1B,MAAM,IAAIW,MAAON,EAAQ,UAE1B,MAAM,IAAID,UAAWC,EAAQ,QAASL,IAEvC,GAAe,IAAVJ,EAEJ,GAAKY,EADLR,EAAMC,UAAW,IAEhBf,EAAM,IAAIY,EAAME,EAAIP,aACd,GAAKiB,EAAeV,GAC1Bd,EAAM,IAAIY,EAAME,QACV,GAAKO,EAAsBP,GACjCd,EAAM,IAAIY,EAAME,OACV,KAAKY,EAAUZ,GAarB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAZtC,IAA6B,IAAxBpB,EACJ,MAAM,IAAIwB,UAAWC,EAAQ,QAASL,IAEvC,IAAMM,EAAYN,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASL,IAGvC,GADAA,EAAMA,EAAKa,MACLP,EAAYN,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,QAASL,IAEvCd,EAAM,IAAIY,EAAMgB,EAAYd,SAK7Bd,EADqB,IAAVU,EACL,IAAIE,EAAMG,UAAU,GAAIA,UAAU,IAElC,IAAIH,EAAMG,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKf,EAAIO,OAAS,IACZ,WAAWsB,KAAMlB,GACrBL,EAAiBN,EAAKF,EAAMC,GAE5B+B,EAAS9B,EAAIO,OAAQP,EAAK,EAAG+B,IAGxB/B,EAYP,SAAS+B,EAAUC,EAAOC,GACzB,OAAOnC,EAAKO,KAAMN,EAASkC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 2ce5ced..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From dd472cb89b9bdb86f8a21b3f71d212e40e475803 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Nov 2022 15:19:11 +0000 Subject: [PATCH 022/117] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 760 ---- .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 178 - .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 41 +- benchmark/benchmark.js | 319 -- benchmark/benchmark.length.complex128.js | 98 - benchmark/benchmark.length.complex64.js | 98 - benchmark/benchmark.length.float32.js | 97 - benchmark/benchmark.length.float64.js | 97 - benchmark/benchmark.length.generic.js | 97 - benchmark/benchmark.length.int16.js | 97 - benchmark/benchmark.length.int32.js | 97 - benchmark/benchmark.length.int8.js | 97 - benchmark/benchmark.length.uint16.js | 97 - benchmark/benchmark.length.uint32.js | 97 - benchmark/benchmark.length.uint8.js | 97 - benchmark/benchmark.length.uint8c.js | 97 - branches.md | 53 - docs/repl.txt | 174 - docs/types/test.ts | 606 --- examples/index.js | 37 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 192 - lib/main.js | 413 -- package.json | 90 +- stats.html | 4044 ++++++++++++++++++++ test/test.js | 4248 --------------------- 49 files changed, 4069 insertions(+), 10225 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.length.complex128.js delete mode 100644 benchmark/benchmark.length.complex64.js delete mode 100644 benchmark/benchmark.length.float32.js delete mode 100644 benchmark/benchmark.length.float64.js delete mode 100644 benchmark/benchmark.length.generic.js delete mode 100644 benchmark/benchmark.length.int16.js delete mode 100644 benchmark/benchmark.length.int32.js delete mode 100644 benchmark/benchmark.length.int8.js delete mode 100644 benchmark/benchmark.length.uint16.js delete mode 100644 benchmark/benchmark.length.uint32.js delete mode 100644 benchmark/benchmark.length.uint8.js delete mode 100644 benchmark/benchmark.length.uint8c.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 5048fde..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-11-01T02:04:41.927Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 8be0b82..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 06a9a75..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index a00dbe5..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.11.0 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index df9d9d7..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 7902a7d..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 16e02e6..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '42 6 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 9113bfe..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,760 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -273,7 +266,7 @@ for ( i = 0; i < dt.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 421b48e..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,319 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); -var isArray = require( '@stdlib/assert-is-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var pkg = require( './../package.json' ).name; -var filledarrayBy = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 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=float64', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'float64', 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=float32', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'float32', 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; - var i; - - clbk = constantFunction( new Complex128( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'complex128', 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=complex64', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( new Complex64( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'complex64', 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=int32', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int32', 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=uint32', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint32', 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=int16', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int16', 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=uint16', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint16', 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=int8', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int8', 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=uint8', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint8', 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=uint8c', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint8c', 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=generic', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'generic', clbk ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.length.complex128.js b/benchmark/benchmark.length.complex128.js deleted file mode 100644 index 671de86..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var Complex128 = require( '@stdlib/complex-float64' ); -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( new Complex128( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'complex128', 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=complex128,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.complex64.js b/benchmark/benchmark.length.complex64.js deleted file mode 100644 index 52da4e3..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var Complex64 = require( '@stdlib/complex-float32' ); -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( new Complex64( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'complex64', 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=complex64,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.float32.js b/benchmark/benchmark.length.float32.js deleted file mode 100644 index 9b4ef9b..0000000 --- a/benchmark/benchmark.length.float32.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'float32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=float32,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.float64.js b/benchmark/benchmark.length.float64.js deleted file mode 100644 index 66cb6b6..0000000 --- a/benchmark/benchmark.length.float64.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'float64', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=float64,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.generic.js b/benchmark/benchmark.length.generic.js deleted file mode 100644 index 5194c1b..0000000 --- a/benchmark/benchmark.length.generic.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isArray = require( '@stdlib/assert-is-array' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'generic', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isArray( 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=generic,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int16.js b/benchmark/benchmark.length.int16.js deleted file mode 100644 index 6669b28..0000000 --- a/benchmark/benchmark.length.int16.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int16', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=int16,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int32.js b/benchmark/benchmark.length.int32.js deleted file mode 100644 index e9c5c88..0000000 --- a/benchmark/benchmark.length.int32.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=int32,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int8.js b/benchmark/benchmark.length.int8.js deleted file mode 100644 index 14bbadf..0000000 --- a/benchmark/benchmark.length.int8.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int8', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=int8,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint16.js b/benchmark/benchmark.length.uint16.js deleted file mode 100644 index d03b23e..0000000 --- a/benchmark/benchmark.length.uint16.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint16', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint16,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint32.js b/benchmark/benchmark.length.uint32.js deleted file mode 100644 index 1382134..0000000 --- a/benchmark/benchmark.length.uint32.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint32,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint8.js b/benchmark/benchmark.length.uint8.js deleted file mode 100644 index c135d6c..0000000 --- a/benchmark/benchmark.length.uint8.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint8', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint8,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint8c.js b/benchmark/benchmark.length.uint8c.js deleted file mode 100644 index 2f7523a..0000000 --- a/benchmark/benchmark.length.uint8c.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint8c', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint8c,len='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 18101fd..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by" -click B href "https://github.com/stdlib-js/array-filled-by/tree/main" -click C href "https://github.com/stdlib-js/array-filled-by/tree/production" -click D href "https://github.com/stdlib-js/array-filled-by/tree/esm" -click E href "https://github.com/stdlib-js/array-filled-by/tree/deno" -click F href "https://github.com/stdlib-js/array-filled-by/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by -[production-url]: https://github.com/stdlib-js/array-filled-by/tree/production -[deno-url]: https://github.com/stdlib-js/array-filled-by/tree/deno -[umd-url]: https://github.com/stdlib-js/array-filled-by/tree/umd -[esm-url]: https://github.com/stdlib-js/array-filled-by/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 5a68984..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,174 +0,0 @@ - -{{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) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr = {{alias}}() - - > arr = {{alias}}( 'float32' ) - - - -{{alias}}( length[, dtype], clbk[, thisArg] ) - Returns a filled array according to a provided callback function and having - a specified length. - - Parameters - ---------- - length: integer - Array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > function clbk() { return 1.0; }; - > var arr = {{alias}}( 5, clbk ) - [ 1.0, 1.0, 1.0, 1.0, 1.0 ] - > arr = {{alias}}( 5, 'int32', clbk ) - [ 1, 1, 1, 1, 1 ] - - -{{alias}}( array[, dtype], clbk[, thisArg] ) - Creates a filled array from another array (or array-like object) according - to a provided callback function. - - Parameters - ---------- - array: ArrayLikeObject - Array from which to generate another array. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias}}( [ 0.5, 0.5, 0.5 ], {{alias:@stdlib/utils/constant-function}}( 2.0 ) ) - [ 2.0, 2.0, 2.0 ] - > var arr2 = {{alias}}( arr1, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( iterable[, dtype], clbk[, thisArg] ) - Creates a filled array from an iterable according to a provided callback - function. - - Parameters - ---------- - iterable: Iterable - Iterable from which to generate an array. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias:@stdlib/iter/constant}}( 3.0, {'iter': 3} ); - > var arr2 = {{alias}}( arr1, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( buffer[, byteOffset[, length]][, dtype], clbk[, thisArg] ) - Returns a filled typed array view of an ArrayBuffer according to a provided - callback function. - - The 'generic' array data type is *not* supported. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( buf, 0, 4, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0, 1.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 394ac49..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,606 +0,0 @@ -/* -* @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. -*/ - -/// - -import { IterableIterator } from '@stdlib/types/iter'; -import filledarrayBy = require( './index' ); - - -/** -* Returns an iterator protocol-compliant object. -* -* @returns iterator protocol-compliant object -*/ -function iterator(): IterableIterator { - const obj: IterableIterator = { - [Symbol.iterator]: iterator, - 'next': next - }; - return obj; -} - -/** -* Implements the iterator protocol `next` method. -* -* @returns iterator protocol-compliant object -*/ -function next(): any { - return { - 'value': 1.0, - 'done': false - }; -} - -/** -* Callback function. -* -* @param i - current array index -* @returns return value -*/ -function clbk( i: number ): number { - return i; -} - - -// TESTS // - -// The function returns an array or typed array... -{ - filledarrayBy(); // $ExpectType ArrayOrTypedArray - filledarrayBy( 'float32' ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( 10, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( 10, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( 10, 'int32', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( 10, 'int32', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const x = new Float64Array( 10 ); - filledarrayBy( x, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( x, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( x, 'uint8', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( x, 'uint8', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const y = [ 2.0, 2.0, 2.0 ]; - filledarrayBy( y, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( y, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( y, 'float64', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( y, 'float64', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const it = iterator(); - filledarrayBy( it, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( it, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( it, 'uint8c', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( it, 'uint8c', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const buf = new ArrayBuffer( 32 ); - filledarrayBy( buf, clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 'uint32', clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 'uint32', clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 8, clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 8, clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 8, 'uint16', clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 8, 'uint16', clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 8, 2, clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 8, 2, clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 8, 2, 'int16', clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 8, 2, 'int16', clbk, {} ); // $ExpectType RealOrComplexTypedArray -} - -// The compiler throws an error if a callback function argument is not a function... -{ - filledarrayBy( 'float64', '5' ); // $ExpectError - filledarrayBy( 'float64', 1.0 ); // $ExpectError - filledarrayBy( 'float64', false ); // $ExpectError - filledarrayBy( 'float64', true ); // $ExpectError - filledarrayBy( 'float64', null ); // $ExpectError - filledarrayBy( 'float64', undefined ); // $ExpectError - filledarrayBy( 'float64', [] ); // $ExpectError - filledarrayBy( 'float64', {} ); // $ExpectError - - filledarrayBy( 'float64', '5', {} ); // $ExpectError - filledarrayBy( 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( 'float64', false, {} ); // $ExpectError - filledarrayBy( 'float64', true, {} ); // $ExpectError - filledarrayBy( 'float64', null, {} ); // $ExpectError - filledarrayBy( 'float64', undefined, {} ); // $ExpectError - filledarrayBy( 'float64', [], {} ); // $ExpectError - filledarrayBy( 'float64', {}, {} ); // $ExpectError - - filledarrayBy( 10, '5' ); // $ExpectError - filledarrayBy( 10, 1.0 ); // $ExpectError - filledarrayBy( 10, false ); // $ExpectError - filledarrayBy( 10, true ); // $ExpectError - filledarrayBy( 10, null ); // $ExpectError - filledarrayBy( 10, undefined ); // $ExpectError - filledarrayBy( 10, [] ); // $ExpectError - filledarrayBy( 10, {} ); // $ExpectError - - filledarrayBy( 10, '5', {} ); // $ExpectError - filledarrayBy( 10, 1.0, {} ); // $ExpectError - filledarrayBy( 10, false, {} ); // $ExpectError - filledarrayBy( 10, true, {} ); // $ExpectError - filledarrayBy( 10, null, {} ); // $ExpectError - filledarrayBy( 10, undefined, {} ); // $ExpectError - filledarrayBy( 10, [], {} ); // $ExpectError - filledarrayBy( 10, {}, {} ); // $ExpectError - - filledarrayBy( 10, 'float64', '5' ); // $ExpectError - filledarrayBy( 10, 'float64', 1.0 ); // $ExpectError - filledarrayBy( 10, 'float64', false ); // $ExpectError - filledarrayBy( 10, 'float64', true ); // $ExpectError - filledarrayBy( 10, 'float64', null ); // $ExpectError - filledarrayBy( 10, 'float64', undefined ); // $ExpectError - filledarrayBy( 10, 'float64', [] ); // $ExpectError - filledarrayBy( 10, 'float64', {} ); // $ExpectError - - filledarrayBy( 10, 'float64', '5', {} ); // $ExpectError - filledarrayBy( 10, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( 10, 'float64', false, {} ); // $ExpectError - filledarrayBy( 10, 'float64', true, {} ); // $ExpectError - filledarrayBy( 10, 'float64', null, {} ); // $ExpectError - filledarrayBy( 10, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( 10, 'float64', [], {} ); // $ExpectError - filledarrayBy( 10, 'float64', {}, {} ); // $ExpectError - - const x = new Float64Array( 10 ); - filledarrayBy( x, '5' ); // $ExpectError - filledarrayBy( x, 1.0 ); // $ExpectError - filledarrayBy( x, false ); // $ExpectError - filledarrayBy( x, true ); // $ExpectError - filledarrayBy( x, null ); // $ExpectError - filledarrayBy( x, undefined ); // $ExpectError - filledarrayBy( x, [] ); // $ExpectError - filledarrayBy( x, {} ); // $ExpectError - - filledarrayBy( x, '5', {} ); // $ExpectError - filledarrayBy( x, 1.0, {} ); // $ExpectError - filledarrayBy( x, false, {} ); // $ExpectError - filledarrayBy( x, true, {} ); // $ExpectError - filledarrayBy( x, null, {} ); // $ExpectError - filledarrayBy( x, undefined, {} ); // $ExpectError - filledarrayBy( x, [], {} ); // $ExpectError - filledarrayBy( x, {}, {} ); // $ExpectError - - filledarrayBy( x, 'float64', '5' ); // $ExpectError - filledarrayBy( x, 'float64', 1.0 ); // $ExpectError - filledarrayBy( x, 'float64', false ); // $ExpectError - filledarrayBy( x, 'float64', true ); // $ExpectError - filledarrayBy( x, 'float64', null ); // $ExpectError - filledarrayBy( x, 'float64', undefined ); // $ExpectError - filledarrayBy( x, 'float64', [] ); // $ExpectError - filledarrayBy( x, 'float64', {} ); // $ExpectError - - filledarrayBy( x, 'float64', '5', {} ); // $ExpectError - filledarrayBy( x, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( x, 'float64', false, {} ); // $ExpectError - filledarrayBy( x, 'float64', true, {} ); // $ExpectError - filledarrayBy( x, 'float64', null, {} ); // $ExpectError - filledarrayBy( x, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( x, 'float64', [], {} ); // $ExpectError - filledarrayBy( x, 'float64', {}, {} ); // $ExpectError - - const y = [ 2.0, 2.0, 2.0 ]; - filledarrayBy( y, '5' ); // $ExpectError - filledarrayBy( y, 1.0 ); // $ExpectError - filledarrayBy( y, false ); // $ExpectError - filledarrayBy( y, true ); // $ExpectError - filledarrayBy( y, null ); // $ExpectError - filledarrayBy( y, undefined ); // $ExpectError - filledarrayBy( y, [] ); // $ExpectError - filledarrayBy( y, {} ); // $ExpectError - - filledarrayBy( y, '5', {} ); // $ExpectError - filledarrayBy( y, 1.0, {} ); // $ExpectError - filledarrayBy( y, false, {} ); // $ExpectError - filledarrayBy( y, true, {} ); // $ExpectError - filledarrayBy( y, null, {} ); // $ExpectError - filledarrayBy( y, undefined, {} ); // $ExpectError - filledarrayBy( y, [], {} ); // $ExpectError - filledarrayBy( y, {}, {} ); // $ExpectError - - filledarrayBy( y, 'float64', '5' ); // $ExpectError - filledarrayBy( y, 'float64', 1.0 ); // $ExpectError - filledarrayBy( y, 'float64', false ); // $ExpectError - filledarrayBy( y, 'float64', true ); // $ExpectError - filledarrayBy( y, 'float64', null ); // $ExpectError - filledarrayBy( y, 'float64', undefined ); // $ExpectError - filledarrayBy( y, 'float64', [] ); // $ExpectError - filledarrayBy( y, 'float64', {} ); // $ExpectError - - filledarrayBy( y, 'float64', '5', {} ); // $ExpectError - filledarrayBy( y, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( y, 'float64', false, {} ); // $ExpectError - filledarrayBy( y, 'float64', true, {} ); // $ExpectError - filledarrayBy( y, 'float64', null, {} ); // $ExpectError - filledarrayBy( y, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( y, 'float64', [], {} ); // $ExpectError - filledarrayBy( y, 'float64', {}, {} ); // $ExpectError - - const it = iterator(); - filledarrayBy( it, '5' ); // $ExpectError - filledarrayBy( it, 1.0 ); // $ExpectError - filledarrayBy( it, false ); // $ExpectError - filledarrayBy( it, true ); // $ExpectError - filledarrayBy( it, null ); // $ExpectError - filledarrayBy( it, undefined ); // $ExpectError - filledarrayBy( it, [] ); // $ExpectError - filledarrayBy( it, {} ); // $ExpectError - - filledarrayBy( it, '5', {} ); // $ExpectError - filledarrayBy( it, 1.0, {} ); // $ExpectError - filledarrayBy( it, false, {} ); // $ExpectError - filledarrayBy( it, true, {} ); // $ExpectError - filledarrayBy( it, null, {} ); // $ExpectError - filledarrayBy( it, undefined, {} ); // $ExpectError - filledarrayBy( it, [], {} ); // $ExpectError - filledarrayBy( it, {}, {} ); // $ExpectError - - filledarrayBy( it, 'float64', '5' ); // $ExpectError - filledarrayBy( it, 'float64', 1.0 ); // $ExpectError - filledarrayBy( it, 'float64', false ); // $ExpectError - filledarrayBy( it, 'float64', true ); // $ExpectError - filledarrayBy( it, 'float64', null ); // $ExpectError - filledarrayBy( it, 'float64', undefined ); // $ExpectError - filledarrayBy( it, 'float64', [] ); // $ExpectError - filledarrayBy( it, 'float64', {} ); // $ExpectError - - filledarrayBy( it, 'float64', '5', {} ); // $ExpectError - filledarrayBy( it, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( it, 'float64', false, {} ); // $ExpectError - filledarrayBy( it, 'float64', true, {} ); // $ExpectError - filledarrayBy( it, 'float64', null, {} ); // $ExpectError - filledarrayBy( it, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( it, 'float64', [], {} ); // $ExpectError - filledarrayBy( it, 'float64', {}, {} ); // $ExpectError - - const buf = new ArrayBuffer( 32 ); - filledarrayBy( buf, '5' ); // $ExpectError - filledarrayBy( buf, 1.0 ); // $ExpectError - filledarrayBy( buf, false ); // $ExpectError - filledarrayBy( buf, true ); // $ExpectError - filledarrayBy( buf, null ); // $ExpectError - filledarrayBy( buf, undefined ); // $ExpectError - filledarrayBy( buf, [] ); // $ExpectError - filledarrayBy( buf, {} ); // $ExpectError - - filledarrayBy( buf, '5', {} ); // $ExpectError - filledarrayBy( buf, 1.0, {} ); // $ExpectError - filledarrayBy( buf, false, {} ); // $ExpectError - filledarrayBy( buf, true, {} ); // $ExpectError - filledarrayBy( buf, null, {} ); // $ExpectError - filledarrayBy( buf, undefined, {} ); // $ExpectError - filledarrayBy( buf, [], {} ); // $ExpectError - filledarrayBy( buf, {}, {} ); // $ExpectError - - filledarrayBy( buf, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 'float64', false ); // $ExpectError - filledarrayBy( buf, 'float64', true ); // $ExpectError - filledarrayBy( buf, 'float64', null ); // $ExpectError - filledarrayBy( buf, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 'float64', {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5' ); // $ExpectError - filledarrayBy( buf, 8, 1.0 ); // $ExpectError - filledarrayBy( buf, 8, false ); // $ExpectError - filledarrayBy( buf, 8, true ); // $ExpectError - filledarrayBy( buf, 8, null ); // $ExpectError - filledarrayBy( buf, 8, undefined ); // $ExpectError - filledarrayBy( buf, 8, [] ); // $ExpectError - filledarrayBy( buf, 8, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, false, {} ); // $ExpectError - filledarrayBy( buf, 8, true, {} ); // $ExpectError - filledarrayBy( buf, 8, null, {} ); // $ExpectError - filledarrayBy( buf, 8, undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, [], {} ); // $ExpectError - filledarrayBy( buf, 8, {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 8, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 'float64', false ); // $ExpectError - filledarrayBy( buf, 8, 'float64', true ); // $ExpectError - filledarrayBy( buf, 8, 'float64', null ); // $ExpectError - filledarrayBy( buf, 8, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 8, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 8, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 8, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, '5' ); // $ExpectError - filledarrayBy( buf, 8, 2, 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 2, false ); // $ExpectError - filledarrayBy( buf, 8, 2, true ); // $ExpectError - filledarrayBy( buf, 8, 2, null ); // $ExpectError - filledarrayBy( buf, 8, 2, undefined ); // $ExpectError - filledarrayBy( buf, 8, 2, [] ); // $ExpectError - filledarrayBy( buf, 8, 2, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, false, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, true, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, null, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, [], {} ); // $ExpectError - filledarrayBy( buf, 8, 2, {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', false ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', true ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', null ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', {}, {} ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid length, typed array, array-like object, `ArrayBuffer`, or iterable argument... -{ - filledarrayBy( false, clbk ); // $ExpectError - filledarrayBy( true, clbk ); // $ExpectError - filledarrayBy( null, clbk ); // $ExpectError - filledarrayBy( {}, clbk ); // $ExpectError - - filledarrayBy( false, clbk, {} ); // $ExpectError - filledarrayBy( true, clbk, {} ); // $ExpectError - filledarrayBy( null, clbk, {} ); // $ExpectError - filledarrayBy( {}, clbk, {} ); // $ExpectError - - filledarrayBy( false, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 'float64', clbk ); // $ExpectError - - filledarrayBy( false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, clbk ); // $ExpectError - filledarrayBy( 1.0, 8, clbk ); // $ExpectError - filledarrayBy( false, 8, clbk ); // $ExpectError - filledarrayBy( true, 8, clbk ); // $ExpectError - filledarrayBy( null, 8, clbk ); // $ExpectError - filledarrayBy( undefined, 8, clbk ); // $ExpectError - filledarrayBy( [], 8, clbk ); // $ExpectError - filledarrayBy( {}, 8, clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, clbk ); // $ExpectError - - filledarrayBy( '5', 8, clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, clbk, {} ); // $ExpectError - filledarrayBy( false, 8, clbk, {} ); // $ExpectError - filledarrayBy( true, 8, clbk, {} ); // $ExpectError - filledarrayBy( null, 8, clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, clbk, {} ); // $ExpectError - filledarrayBy( [], 8, clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 'float64', clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( false, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( [], 8, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 'float64', clbk ); // $ExpectError - - filledarrayBy( '5', 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 2, clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 2, clbk ); // $ExpectError - filledarrayBy( false, 8, 2, clbk ); // $ExpectError - filledarrayBy( true, 8, 2, clbk ); // $ExpectError - filledarrayBy( null, 8, 2, clbk ); // $ExpectError - filledarrayBy( undefined, 8, 2, clbk ); // $ExpectError - filledarrayBy( [], 8, 2, clbk ); // $ExpectError - filledarrayBy( {}, 8, 2, clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, clbk ); // $ExpectError - - filledarrayBy( '5', 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( false, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( [], 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, 'float64', clbk ); // $ExpectError - - filledarrayBy( '5', 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a byte offset argument which is not a number... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, false, clbk ); // $ExpectError - filledarrayBy( buf, true, clbk ); // $ExpectError - filledarrayBy( buf, null, clbk ); // $ExpectError - filledarrayBy( buf, [], clbk ); // $ExpectError - filledarrayBy( buf, {}, clbk ); // $ExpectError - - filledarrayBy( buf, false, clbk, {} ); // $ExpectError - filledarrayBy( buf, true, clbk, {} ); // $ExpectError - filledarrayBy( buf, null, clbk, {} ); // $ExpectError - filledarrayBy( buf, [], clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, clbk, {} ); // $ExpectError - - filledarrayBy( buf, '5', 'float64', clbk ); // $ExpectError - filledarrayBy( buf, false, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, true, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, null, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, [], 'float64', clbk ); // $ExpectError - filledarrayBy( buf, {}, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, '5', 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( buf, false, 2, clbk ); // $ExpectError - filledarrayBy( buf, true, 2, clbk ); // $ExpectError - filledarrayBy( buf, null, 2, clbk ); // $ExpectError - filledarrayBy( buf, [], 2, clbk ); // $ExpectError - filledarrayBy( buf, {}, 2, clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, clbk ); // $ExpectError - - filledarrayBy( buf, false, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, clbk, {} ); // $ExpectError - - filledarrayBy( buf, '5', 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, false, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, true, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, null, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, undefined, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, [], 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, {}, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, '5', 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, false, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, undefined, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a view length argument which is not a number... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, 8, false, clbk ); // $ExpectError - filledarrayBy( buf, 8, true, clbk ); // $ExpectError - filledarrayBy( buf, 8, null, clbk ); // $ExpectError - filledarrayBy( buf, 8, [], clbk ); // $ExpectError - filledarrayBy( buf, 8, {}, clbk ); // $ExpectError - - filledarrayBy( buf, 8, false, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, true, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, null, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, [], clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, {}, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, clbk, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5', 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, false, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, true, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, null, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, [], 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, {}, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, 8, '5', 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, [], 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, {}, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided too many arguments... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, 8, 2, 'float64', 1, clbk, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 997a381..0000000 --- a/examples/index.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ).factory; -var dtypes = require( '@stdlib/array-typed-real-dtypes' ); -var filledarrayBy = require( './../lib' ); - -// Create a pseudorandom number generator: -var rand = discreteUniform( 0, 100 ); - -// Get a list of array data types: -var dt = dtypes(); - -// Generate filled arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = filledarrayBy( 10, dt[ i ], rand ); - console.log( arr ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 3fc2784..2156674 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { RealOrComplexTypedArray, DataType } from '@stdlib/types/array'; import { Collection } from '@stdlib/types/object'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..ce0d7c1 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-ctors@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill-by@v0.0.10-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled-by@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";var w=d();function j(r,e,t){var s,i;for(s=[],i=-1;!r.next().done;)i+=1,s.push(e.call(t,i));return s}function a(r,e,t){var s;for(s=0;s1)throw new TypeError(p("00L05"));if(null===(b=o(g)))throw new TypeError(p("00L2k",g));return new b(0)}if(c<2)throw new TypeError(p("00L05"));if(n(arguments[c-=1]))if(n(arguments[c-1])){if(d=arguments[c],y=arguments[c-=1],0===c)throw new TypeError(p("00L05"))}else y=arguments[c];else{if(!(c>=2))throw new TypeError(p("00L05"));if(d=arguments[c],!n(y=arguments[c-=1]))throw new TypeError(p("00L2n",y))}if((c-=1)>=0&&r(arguments[c])?(g=arguments[c],c-=1):g="float64",null===(b=o(g)))throw new TypeError(p("00L2k",g));if("generic"===g){if(x=arguments[0],0===c){if(e(x)?u=x:t(x)&&(u=x.length),void 0!==u)return m(u,y,d);if(s(x))throw new Error(p("00L04"));if(i(x)){if(!1===w)throw new TypeError(p("00L2l",x));if(!n(x[f]))throw new TypeError(p("00L2m",x));if(x=x[f](),!n(x.next))throw new TypeError(p("00L2m",x));return j(x,y,d)}throw new TypeError(p("00L2m",x))}if(s(x))throw new Error(p("00L04"));throw new TypeError(p("00L2m",x))}if(0===c)if(t(x=arguments[0]))v=new b(x.length);else if(s(x))v=new b(x);else if(e(x))v=new b(x);else{if(!i(x))throw new TypeError(p("00L2m",x));if(!1===w)throw new TypeError(p("00L2l",x));if(!n(x[f]))throw new TypeError(p("00L2m",x));if(x=x[f](),!n(x.next))throw new TypeError(p("00L2m",x));v=new b(h(x))}else v=1===c?new b(arguments[0],arguments[1]):new b(arguments[0],arguments[1],arguments[2]);return v.length>0&&(/^complex/.test(g)?a(v,y,d):l(v.length,v,1,E)),v;function E(r,e){return y.call(d,e)}}export{c as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..4c947f8 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.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\nimport { isPrimitive as isString } from '@stdlib/assert-is-string' ;\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer' ;\nimport isCollection from '@stdlib/assert-is-collection' ;\nimport isArrayBuffer from '@stdlib/assert-is-arraybuffer' ;\nimport isObject from '@stdlib/assert-is-object' ;\nimport isFunction from '@stdlib/assert-is-function' ;\nimport ctors from '@stdlib/array-ctors' ;\nimport gfillBy from '@stdlib/blas-ext-base-gfill-by' ;\nimport filledArray from '@stdlib/array-base-filled-by' ;\nimport hasIteratorSymbolSupport from '@stdlib/assert-has-iterator-symbol-support' ;\nimport ITERATOR_SYMBOL from '@stdlib/symbol-iterator' ;\nimport iterLength from '@stdlib/iter-length' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\n\n\n// VARIABLES //\n\nvar HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport();\nvar DEFAULT_DTYPE = 'float64';\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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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( format( '00L05' ) );\n\t\t}\n\t\tctor = ctors( dtype );\n\t\tif ( ctor === null ) {\n\t\t\tthrow new TypeError( format( '00L2k', 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( format( '00L05' ) );\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( format( '00L05' ) );\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( '00L2n', 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( format( '00L05' ) );\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( '00L2k', 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( format( '00L04' ) );\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( '00L2l', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00L2m', 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( '00L2m', 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( '00L2m', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format( '00L04' ) );\n\t\t}\n\t\tthrow new TypeError( format( '00L2m', 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( '00L2l', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00L2m', 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( '00L2m', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00L2m', 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\nexport default filledarrayBy;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","filledArrayIterator","it","clbk","thisArg","arr","i","next","done","push","call","filledAccessors","length","set","filledarrayBy","nargs","dtype","ctor","len","arg","arguments","ctors","isString","TypeError","format","isFunction","isNonNegativeInteger","isCollection","filledArray","isArrayBuffer","Error","isObject","ITERATOR_SYMBOL","iterLength","test","gfillBy","callback","value","aidx"],"mappings":";;gqCAuCA,IAAIA,EAAsBC,IAe1B,SAASC,EAAqBC,EAAIC,EAAMC,GACvC,IAAIC,EACAC,EAKJ,IAFAD,EAAM,GACNC,GAAK,GAEAJ,EAAGK,OACAC,MAGPF,GAAK,EACLD,EAAII,KAAMN,EAAKO,KAAMN,EAASE,IAE/B,OAAOD,CACR,CAWA,SAASM,EAAiBN,EAAKF,EAAMC,GACpC,IAAIE,EACJ,IAAMA,EAAI,EAAGA,EAAID,EAAIO,OAAQN,IAC5BD,EAAIQ,IAAKV,EAAKO,KAAMN,EAASE,GAAKA,GAEnC,OAAOD,CACR,CA4JA,SAASS,IACR,IAAIV,EACAW,EACAC,EACAb,EACAc,EACAZ,EACAa,EACAC,EAKJ,GAAe,KAHfJ,EAAQK,UAAUR,QAKjB,OAAO,IADPK,EAAOI,EAzNW,YA0ND,GAIlB,GAAKC,EADLN,EAAQI,UAAW,IACM,CAExB,GAAKL,EAAQ,EACZ,MAAM,IAAIQ,UAAWC,EAAQ,UAG9B,GAAc,QADdP,EAAOI,EAAOL,IAEb,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAGvC,OAAO,IAAIC,EAAM,EACjB,CAED,GAAKF,EAAQ,EACZ,MAAM,IAAIQ,UAAWC,EAAQ,UAM9B,GAAKC,EAAYL,UAHjBL,GAAS,IAKR,GAAKU,EAAYL,UAAWL,EAAM,KAMjC,GALAX,EAAUgB,UAAWL,GAErBZ,EAAOiB,UADPL,GAAS,GAIM,IAAVA,EACJ,MAAM,IAAIQ,UAAWC,EAAQ,eAI9BrB,EAAOiB,UAAWL,OAIf,MAAKA,GAAS,GAUlB,MAAM,IAAIQ,UAAWC,EAAQ,UAN7B,GAHApB,EAAUgB,UAAWL,IAGfU,EADNtB,EAAOiB,UADPL,GAAS,IAGR,MAAM,IAAIQ,UAAWC,EAAQ,QAASrB,GAMvC,CAUD,IARAY,GAAS,IACK,GAAKO,EAAUF,UAAWL,KACvCC,EAAQI,UAAWL,GACnBA,GAAS,GAETC,EArRkB,UAwRL,QADdC,EAAOI,EAAOL,IAEb,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAGvC,GAAe,YAAVA,EAAsB,CAE1B,GADAG,EAAMC,UAAW,GACF,IAAVL,EAAc,CAMlB,GALKW,EAAsBP,GAC1BD,EAAMC,EACKQ,EAAcR,KACzBD,EAAMC,EAAIP,aAEE,IAARM,EACJ,OAAOU,EAAaV,EAAKf,EAAMC,GAEhC,GAAKyB,EAAeV,GACnB,MAAM,IAAIW,MAAON,EAAQ,UAE1B,GAAKO,EAAUZ,GAAQ,CACtB,IAA6B,IAAxBpB,EACJ,MAAM,IAAIwB,UAAWC,EAAQ,QAASL,IAEvC,IAAMM,EAAYN,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASL,IAGvC,GADAA,EAAMA,EAAKa,MACLP,EAAYN,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,QAASL,IAEvC,OAAOlB,EAAqBkB,EAAKhB,EAAMC,EACvC,CACD,MAAM,IAAImB,UAAWC,EAAQ,QAASL,GACzC,CAAS,GAAKU,EAAeV,GAC1B,MAAM,IAAIW,MAAON,EAAQ,UAE1B,MAAM,IAAID,UAAWC,EAAQ,QAASL,GACtC,CACD,GAAe,IAAVJ,EAEJ,GAAKY,EADLR,EAAMC,UAAW,IAEhBf,EAAM,IAAIY,EAAME,EAAIP,aACd,GAAKiB,EAAeV,GAC1Bd,EAAM,IAAIY,EAAME,QACV,GAAKO,EAAsBP,GACjCd,EAAM,IAAIY,EAAME,OACV,KAAKY,EAAUZ,GAarB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAZtC,IAA6B,IAAxBpB,EACJ,MAAM,IAAIwB,UAAWC,EAAQ,QAASL,IAEvC,IAAMM,EAAYN,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASL,IAGvC,GADAA,EAAMA,EAAKa,MACLP,EAAYN,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,QAASL,IAEvCd,EAAM,IAAIY,EAAMgB,EAAYd,GAG5B,MAEDd,EADqB,IAAVU,EACL,IAAIE,EAAMG,UAAU,GAAIA,UAAU,IAElC,IAAIH,EAAMG,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKf,EAAIO,OAAS,IACZ,WAAWsB,KAAMlB,GACrBL,EAAiBN,EAAKF,EAAMC,GAE5B+B,EAAS9B,EAAIO,OAAQP,EAAK,EAAG+B,IAGxB/B,EAYP,SAAS+B,EAAUC,EAAOC,GACzB,OAAOnC,EAAKO,KAAMN,EAASkC,EAC3B,CACF"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d115cf0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,192 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -/** -* Create a filled array according to a provided callback function. -* -* @module @stdlib/array-filled-by -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* var arr = filledarrayBy(); -* // returns -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'generic', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( [ 0.5, 0.5 ], clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1; -* } -* -* var arr = filledarrayBy( [ 5, -3 ], 'int32', clbk ); -* // returns [ 1, 1 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk1() { -* return 10; -* } -* -* function clbk2() { -* return 1.0; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, clbk2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk1() { -* return 1.0; -* } -* -* function clbk2() { -* return 2; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, 'uint32', clbk2 ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 'float32', clbk ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, clbk ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, 'int32', clbk ); -* // returns [ 1, 1 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index d6fbe5e..0000000 --- a/lib/main.js +++ /dev/null @@ -1,413 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var isCollection = require( '@stdlib/assert-is-collection' ); -var isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isObject = require( '@stdlib/assert-is-object' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var ctors = require( '@stdlib/array-ctors' ); -var gfillBy = require( '@stdlib/blas-ext-base-gfill-by' ); -var filledArray = require( '@stdlib/array-base-filled-by' ); -var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var iterLength = require( '@stdlib/iter-length' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport(); -var DEFAULT_DTYPE = 'float64'; - - -// FUNCTIONS // - -/** -* Creates a filled "generic" array from an iterator. -* -* @private -* @param {Iterable} it - iterator -* @param {Callback} clbk - callback function -* @param {*} thisArg - callback function execution context -* @returns {Array} filled array -*/ -function filledArrayIterator( it, clbk, thisArg ) { - var arr; - var i; - var v; - - arr = []; - i = -1; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - i += 1; - arr.push( clbk.call( thisArg, i ) ); - } - return arr; -} - -/** -* Fills an array exposing accessors for getting and setting array elements. -* -* @private -* @param {Collection} arr - input array -* @param {Callback} clbk - callback function -* @param {*} thisArg - callback function execution context -* @returns {Collection} input array -*/ -function filledAccessors( arr, clbk, thisArg ) { - var i; - for ( i = 0; i < arr.length; i++ ) { - arr.set( clbk.call( thisArg, i ), i ); - } - return arr; -} - - -// MAIN // - -/** -* Creates a filled array according to a provided callback function. -* -* @param {(NonNegativeInteger|TypedArray|ArrayLikeObject|ArrayBuffer|Iterable)} [arg] - a length, typed array, array-like object, buffer, or iterable -* @param {NonNegativeInteger} [byteOffset=0] - byte offset -* @param {NonNegativeInteger} [length] - view length -* @param {string} [dtype="float64"] - data type -* @param {Callback} [clbk] - callback to invoke -* @param {*} [thisArg] - callback execution context -* @throws {TypeError} must provide a recognized data type -* @throws {TypeError} must provide a length, typed array, array-like object, buffer, or iterable -* @throws {TypeError} callback argument must be a function. -* @throws {Error} creating a generic array from an `ArrayBuffer` is not supported -* @returns {(TypedArray|Array)} array or typed array -* -* @example -* var arr = filledarrayBy(); -* // returns -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'generic', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( [ 0.5, 0.5 ], clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1; -* } -* -* var arr = filledarrayBy( [ 5, -3 ], 'int32', clbk ); -* // returns [ 1, 1 ] -* -* @example -* function clbk1() { -* return 10; -* } -* -* function clbk2() { -* return 1.0; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, clbk2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk1() { -* return 1.0; -* } -* -* function clbk2() { -* return 2; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, 'uint32', clbk2 ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 'float32', clbk ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, clbk ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, 'int32', clbk ); -* // returns [ 1, 1 ] -*/ -function filledarrayBy() { - var thisArg; - var nargs; - var dtype; - var clbk; - var ctor; - var arr; - var len; - var arg; - - nargs = arguments.length; - - // If we weren't provided any arguments, return an empty array... - if ( nargs === 0 ) { - ctor = ctors( DEFAULT_DTYPE ); - return new ctor( 0 ); - } - // Check if we were provided a dtype as the first argument... - dtype = arguments[ 0 ]; - if ( isString( dtype ) ) { - // Invoking this function with arguments `f( dtype, clbk[, thisArg] )` is not allowed (otherwise, we'd need to also allow `f( clbk[, thisArg] )`)... - if ( nargs > 1 ) { - throw new TypeError( format( '00L05' ) ); - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '00L2k', dtype ) ); - } - // Return an empty array having the specified dtype: - return new ctor( 0 ); - } - // For all other supported invocations, we need at least two arguments... - if ( nargs < 2 ) { - throw new TypeError( format( '00L05' ) ); - } - // At this point, we need to do some argument juggling... - nargs -= 1; // henceforth, the number of available arguments is `nargs+1` - - // Determine whether the last argument is a callback or "this" context... - if ( isFunction( arguments[ nargs ] ) ) { - // 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... - if ( isFunction( arguments[ nargs-1 ] ) ) { - thisArg = arguments[ nargs ]; - nargs -= 1; - clbk = arguments[ nargs ]; - - // Check if we were provided only a callback and a "this" context.. - if ( nargs === 0 ) { - throw new TypeError( format( '00L05' ) ); - } - } else { - // "this" context is left undefined... - clbk = arguments[ nargs ]; - } - } - // 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... - else if ( nargs >= 2 ) { - thisArg = arguments[ nargs ]; - nargs -= 1; - clbk = arguments[ nargs ]; - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '00L2n', clbk ) ); - } - } - // If were were only provided 2 arguments and the last argument was not a function, we've been provided an insufficient number of arguments... - else { - throw new TypeError( format( '00L05' ) ); - } - // Now that we've processed the callback arguments, let's continue working backward to see if we've been provided a `dtype` argument... - nargs -= 1; - if ( nargs >= 0 && isString( arguments[ nargs ] ) ) { - dtype = arguments[ nargs ]; - nargs -= 1; - } else { - dtype = DEFAULT_DTYPE; - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '00L2k', dtype ) ); - } - // At this point, we've resolved the output array data type, and now we can actually create the output array... - if ( dtype === 'generic' ) { - arg = arguments[ 0 ]; - if ( nargs === 0 ) { - if ( isNonNegativeInteger( arg ) ) { - len = arg; - } else if ( isCollection( arg ) ) { - len = arg.length; - } - if ( len !== void 0 ) { - return filledArray( len, clbk, thisArg ); - } - if ( isArrayBuffer( arg ) ) { - throw new Error( format( '00L04' ) ); - } - if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( '00L2l', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00L2m', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00L2m', arg ) ); - } - return filledArrayIterator( arg, clbk, thisArg ); - } - throw new TypeError( format( '00L2m', arg ) ); - } else if ( isArrayBuffer( arg ) ) { - throw new Error( format( '00L04' ) ); - } - throw new TypeError( format( '00L2m', arg ) ); - } - if ( nargs === 0 ) { // length || array-like || ArrayBuffer || iterable - arg = arguments[ 0 ]; - if ( isCollection( arg ) ) { - arr = new ctor( arg.length ); - } else if ( isArrayBuffer( arg ) ) { - arr = new ctor( arg ); - } else if ( isNonNegativeInteger( arg ) ) { - arr = new ctor( arg ); - } else if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( '00L2l', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00L2m', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00L2m', arg ) ); - } - arr = new ctor( iterLength( arg ) ); - } else { - throw new TypeError( format( '00L2m', arg ) ); - } - } else if ( nargs === 1 ) { - arr = new ctor( arguments[0], arguments[1] ); // (ArrayBuffer, byteOffset) - } else { - arr = new ctor( arguments[0], arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset, length) - } - if ( arr.length > 0 ) { - if ( /^complex/.test( dtype ) ) { - filledAccessors( arr, clbk, thisArg ); - } else { - gfillBy( arr.length, arr, 1, callback ); - } - } - return arr; - - /** - * Callback which wraps a provided callback and is invoked for each array element. - * - * @private - * @param {*} value - element value - * @param {NonNegativeInteger} aidx - array index - * @param {NonNegativeInteger} sidx - strided index - * @param {Collection} array - input array/collection - * @returns {*} callback return value - */ - function callback( value, aidx ) { - return clbk.call( thisArg, aidx ); - } -} - - -// EXPORTS // - -module.exports = filledarrayBy; diff --git a/package.json b/package.json index 6511a88..498622b 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.2", "description": "Create a filled array according to a provided callback function.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,69 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-filled-by": "^0.0.x", - "@stdlib/array-ctors": "^0.0.x", - "@stdlib/assert-has-iterator-symbol-support": "^0.0.x", - "@stdlib/assert-is-arraybuffer": "^0.0.x", - "@stdlib/assert-is-collection": "^0.0.x", - "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/assert-is-nonnegative-integer": "^0.0.x", - "@stdlib/assert-is-object": "^0.0.x", - "@stdlib/assert-is-string": "^0.0.x", - "@stdlib/blas-ext-base-gfill-by": "^0.0.x", - "@stdlib/iter-length": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x", - "@stdlib/symbol-iterator": "^0.0.x", - "@stdlib/types": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-buffer": "^0.0.x", - "@stdlib/array-complex128": "^0.0.x", - "@stdlib/array-complex64": "^0.0.x", - "@stdlib/array-float32": "^0.0.x", - "@stdlib/array-float64": "^0.0.x", - "@stdlib/array-int16": "^0.0.x", - "@stdlib/array-int32": "^0.0.x", - "@stdlib/array-int8": "^0.0.x", - "@stdlib/array-typed-real-dtypes": "^0.0.x", - "@stdlib/array-uint16": "^0.0.x", - "@stdlib/array-uint32": "^0.0.x", - "@stdlib/array-uint8": "^0.0.x", - "@stdlib/array-uint8c": "^0.0.x", - "@stdlib/assert-instance-of": "^0.0.x", - "@stdlib/assert-is-array": "^0.0.x", - "@stdlib/assert-is-typed-array": "^0.0.x", - "@stdlib/assert-is-typed-array-like": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/complex-float32": "^0.0.x", - "@stdlib/complex-float64": "^0.0.x", - "@stdlib/iter-constant": "^0.0.x", - "@stdlib/math-base-special-pow": "^0.0.x", - "@stdlib/random-base-discrete-uniform": "^0.0.x", - "@stdlib/strided-base-reinterpret-complex128": "^0.0.x", - "@stdlib/strided-base-reinterpret-complex64": "^0.0.x", - "@stdlib/utils-constant-function": "^0.0.x", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..7f923c2 --- /dev/null +++ b/stats.html @@ -0,0 +1,4044 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index b55aa4a..0000000 --- a/test/test.js +++ /dev/null @@ -1,4248 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 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. -*/ - -/* eslint-disable max-len */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -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 ArrayBuffer = require( '@stdlib/array-buffer' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var iterConstant = require( '@stdlib/iter-constant' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var filledarrayBy = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': !hasIteratorSymbolSupport() -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof filledarrayBy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if only provided callback arguments', function test( t ) { - t.throws( clbk1, TypeError, 'throws an error' ); - t.throws( clbk2, TypeError, 'throws an error' ); - t.throws( clbk3, TypeError, 'throws an error' ); - t.end(); - - function clbk1() { - filledarrayBy( constantFunction( 1.0 ) ); - } - - function clbk2() { - filledarrayBy( constantFunction( 1.0 ), {} ); - } - - function clbk3() { - filledarrayBy( constantFunction( 1.0 ), constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (only argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (typed array; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (array-like object)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (array-like object; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 8 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 8 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, 1, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (iterator)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( iterConstant( 1.0 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (iterator; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( iterConstant( 1.0 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if only provided data type and callback arguments', function test( t ) { - t.throws( clbk1, TypeError, 'throws an error' ); - t.throws( clbk2, TypeError, 'throws an error' ); - t.throws( clbk3, TypeError, 'throws an error' ); - t.end(); - - function clbk1() { - filledarrayBy( 'float64', constantFunction( 1.0 ) ); - } - - function clbk2() { - filledarrayBy( 'float64', constantFunction( 1.0 ), {} ); - } - - function clbk3() { - filledarrayBy( 'float64', constantFunction( 1.0 ), constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (array-like object)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (array-like object; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, 1, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, 1, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (no iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (no iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (non-function iterator symbol property)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (non-function iterator symbol property; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (`next` property is not a function)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ) ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (`next` property is not a function; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ), {} ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (no iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (no iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (non-function iterator symbol property)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (non-function iterator symbol property; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (`next` property is not a function)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ) ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (`next` property is not a function; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ), {} ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 1, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 1, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function returns a filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - arr = filledarrayBy(); - - t.strictEqual( instanceOf( arr, Float64Array ), 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=float64)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - arr = filledarrayBy( 'float64' ); - - t.strictEqual( instanceOf( arr, Float64Array ), 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=float32)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( 0 ); - arr = filledarrayBy( 'float32' ); - - t.strictEqual( instanceOf( arr, Float32Array ), 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; - - expected = new Complex128Array( 0 ); - arr = filledarrayBy( 'complex128' ); - - t.strictEqual( instanceOf( arr, Complex128Array ), 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=complex64)', function test( t ) { - var expected; - var arr; - - expected = new Complex64Array( 0 ); - arr = filledarrayBy( 'complex64' ); - - t.strictEqual( instanceOf( arr, Complex64Array ), 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=int32)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( 0 ); - arr = filledarrayBy( 'int32' ); - - t.strictEqual( instanceOf( arr, Int32Array ), 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=uint32)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( 0 ); - arr = filledarrayBy( 'uint32' ); - - t.strictEqual( instanceOf( arr, Uint32Array ), 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=int16)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( 0 ); - arr = filledarrayBy( 'int16' ); - - t.strictEqual( instanceOf( arr, Int16Array ), 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=uint16)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( 0 ); - arr = filledarrayBy( 'uint16' ); - - t.strictEqual( instanceOf( arr, Uint16Array ), 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=int8)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( 0 ); - arr = filledarrayBy( 'int8' ); - - t.strictEqual( instanceOf( arr, Int8Array ), 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=uint8)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( 0 ); - arr = filledarrayBy( 'uint8' ); - - t.strictEqual( instanceOf( arr, Uint8Array ), 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=uint8c)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( 0 ); - arr = filledarrayBy( 'uint8c' ); - - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), 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=generic)', function test( t ) { - var expected; - var arr; - - expected = []; - arr = filledarrayBy( 'generic' ); - - t.strictEqual( instanceOf( arr, Array ), 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 (default, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, length=0)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array(); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 0, clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, clbk, ctx ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (default, length; thisArg=function)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, clbk, context ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this(); // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } - - function context() { - ctx.count += 1; - } -}); - -tape( 'the function returns a filled array (dtype=float64, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, 'float64', clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, length; thisArg=function)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, 'float64', clbk, context ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this(); // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } - - function context() { - ctx.count += 1; - } -}); - -tape( 'the function returns a filled array (dtype=float32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, 'float32', clbk ); - - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex128, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = filledarrayBy( 5, 'complex128', clbk ); - - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = filledarrayBy( 5, 'complex64', clbk ); - - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int32Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int32', clbk ); - - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint32Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint32', clbk ); - - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int16Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int16', clbk ); - - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint16', clbk ); - - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int8Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int8', clbk ); - - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint8', clbk ); - - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint8c', clbk ); - - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = [ 1, 1, 1, 1, 1 ]; - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'generic', clbk ); - - t.strictEqual( instanceOf( arr, Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex128, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = [ 1.0, 2.0 ]; - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = [ 1.0, 2.0 ]; - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int32', clbk ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, typed array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, typed array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex128, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = new Float64Array( [ 1.0, 2.0 ] ); - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = new Float64Array( [ 1.0, 2.0 ] ); - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (default, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex128, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer, byteoffset; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer, byteoffset; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, 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; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 48 ); - out = filledarrayBy( buf, 16, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 24 ); - out = filledarrayBy( buf, 8, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int32', clbk ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint8c', clbk ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, 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; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 64 ); - out = filledarrayBy( buf, 16, 2, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset, length)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 1, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 1, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled array (default, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, iterator; thisArg)', opts, function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - ctx = { - 'count': 0 - }; - indices = []; - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, iterator; thisArg)', opts, function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - ctx = { - 'count': 0 - }; - indices = []; - out = filledarrayBy( arr, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex128, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = iterConstant( new Complex128( 3.0, 3.0 ), { - 'iter': 2 - }); - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = iterConstant( new Complex64( 3.0, 3.0 ), { - 'iter': 2 - }); - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); From 0d180df465f5cd9dc6330794f11edf677ea988e7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 4 Nov 2022 00:47:06 +0000 Subject: [PATCH 023/117] Transform error messages --- lib/main.js | 38 +++++++++++++++++++------------------- package.json | 2 +- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/lib/main.js b/lib/main.js index d27b055..d6fbe5e 100644 --- a/lib/main.js +++ b/lib/main.js @@ -32,7 +32,7 @@ var filledArray = require( '@stdlib/array-base-filled-by' ); var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); var iterLength = require( '@stdlib/iter-length' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -263,18 +263,18 @@ function filledarrayBy() { if ( isString( dtype ) ) { // Invoking this function with arguments `f( dtype, clbk[, thisArg] )` is not allowed (otherwise, we'd need to also allow `f( clbk[, thisArg] )`)... if ( nargs > 1 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format( '00L05' ) ); } ctor = ctors( dtype ); if ( ctor === null ) { - throw new TypeError( format( 'invalid argument. Must provide a recognized data type. Value: `%s`.', dtype ) ); + throw new TypeError( format( '00L2k', dtype ) ); } // Return an empty array having the specified dtype: return new ctor( 0 ); } // For all other supported invocations, we need at least two arguments... if ( nargs < 2 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format( '00L05' ) ); } // At this point, we need to do some argument juggling... nargs -= 1; // henceforth, the number of available arguments is `nargs+1` @@ -289,7 +289,7 @@ function filledarrayBy() { // Check if we were provided only a callback and a "this" context.. if ( nargs === 0 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format( '00L05' ) ); } } else { // "this" context is left undefined... @@ -302,12 +302,12 @@ function filledarrayBy() { nargs -= 1; clbk = arguments[ nargs ]; if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '00L2n', clbk ) ); } } // If were were only provided 2 arguments and the last argument was not a function, we've been provided an insufficient number of arguments... else { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format( '00L05' ) ); } // Now that we've processed the callback arguments, let's continue working backward to see if we've been provided a `dtype` argument... nargs -= 1; @@ -319,7 +319,7 @@ function filledarrayBy() { } ctor = ctors( dtype ); if ( ctor === null ) { - throw new TypeError( format( 'invalid argument. Must provide a recognized data type. Value: `%s`.', dtype ) ); + throw new TypeError( format( '00L2k', dtype ) ); } // At this point, we've resolved the output array data type, and now we can actually create the output array... if ( dtype === 'generic' ) { @@ -334,26 +334,26 @@ function filledarrayBy() { return filledArray( len, clbk, thisArg ); } if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format( '00L04' ) ); } if ( isObject( arg ) ) { if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.', arg ) ); + throw new TypeError( format( '00L2l', arg ) ); } if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00L2m', arg ) ); } arg = arg[ ITERATOR_SYMBOL ](); if ( !isFunction( arg.next ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00L2m', arg ) ); } return filledArrayIterator( arg, clbk, thisArg ); } - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00L2m', arg ) ); } else if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format( '00L04' ) ); } - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00L2m', arg ) ); } if ( nargs === 0 ) { // length || array-like || ArrayBuffer || iterable arg = arguments[ 0 ]; @@ -365,18 +365,18 @@ function filledarrayBy() { arr = new ctor( arg ); } else if ( isObject( arg ) ) { if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.', arg ) ); + throw new TypeError( format( '00L2l', arg ) ); } if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00L2m', arg ) ); } arg = arg[ ITERATOR_SYMBOL ](); if ( !isFunction( arg.next ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00L2m', arg ) ); } arr = new ctor( iterLength( arg ) ); } else { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00L2m', arg ) ); } } else if ( nargs === 1 ) { arr = new ctor( arguments[0], arguments[1] ); // (ArrayBuffer, byteOffset) diff --git a/package.json b/package.json index b974a7b..6511a88 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "@stdlib/assert-is-string": "^0.0.x", "@stdlib/blas-ext-base-gfill-by": "^0.0.x", "@stdlib/iter-length": "^0.0.x", - "@stdlib/string-format": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x", "@stdlib/symbol-iterator": "^0.0.x", "@stdlib/types": "^0.0.x" }, From 75b189c8a735d33a78ce9a4fdb9a04fdb34195d0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 4 Nov 2022 14:55:27 +0000 Subject: [PATCH 024/117] Remove files --- index.d.ts | 427 ------ index.mjs | 4 - index.mjs.map | 1 - stats.html | 4044 ------------------------------------------------- 4 files changed, 4476 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 2156674..0000000 --- a/index.d.ts +++ /dev/null @@ -1,427 +0,0 @@ -/* -* @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. -*/ - -// TypeScript Version: 2.0 - -/// - -import { RealOrComplexTypedArray, DataType } from '@stdlib/types/array'; -import { Collection } from '@stdlib/types/object'; -import { IterableIterator } from '@stdlib/types/iter'; - -/** -* Array or typed array. -*/ -type ArrayOrTypedArray = Array | RealOrComplexTypedArray; - -/** -* Nullary callback function. -* -* @returns fill value -*/ -type Nullary = () => any; - -/** -* Unary callback function. -* -* @param i - current array index -* @returns fill value -*/ -type Unary = ( i: number ) => any; - -/** -* Callback function. -* -* @param i - current array index -* @returns fill value -*/ -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 -* -* @example -* var arr = filledarrayBy(); -* // returns -* -* @example -* var arr = filledarrayBy( 'float32' ); -* // returns -*/ -declare function filledarrayBy( dtype?: DataType ): ArrayOrTypedArray; // tslint:disable-line:unified-signatures - -/** -* Creates a filled array according to a provided callback function and having a specified `length`. -* -* @param length - array length -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* -* var arr = filledarrayBy( 5, constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( length: number, clbk: Callback, thisArg?: any ): ArrayOrTypedArray; // tslint:disable-line:max-line-length unified-signatures - -/** -* 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 -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* -* var arr = filledarrayBy( 5, 'float64', constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( length: number, dtype: DataType, clbk: Callback, thisArg?: any ): ArrayOrTypedArray; // tslint:disable-line:max-line-length unified-signatures - -/** -* Creates a filled array from another `array` according to a provided callback function. -* -* @param array - typed array or array-like object -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* -* 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; // tslint:disable-line:max-line-length 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 -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* -* 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; // tslint:disable-line:max-line-length unified-signatures - -/** -* Creates a filled array from an iterable according to a callback function. -* -* @param iterable - iterable -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* var iterConstant = require( `@stdlib/iter/constant` ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarrayBy( it, constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( iterable: IterableIterator, callback: Callback, thisArg?: any ): ArrayOrTypedArray; // tslint:disable-line:max-line-length 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 -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* var iterConstant = require( `@stdlib/iter/constant` ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* 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; // tslint:disable-line:max-line-length unified-signatures - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; // tslint:disable-line:max-line-length - -/** -* 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. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; // tslint:disable-line:max-line-length unified-signatures - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; // tslint:disable-line:max-line-length - -/** -* 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. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; // tslint:disable-line:max-line-length unified-signatures - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; // tslint:disable-line:max-line-length 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. -* -* @param buffer - `ArrayBuffer` -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; // tslint:disable-line:max-line-length unified-signatures - - -// EXPORTS // - -export = filledarrayBy; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index ce0d7c1..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-ctors@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill-by@v0.0.10-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled-by@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";var w=d();function j(r,e,t){var s,i;for(s=[],i=-1;!r.next().done;)i+=1,s.push(e.call(t,i));return s}function a(r,e,t){var s;for(s=0;s1)throw new TypeError(p("00L05"));if(null===(b=o(g)))throw new TypeError(p("00L2k",g));return new b(0)}if(c<2)throw new TypeError(p("00L05"));if(n(arguments[c-=1]))if(n(arguments[c-1])){if(d=arguments[c],y=arguments[c-=1],0===c)throw new TypeError(p("00L05"))}else y=arguments[c];else{if(!(c>=2))throw new TypeError(p("00L05"));if(d=arguments[c],!n(y=arguments[c-=1]))throw new TypeError(p("00L2n",y))}if((c-=1)>=0&&r(arguments[c])?(g=arguments[c],c-=1):g="float64",null===(b=o(g)))throw new TypeError(p("00L2k",g));if("generic"===g){if(x=arguments[0],0===c){if(e(x)?u=x:t(x)&&(u=x.length),void 0!==u)return m(u,y,d);if(s(x))throw new Error(p("00L04"));if(i(x)){if(!1===w)throw new TypeError(p("00L2l",x));if(!n(x[f]))throw new TypeError(p("00L2m",x));if(x=x[f](),!n(x.next))throw new TypeError(p("00L2m",x));return j(x,y,d)}throw new TypeError(p("00L2m",x))}if(s(x))throw new Error(p("00L04"));throw new TypeError(p("00L2m",x))}if(0===c)if(t(x=arguments[0]))v=new b(x.length);else if(s(x))v=new b(x);else if(e(x))v=new b(x);else{if(!i(x))throw new TypeError(p("00L2m",x));if(!1===w)throw new TypeError(p("00L2l",x));if(!n(x[f]))throw new TypeError(p("00L2m",x));if(x=x[f](),!n(x.next))throw new TypeError(p("00L2m",x));v=new b(h(x))}else v=1===c?new b(arguments[0],arguments[1]):new b(arguments[0],arguments[1],arguments[2]);return v.length>0&&(/^complex/.test(g)?a(v,y,d):l(v.length,v,1,E)),v;function E(r,e){return y.call(d,e)}}export{c as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 4c947f8..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.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\nimport { isPrimitive as isString } from '@stdlib/assert-is-string' ;\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer' ;\nimport isCollection from '@stdlib/assert-is-collection' ;\nimport isArrayBuffer from '@stdlib/assert-is-arraybuffer' ;\nimport isObject from '@stdlib/assert-is-object' ;\nimport isFunction from '@stdlib/assert-is-function' ;\nimport ctors from '@stdlib/array-ctors' ;\nimport gfillBy from '@stdlib/blas-ext-base-gfill-by' ;\nimport filledArray from '@stdlib/array-base-filled-by' ;\nimport hasIteratorSymbolSupport from '@stdlib/assert-has-iterator-symbol-support' ;\nimport ITERATOR_SYMBOL from '@stdlib/symbol-iterator' ;\nimport iterLength from '@stdlib/iter-length' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\n\n\n// VARIABLES //\n\nvar HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport();\nvar DEFAULT_DTYPE = 'float64';\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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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( format( '00L05' ) );\n\t\t}\n\t\tctor = ctors( dtype );\n\t\tif ( ctor === null ) {\n\t\t\tthrow new TypeError( format( '00L2k', 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( format( '00L05' ) );\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( format( '00L05' ) );\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( '00L2n', 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( format( '00L05' ) );\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( '00L2k', 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( format( '00L04' ) );\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( '00L2l', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00L2m', 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( '00L2m', 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( '00L2m', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format( '00L04' ) );\n\t\t}\n\t\tthrow new TypeError( format( '00L2m', 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( '00L2l', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00L2m', 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( '00L2m', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00L2m', 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\nexport default filledarrayBy;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","filledArrayIterator","it","clbk","thisArg","arr","i","next","done","push","call","filledAccessors","length","set","filledarrayBy","nargs","dtype","ctor","len","arg","arguments","ctors","isString","TypeError","format","isFunction","isNonNegativeInteger","isCollection","filledArray","isArrayBuffer","Error","isObject","ITERATOR_SYMBOL","iterLength","test","gfillBy","callback","value","aidx"],"mappings":";;gqCAuCA,IAAIA,EAAsBC,IAe1B,SAASC,EAAqBC,EAAIC,EAAMC,GACvC,IAAIC,EACAC,EAKJ,IAFAD,EAAM,GACNC,GAAK,GAEAJ,EAAGK,OACAC,MAGPF,GAAK,EACLD,EAAII,KAAMN,EAAKO,KAAMN,EAASE,IAE/B,OAAOD,CACR,CAWA,SAASM,EAAiBN,EAAKF,EAAMC,GACpC,IAAIE,EACJ,IAAMA,EAAI,EAAGA,EAAID,EAAIO,OAAQN,IAC5BD,EAAIQ,IAAKV,EAAKO,KAAMN,EAASE,GAAKA,GAEnC,OAAOD,CACR,CA4JA,SAASS,IACR,IAAIV,EACAW,EACAC,EACAb,EACAc,EACAZ,EACAa,EACAC,EAKJ,GAAe,KAHfJ,EAAQK,UAAUR,QAKjB,OAAO,IADPK,EAAOI,EAzNW,YA0ND,GAIlB,GAAKC,EADLN,EAAQI,UAAW,IACM,CAExB,GAAKL,EAAQ,EACZ,MAAM,IAAIQ,UAAWC,EAAQ,UAG9B,GAAc,QADdP,EAAOI,EAAOL,IAEb,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAGvC,OAAO,IAAIC,EAAM,EACjB,CAED,GAAKF,EAAQ,EACZ,MAAM,IAAIQ,UAAWC,EAAQ,UAM9B,GAAKC,EAAYL,UAHjBL,GAAS,IAKR,GAAKU,EAAYL,UAAWL,EAAM,KAMjC,GALAX,EAAUgB,UAAWL,GAErBZ,EAAOiB,UADPL,GAAS,GAIM,IAAVA,EACJ,MAAM,IAAIQ,UAAWC,EAAQ,eAI9BrB,EAAOiB,UAAWL,OAIf,MAAKA,GAAS,GAUlB,MAAM,IAAIQ,UAAWC,EAAQ,UAN7B,GAHApB,EAAUgB,UAAWL,IAGfU,EADNtB,EAAOiB,UADPL,GAAS,IAGR,MAAM,IAAIQ,UAAWC,EAAQ,QAASrB,GAMvC,CAUD,IARAY,GAAS,IACK,GAAKO,EAAUF,UAAWL,KACvCC,EAAQI,UAAWL,GACnBA,GAAS,GAETC,EArRkB,UAwRL,QADdC,EAAOI,EAAOL,IAEb,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAGvC,GAAe,YAAVA,EAAsB,CAE1B,GADAG,EAAMC,UAAW,GACF,IAAVL,EAAc,CAMlB,GALKW,EAAsBP,GAC1BD,EAAMC,EACKQ,EAAcR,KACzBD,EAAMC,EAAIP,aAEE,IAARM,EACJ,OAAOU,EAAaV,EAAKf,EAAMC,GAEhC,GAAKyB,EAAeV,GACnB,MAAM,IAAIW,MAAON,EAAQ,UAE1B,GAAKO,EAAUZ,GAAQ,CACtB,IAA6B,IAAxBpB,EACJ,MAAM,IAAIwB,UAAWC,EAAQ,QAASL,IAEvC,IAAMM,EAAYN,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASL,IAGvC,GADAA,EAAMA,EAAKa,MACLP,EAAYN,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,QAASL,IAEvC,OAAOlB,EAAqBkB,EAAKhB,EAAMC,EACvC,CACD,MAAM,IAAImB,UAAWC,EAAQ,QAASL,GACzC,CAAS,GAAKU,EAAeV,GAC1B,MAAM,IAAIW,MAAON,EAAQ,UAE1B,MAAM,IAAID,UAAWC,EAAQ,QAASL,GACtC,CACD,GAAe,IAAVJ,EAEJ,GAAKY,EADLR,EAAMC,UAAW,IAEhBf,EAAM,IAAIY,EAAME,EAAIP,aACd,GAAKiB,EAAeV,GAC1Bd,EAAM,IAAIY,EAAME,QACV,GAAKO,EAAsBP,GACjCd,EAAM,IAAIY,EAAME,OACV,KAAKY,EAAUZ,GAarB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAZtC,IAA6B,IAAxBpB,EACJ,MAAM,IAAIwB,UAAWC,EAAQ,QAASL,IAEvC,IAAMM,EAAYN,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASL,IAGvC,GADAA,EAAMA,EAAKa,MACLP,EAAYN,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,QAASL,IAEvCd,EAAM,IAAIY,EAAMgB,EAAYd,GAG5B,MAEDd,EADqB,IAAVU,EACL,IAAIE,EAAMG,UAAU,GAAIA,UAAU,IAElC,IAAIH,EAAMG,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKf,EAAIO,OAAS,IACZ,WAAWsB,KAAMlB,GACrBL,EAAiBN,EAAKF,EAAMC,GAE5B+B,EAAS9B,EAAIO,OAAQP,EAAK,EAAG+B,IAGxB/B,EAYP,SAAS+B,EAAUC,EAAOC,GACzB,OAAOnC,EAAKO,KAAMN,EAASkC,EAC3B,CACF"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 7f923c2..0000000 --- a/stats.html +++ /dev/null @@ -1,4044 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 74f3f54ae917de8b2b01a3b33ed5d2407fb991b0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 4 Nov 2022 14:56:19 +0000 Subject: [PATCH 025/117] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 781 ---- .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 178 - .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 41 +- benchmark/benchmark.js | 319 -- benchmark/benchmark.length.complex128.js | 98 - benchmark/benchmark.length.complex64.js | 98 - benchmark/benchmark.length.float32.js | 97 - benchmark/benchmark.length.float64.js | 97 - benchmark/benchmark.length.generic.js | 97 - benchmark/benchmark.length.int16.js | 97 - benchmark/benchmark.length.int32.js | 97 - benchmark/benchmark.length.int8.js | 97 - benchmark/benchmark.length.uint16.js | 97 - benchmark/benchmark.length.uint32.js | 97 - benchmark/benchmark.length.uint8.js | 97 - benchmark/benchmark.length.uint8c.js | 97 - branches.md | 53 - docs/repl.txt | 174 - docs/types/test.ts | 606 --- examples/index.js | 37 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 192 - lib/main.js | 413 -- package.json | 90 +- stats.html | 4044 ++++++++++++++++++++ test/test.js | 4248 --------------------- 49 files changed, 4069 insertions(+), 10246 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.length.complex128.js delete mode 100644 benchmark/benchmark.length.complex64.js delete mode 100644 benchmark/benchmark.length.float32.js delete mode 100644 benchmark/benchmark.length.float64.js delete mode 100644 benchmark/benchmark.length.generic.js delete mode 100644 benchmark/benchmark.length.int16.js delete mode 100644 benchmark/benchmark.length.int32.js delete mode 100644 benchmark/benchmark.length.int8.js delete mode 100644 benchmark/benchmark.length.uint16.js delete mode 100644 benchmark/benchmark.length.uint32.js delete mode 100644 benchmark/benchmark.length.uint8.js delete mode 100644 benchmark/benchmark.length.uint8c.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 5191495..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-11-03T23:11:52.928Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 8be0b82..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 06a9a75..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index a00dbe5..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.11.0 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index df9d9d7..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 7902a7d..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 16e02e6..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '42 6 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 37ddb4f..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,781 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -273,7 +266,7 @@ for ( i = 0; i < dt.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 421b48e..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,319 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); -var isArray = require( '@stdlib/assert-is-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var pkg = require( './../package.json' ).name; -var filledarrayBy = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 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=float64', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'float64', 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=float32', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'float32', 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; - var i; - - clbk = constantFunction( new Complex128( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'complex128', 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=complex64', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( new Complex64( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'complex64', 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=int32', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int32', 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=uint32', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint32', 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=int16', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int16', 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=uint16', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint16', 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=int8', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int8', 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=uint8', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint8', 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=uint8c', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint8c', 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=generic', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'generic', clbk ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.length.complex128.js b/benchmark/benchmark.length.complex128.js deleted file mode 100644 index 671de86..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var Complex128 = require( '@stdlib/complex-float64' ); -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( new Complex128( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'complex128', 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=complex128,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.complex64.js b/benchmark/benchmark.length.complex64.js deleted file mode 100644 index 52da4e3..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var Complex64 = require( '@stdlib/complex-float32' ); -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( new Complex64( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'complex64', 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=complex64,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.float32.js b/benchmark/benchmark.length.float32.js deleted file mode 100644 index 9b4ef9b..0000000 --- a/benchmark/benchmark.length.float32.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'float32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=float32,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.float64.js b/benchmark/benchmark.length.float64.js deleted file mode 100644 index 66cb6b6..0000000 --- a/benchmark/benchmark.length.float64.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'float64', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=float64,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.generic.js b/benchmark/benchmark.length.generic.js deleted file mode 100644 index 5194c1b..0000000 --- a/benchmark/benchmark.length.generic.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isArray = require( '@stdlib/assert-is-array' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'generic', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isArray( 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=generic,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int16.js b/benchmark/benchmark.length.int16.js deleted file mode 100644 index 6669b28..0000000 --- a/benchmark/benchmark.length.int16.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int16', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=int16,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int32.js b/benchmark/benchmark.length.int32.js deleted file mode 100644 index e9c5c88..0000000 --- a/benchmark/benchmark.length.int32.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=int32,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int8.js b/benchmark/benchmark.length.int8.js deleted file mode 100644 index 14bbadf..0000000 --- a/benchmark/benchmark.length.int8.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int8', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=int8,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint16.js b/benchmark/benchmark.length.uint16.js deleted file mode 100644 index d03b23e..0000000 --- a/benchmark/benchmark.length.uint16.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint16', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint16,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint32.js b/benchmark/benchmark.length.uint32.js deleted file mode 100644 index 1382134..0000000 --- a/benchmark/benchmark.length.uint32.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint32,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint8.js b/benchmark/benchmark.length.uint8.js deleted file mode 100644 index c135d6c..0000000 --- a/benchmark/benchmark.length.uint8.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint8', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint8,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint8c.js b/benchmark/benchmark.length.uint8c.js deleted file mode 100644 index 2f7523a..0000000 --- a/benchmark/benchmark.length.uint8c.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint8c', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint8c,len='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 18101fd..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by" -click B href "https://github.com/stdlib-js/array-filled-by/tree/main" -click C href "https://github.com/stdlib-js/array-filled-by/tree/production" -click D href "https://github.com/stdlib-js/array-filled-by/tree/esm" -click E href "https://github.com/stdlib-js/array-filled-by/tree/deno" -click F href "https://github.com/stdlib-js/array-filled-by/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by -[production-url]: https://github.com/stdlib-js/array-filled-by/tree/production -[deno-url]: https://github.com/stdlib-js/array-filled-by/tree/deno -[umd-url]: https://github.com/stdlib-js/array-filled-by/tree/umd -[esm-url]: https://github.com/stdlib-js/array-filled-by/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 5a68984..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,174 +0,0 @@ - -{{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) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr = {{alias}}() - - > arr = {{alias}}( 'float32' ) - - - -{{alias}}( length[, dtype], clbk[, thisArg] ) - Returns a filled array according to a provided callback function and having - a specified length. - - Parameters - ---------- - length: integer - Array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > function clbk() { return 1.0; }; - > var arr = {{alias}}( 5, clbk ) - [ 1.0, 1.0, 1.0, 1.0, 1.0 ] - > arr = {{alias}}( 5, 'int32', clbk ) - [ 1, 1, 1, 1, 1 ] - - -{{alias}}( array[, dtype], clbk[, thisArg] ) - Creates a filled array from another array (or array-like object) according - to a provided callback function. - - Parameters - ---------- - array: ArrayLikeObject - Array from which to generate another array. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias}}( [ 0.5, 0.5, 0.5 ], {{alias:@stdlib/utils/constant-function}}( 2.0 ) ) - [ 2.0, 2.0, 2.0 ] - > var arr2 = {{alias}}( arr1, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( iterable[, dtype], clbk[, thisArg] ) - Creates a filled array from an iterable according to a provided callback - function. - - Parameters - ---------- - iterable: Iterable - Iterable from which to generate an array. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias:@stdlib/iter/constant}}( 3.0, {'iter': 3} ); - > var arr2 = {{alias}}( arr1, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( buffer[, byteOffset[, length]][, dtype], clbk[, thisArg] ) - Returns a filled typed array view of an ArrayBuffer according to a provided - callback function. - - The 'generic' array data type is *not* supported. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( buf, 0, 4, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0, 1.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 394ac49..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,606 +0,0 @@ -/* -* @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. -*/ - -/// - -import { IterableIterator } from '@stdlib/types/iter'; -import filledarrayBy = require( './index' ); - - -/** -* Returns an iterator protocol-compliant object. -* -* @returns iterator protocol-compliant object -*/ -function iterator(): IterableIterator { - const obj: IterableIterator = { - [Symbol.iterator]: iterator, - 'next': next - }; - return obj; -} - -/** -* Implements the iterator protocol `next` method. -* -* @returns iterator protocol-compliant object -*/ -function next(): any { - return { - 'value': 1.0, - 'done': false - }; -} - -/** -* Callback function. -* -* @param i - current array index -* @returns return value -*/ -function clbk( i: number ): number { - return i; -} - - -// TESTS // - -// The function returns an array or typed array... -{ - filledarrayBy(); // $ExpectType ArrayOrTypedArray - filledarrayBy( 'float32' ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( 10, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( 10, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( 10, 'int32', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( 10, 'int32', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const x = new Float64Array( 10 ); - filledarrayBy( x, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( x, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( x, 'uint8', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( x, 'uint8', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const y = [ 2.0, 2.0, 2.0 ]; - filledarrayBy( y, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( y, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( y, 'float64', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( y, 'float64', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const it = iterator(); - filledarrayBy( it, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( it, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( it, 'uint8c', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( it, 'uint8c', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const buf = new ArrayBuffer( 32 ); - filledarrayBy( buf, clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 'uint32', clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 'uint32', clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 8, clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 8, clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 8, 'uint16', clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 8, 'uint16', clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 8, 2, clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 8, 2, clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 8, 2, 'int16', clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 8, 2, 'int16', clbk, {} ); // $ExpectType RealOrComplexTypedArray -} - -// The compiler throws an error if a callback function argument is not a function... -{ - filledarrayBy( 'float64', '5' ); // $ExpectError - filledarrayBy( 'float64', 1.0 ); // $ExpectError - filledarrayBy( 'float64', false ); // $ExpectError - filledarrayBy( 'float64', true ); // $ExpectError - filledarrayBy( 'float64', null ); // $ExpectError - filledarrayBy( 'float64', undefined ); // $ExpectError - filledarrayBy( 'float64', [] ); // $ExpectError - filledarrayBy( 'float64', {} ); // $ExpectError - - filledarrayBy( 'float64', '5', {} ); // $ExpectError - filledarrayBy( 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( 'float64', false, {} ); // $ExpectError - filledarrayBy( 'float64', true, {} ); // $ExpectError - filledarrayBy( 'float64', null, {} ); // $ExpectError - filledarrayBy( 'float64', undefined, {} ); // $ExpectError - filledarrayBy( 'float64', [], {} ); // $ExpectError - filledarrayBy( 'float64', {}, {} ); // $ExpectError - - filledarrayBy( 10, '5' ); // $ExpectError - filledarrayBy( 10, 1.0 ); // $ExpectError - filledarrayBy( 10, false ); // $ExpectError - filledarrayBy( 10, true ); // $ExpectError - filledarrayBy( 10, null ); // $ExpectError - filledarrayBy( 10, undefined ); // $ExpectError - filledarrayBy( 10, [] ); // $ExpectError - filledarrayBy( 10, {} ); // $ExpectError - - filledarrayBy( 10, '5', {} ); // $ExpectError - filledarrayBy( 10, 1.0, {} ); // $ExpectError - filledarrayBy( 10, false, {} ); // $ExpectError - filledarrayBy( 10, true, {} ); // $ExpectError - filledarrayBy( 10, null, {} ); // $ExpectError - filledarrayBy( 10, undefined, {} ); // $ExpectError - filledarrayBy( 10, [], {} ); // $ExpectError - filledarrayBy( 10, {}, {} ); // $ExpectError - - filledarrayBy( 10, 'float64', '5' ); // $ExpectError - filledarrayBy( 10, 'float64', 1.0 ); // $ExpectError - filledarrayBy( 10, 'float64', false ); // $ExpectError - filledarrayBy( 10, 'float64', true ); // $ExpectError - filledarrayBy( 10, 'float64', null ); // $ExpectError - filledarrayBy( 10, 'float64', undefined ); // $ExpectError - filledarrayBy( 10, 'float64', [] ); // $ExpectError - filledarrayBy( 10, 'float64', {} ); // $ExpectError - - filledarrayBy( 10, 'float64', '5', {} ); // $ExpectError - filledarrayBy( 10, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( 10, 'float64', false, {} ); // $ExpectError - filledarrayBy( 10, 'float64', true, {} ); // $ExpectError - filledarrayBy( 10, 'float64', null, {} ); // $ExpectError - filledarrayBy( 10, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( 10, 'float64', [], {} ); // $ExpectError - filledarrayBy( 10, 'float64', {}, {} ); // $ExpectError - - const x = new Float64Array( 10 ); - filledarrayBy( x, '5' ); // $ExpectError - filledarrayBy( x, 1.0 ); // $ExpectError - filledarrayBy( x, false ); // $ExpectError - filledarrayBy( x, true ); // $ExpectError - filledarrayBy( x, null ); // $ExpectError - filledarrayBy( x, undefined ); // $ExpectError - filledarrayBy( x, [] ); // $ExpectError - filledarrayBy( x, {} ); // $ExpectError - - filledarrayBy( x, '5', {} ); // $ExpectError - filledarrayBy( x, 1.0, {} ); // $ExpectError - filledarrayBy( x, false, {} ); // $ExpectError - filledarrayBy( x, true, {} ); // $ExpectError - filledarrayBy( x, null, {} ); // $ExpectError - filledarrayBy( x, undefined, {} ); // $ExpectError - filledarrayBy( x, [], {} ); // $ExpectError - filledarrayBy( x, {}, {} ); // $ExpectError - - filledarrayBy( x, 'float64', '5' ); // $ExpectError - filledarrayBy( x, 'float64', 1.0 ); // $ExpectError - filledarrayBy( x, 'float64', false ); // $ExpectError - filledarrayBy( x, 'float64', true ); // $ExpectError - filledarrayBy( x, 'float64', null ); // $ExpectError - filledarrayBy( x, 'float64', undefined ); // $ExpectError - filledarrayBy( x, 'float64', [] ); // $ExpectError - filledarrayBy( x, 'float64', {} ); // $ExpectError - - filledarrayBy( x, 'float64', '5', {} ); // $ExpectError - filledarrayBy( x, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( x, 'float64', false, {} ); // $ExpectError - filledarrayBy( x, 'float64', true, {} ); // $ExpectError - filledarrayBy( x, 'float64', null, {} ); // $ExpectError - filledarrayBy( x, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( x, 'float64', [], {} ); // $ExpectError - filledarrayBy( x, 'float64', {}, {} ); // $ExpectError - - const y = [ 2.0, 2.0, 2.0 ]; - filledarrayBy( y, '5' ); // $ExpectError - filledarrayBy( y, 1.0 ); // $ExpectError - filledarrayBy( y, false ); // $ExpectError - filledarrayBy( y, true ); // $ExpectError - filledarrayBy( y, null ); // $ExpectError - filledarrayBy( y, undefined ); // $ExpectError - filledarrayBy( y, [] ); // $ExpectError - filledarrayBy( y, {} ); // $ExpectError - - filledarrayBy( y, '5', {} ); // $ExpectError - filledarrayBy( y, 1.0, {} ); // $ExpectError - filledarrayBy( y, false, {} ); // $ExpectError - filledarrayBy( y, true, {} ); // $ExpectError - filledarrayBy( y, null, {} ); // $ExpectError - filledarrayBy( y, undefined, {} ); // $ExpectError - filledarrayBy( y, [], {} ); // $ExpectError - filledarrayBy( y, {}, {} ); // $ExpectError - - filledarrayBy( y, 'float64', '5' ); // $ExpectError - filledarrayBy( y, 'float64', 1.0 ); // $ExpectError - filledarrayBy( y, 'float64', false ); // $ExpectError - filledarrayBy( y, 'float64', true ); // $ExpectError - filledarrayBy( y, 'float64', null ); // $ExpectError - filledarrayBy( y, 'float64', undefined ); // $ExpectError - filledarrayBy( y, 'float64', [] ); // $ExpectError - filledarrayBy( y, 'float64', {} ); // $ExpectError - - filledarrayBy( y, 'float64', '5', {} ); // $ExpectError - filledarrayBy( y, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( y, 'float64', false, {} ); // $ExpectError - filledarrayBy( y, 'float64', true, {} ); // $ExpectError - filledarrayBy( y, 'float64', null, {} ); // $ExpectError - filledarrayBy( y, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( y, 'float64', [], {} ); // $ExpectError - filledarrayBy( y, 'float64', {}, {} ); // $ExpectError - - const it = iterator(); - filledarrayBy( it, '5' ); // $ExpectError - filledarrayBy( it, 1.0 ); // $ExpectError - filledarrayBy( it, false ); // $ExpectError - filledarrayBy( it, true ); // $ExpectError - filledarrayBy( it, null ); // $ExpectError - filledarrayBy( it, undefined ); // $ExpectError - filledarrayBy( it, [] ); // $ExpectError - filledarrayBy( it, {} ); // $ExpectError - - filledarrayBy( it, '5', {} ); // $ExpectError - filledarrayBy( it, 1.0, {} ); // $ExpectError - filledarrayBy( it, false, {} ); // $ExpectError - filledarrayBy( it, true, {} ); // $ExpectError - filledarrayBy( it, null, {} ); // $ExpectError - filledarrayBy( it, undefined, {} ); // $ExpectError - filledarrayBy( it, [], {} ); // $ExpectError - filledarrayBy( it, {}, {} ); // $ExpectError - - filledarrayBy( it, 'float64', '5' ); // $ExpectError - filledarrayBy( it, 'float64', 1.0 ); // $ExpectError - filledarrayBy( it, 'float64', false ); // $ExpectError - filledarrayBy( it, 'float64', true ); // $ExpectError - filledarrayBy( it, 'float64', null ); // $ExpectError - filledarrayBy( it, 'float64', undefined ); // $ExpectError - filledarrayBy( it, 'float64', [] ); // $ExpectError - filledarrayBy( it, 'float64', {} ); // $ExpectError - - filledarrayBy( it, 'float64', '5', {} ); // $ExpectError - filledarrayBy( it, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( it, 'float64', false, {} ); // $ExpectError - filledarrayBy( it, 'float64', true, {} ); // $ExpectError - filledarrayBy( it, 'float64', null, {} ); // $ExpectError - filledarrayBy( it, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( it, 'float64', [], {} ); // $ExpectError - filledarrayBy( it, 'float64', {}, {} ); // $ExpectError - - const buf = new ArrayBuffer( 32 ); - filledarrayBy( buf, '5' ); // $ExpectError - filledarrayBy( buf, 1.0 ); // $ExpectError - filledarrayBy( buf, false ); // $ExpectError - filledarrayBy( buf, true ); // $ExpectError - filledarrayBy( buf, null ); // $ExpectError - filledarrayBy( buf, undefined ); // $ExpectError - filledarrayBy( buf, [] ); // $ExpectError - filledarrayBy( buf, {} ); // $ExpectError - - filledarrayBy( buf, '5', {} ); // $ExpectError - filledarrayBy( buf, 1.0, {} ); // $ExpectError - filledarrayBy( buf, false, {} ); // $ExpectError - filledarrayBy( buf, true, {} ); // $ExpectError - filledarrayBy( buf, null, {} ); // $ExpectError - filledarrayBy( buf, undefined, {} ); // $ExpectError - filledarrayBy( buf, [], {} ); // $ExpectError - filledarrayBy( buf, {}, {} ); // $ExpectError - - filledarrayBy( buf, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 'float64', false ); // $ExpectError - filledarrayBy( buf, 'float64', true ); // $ExpectError - filledarrayBy( buf, 'float64', null ); // $ExpectError - filledarrayBy( buf, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 'float64', {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5' ); // $ExpectError - filledarrayBy( buf, 8, 1.0 ); // $ExpectError - filledarrayBy( buf, 8, false ); // $ExpectError - filledarrayBy( buf, 8, true ); // $ExpectError - filledarrayBy( buf, 8, null ); // $ExpectError - filledarrayBy( buf, 8, undefined ); // $ExpectError - filledarrayBy( buf, 8, [] ); // $ExpectError - filledarrayBy( buf, 8, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, false, {} ); // $ExpectError - filledarrayBy( buf, 8, true, {} ); // $ExpectError - filledarrayBy( buf, 8, null, {} ); // $ExpectError - filledarrayBy( buf, 8, undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, [], {} ); // $ExpectError - filledarrayBy( buf, 8, {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 8, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 'float64', false ); // $ExpectError - filledarrayBy( buf, 8, 'float64', true ); // $ExpectError - filledarrayBy( buf, 8, 'float64', null ); // $ExpectError - filledarrayBy( buf, 8, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 8, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 8, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 8, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, '5' ); // $ExpectError - filledarrayBy( buf, 8, 2, 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 2, false ); // $ExpectError - filledarrayBy( buf, 8, 2, true ); // $ExpectError - filledarrayBy( buf, 8, 2, null ); // $ExpectError - filledarrayBy( buf, 8, 2, undefined ); // $ExpectError - filledarrayBy( buf, 8, 2, [] ); // $ExpectError - filledarrayBy( buf, 8, 2, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, false, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, true, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, null, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, [], {} ); // $ExpectError - filledarrayBy( buf, 8, 2, {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', false ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', true ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', null ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', {}, {} ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid length, typed array, array-like object, `ArrayBuffer`, or iterable argument... -{ - filledarrayBy( false, clbk ); // $ExpectError - filledarrayBy( true, clbk ); // $ExpectError - filledarrayBy( null, clbk ); // $ExpectError - filledarrayBy( {}, clbk ); // $ExpectError - - filledarrayBy( false, clbk, {} ); // $ExpectError - filledarrayBy( true, clbk, {} ); // $ExpectError - filledarrayBy( null, clbk, {} ); // $ExpectError - filledarrayBy( {}, clbk, {} ); // $ExpectError - - filledarrayBy( false, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 'float64', clbk ); // $ExpectError - - filledarrayBy( false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, clbk ); // $ExpectError - filledarrayBy( 1.0, 8, clbk ); // $ExpectError - filledarrayBy( false, 8, clbk ); // $ExpectError - filledarrayBy( true, 8, clbk ); // $ExpectError - filledarrayBy( null, 8, clbk ); // $ExpectError - filledarrayBy( undefined, 8, clbk ); // $ExpectError - filledarrayBy( [], 8, clbk ); // $ExpectError - filledarrayBy( {}, 8, clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, clbk ); // $ExpectError - - filledarrayBy( '5', 8, clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, clbk, {} ); // $ExpectError - filledarrayBy( false, 8, clbk, {} ); // $ExpectError - filledarrayBy( true, 8, clbk, {} ); // $ExpectError - filledarrayBy( null, 8, clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, clbk, {} ); // $ExpectError - filledarrayBy( [], 8, clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 'float64', clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( false, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( [], 8, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 'float64', clbk ); // $ExpectError - - filledarrayBy( '5', 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 2, clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 2, clbk ); // $ExpectError - filledarrayBy( false, 8, 2, clbk ); // $ExpectError - filledarrayBy( true, 8, 2, clbk ); // $ExpectError - filledarrayBy( null, 8, 2, clbk ); // $ExpectError - filledarrayBy( undefined, 8, 2, clbk ); // $ExpectError - filledarrayBy( [], 8, 2, clbk ); // $ExpectError - filledarrayBy( {}, 8, 2, clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, clbk ); // $ExpectError - - filledarrayBy( '5', 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( false, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( [], 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, 'float64', clbk ); // $ExpectError - - filledarrayBy( '5', 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a byte offset argument which is not a number... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, false, clbk ); // $ExpectError - filledarrayBy( buf, true, clbk ); // $ExpectError - filledarrayBy( buf, null, clbk ); // $ExpectError - filledarrayBy( buf, [], clbk ); // $ExpectError - filledarrayBy( buf, {}, clbk ); // $ExpectError - - filledarrayBy( buf, false, clbk, {} ); // $ExpectError - filledarrayBy( buf, true, clbk, {} ); // $ExpectError - filledarrayBy( buf, null, clbk, {} ); // $ExpectError - filledarrayBy( buf, [], clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, clbk, {} ); // $ExpectError - - filledarrayBy( buf, '5', 'float64', clbk ); // $ExpectError - filledarrayBy( buf, false, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, true, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, null, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, [], 'float64', clbk ); // $ExpectError - filledarrayBy( buf, {}, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, '5', 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( buf, false, 2, clbk ); // $ExpectError - filledarrayBy( buf, true, 2, clbk ); // $ExpectError - filledarrayBy( buf, null, 2, clbk ); // $ExpectError - filledarrayBy( buf, [], 2, clbk ); // $ExpectError - filledarrayBy( buf, {}, 2, clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, clbk ); // $ExpectError - - filledarrayBy( buf, false, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, clbk, {} ); // $ExpectError - - filledarrayBy( buf, '5', 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, false, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, true, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, null, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, undefined, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, [], 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, {}, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, '5', 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, false, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, undefined, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a view length argument which is not a number... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, 8, false, clbk ); // $ExpectError - filledarrayBy( buf, 8, true, clbk ); // $ExpectError - filledarrayBy( buf, 8, null, clbk ); // $ExpectError - filledarrayBy( buf, 8, [], clbk ); // $ExpectError - filledarrayBy( buf, 8, {}, clbk ); // $ExpectError - - filledarrayBy( buf, 8, false, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, true, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, null, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, [], clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, {}, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, clbk, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5', 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, false, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, true, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, null, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, [], 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, {}, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, 8, '5', 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, [], 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, {}, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided too many arguments... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, 8, 2, 'float64', 1, clbk, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 997a381..0000000 --- a/examples/index.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ).factory; -var dtypes = require( '@stdlib/array-typed-real-dtypes' ); -var filledarrayBy = require( './../lib' ); - -// Create a pseudorandom number generator: -var rand = discreteUniform( 0, 100 ); - -// Get a list of array data types: -var dt = dtypes(); - -// Generate filled arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = filledarrayBy( 10, dt[ i ], rand ); - console.log( arr ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 3fc2784..2156674 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { RealOrComplexTypedArray, DataType } from '@stdlib/types/array'; import { Collection } from '@stdlib/types/object'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..ce0d7c1 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-ctors@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill-by@v0.0.10-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled-by@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";var w=d();function j(r,e,t){var s,i;for(s=[],i=-1;!r.next().done;)i+=1,s.push(e.call(t,i));return s}function a(r,e,t){var s;for(s=0;s1)throw new TypeError(p("00L05"));if(null===(b=o(g)))throw new TypeError(p("00L2k",g));return new b(0)}if(c<2)throw new TypeError(p("00L05"));if(n(arguments[c-=1]))if(n(arguments[c-1])){if(d=arguments[c],y=arguments[c-=1],0===c)throw new TypeError(p("00L05"))}else y=arguments[c];else{if(!(c>=2))throw new TypeError(p("00L05"));if(d=arguments[c],!n(y=arguments[c-=1]))throw new TypeError(p("00L2n",y))}if((c-=1)>=0&&r(arguments[c])?(g=arguments[c],c-=1):g="float64",null===(b=o(g)))throw new TypeError(p("00L2k",g));if("generic"===g){if(x=arguments[0],0===c){if(e(x)?u=x:t(x)&&(u=x.length),void 0!==u)return m(u,y,d);if(s(x))throw new Error(p("00L04"));if(i(x)){if(!1===w)throw new TypeError(p("00L2l",x));if(!n(x[f]))throw new TypeError(p("00L2m",x));if(x=x[f](),!n(x.next))throw new TypeError(p("00L2m",x));return j(x,y,d)}throw new TypeError(p("00L2m",x))}if(s(x))throw new Error(p("00L04"));throw new TypeError(p("00L2m",x))}if(0===c)if(t(x=arguments[0]))v=new b(x.length);else if(s(x))v=new b(x);else if(e(x))v=new b(x);else{if(!i(x))throw new TypeError(p("00L2m",x));if(!1===w)throw new TypeError(p("00L2l",x));if(!n(x[f]))throw new TypeError(p("00L2m",x));if(x=x[f](),!n(x.next))throw new TypeError(p("00L2m",x));v=new b(h(x))}else v=1===c?new b(arguments[0],arguments[1]):new b(arguments[0],arguments[1],arguments[2]);return v.length>0&&(/^complex/.test(g)?a(v,y,d):l(v.length,v,1,E)),v;function E(r,e){return y.call(d,e)}}export{c as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..4c947f8 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.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\nimport { isPrimitive as isString } from '@stdlib/assert-is-string' ;\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer' ;\nimport isCollection from '@stdlib/assert-is-collection' ;\nimport isArrayBuffer from '@stdlib/assert-is-arraybuffer' ;\nimport isObject from '@stdlib/assert-is-object' ;\nimport isFunction from '@stdlib/assert-is-function' ;\nimport ctors from '@stdlib/array-ctors' ;\nimport gfillBy from '@stdlib/blas-ext-base-gfill-by' ;\nimport filledArray from '@stdlib/array-base-filled-by' ;\nimport hasIteratorSymbolSupport from '@stdlib/assert-has-iterator-symbol-support' ;\nimport ITERATOR_SYMBOL from '@stdlib/symbol-iterator' ;\nimport iterLength from '@stdlib/iter-length' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\n\n\n// VARIABLES //\n\nvar HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport();\nvar DEFAULT_DTYPE = 'float64';\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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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( format( '00L05' ) );\n\t\t}\n\t\tctor = ctors( dtype );\n\t\tif ( ctor === null ) {\n\t\t\tthrow new TypeError( format( '00L2k', 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( format( '00L05' ) );\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( format( '00L05' ) );\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( '00L2n', 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( format( '00L05' ) );\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( '00L2k', 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( format( '00L04' ) );\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( '00L2l', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00L2m', 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( '00L2m', 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( '00L2m', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format( '00L04' ) );\n\t\t}\n\t\tthrow new TypeError( format( '00L2m', 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( '00L2l', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00L2m', 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( '00L2m', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00L2m', 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\nexport default filledarrayBy;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","filledArrayIterator","it","clbk","thisArg","arr","i","next","done","push","call","filledAccessors","length","set","filledarrayBy","nargs","dtype","ctor","len","arg","arguments","ctors","isString","TypeError","format","isFunction","isNonNegativeInteger","isCollection","filledArray","isArrayBuffer","Error","isObject","ITERATOR_SYMBOL","iterLength","test","gfillBy","callback","value","aidx"],"mappings":";;gqCAuCA,IAAIA,EAAsBC,IAe1B,SAASC,EAAqBC,EAAIC,EAAMC,GACvC,IAAIC,EACAC,EAKJ,IAFAD,EAAM,GACNC,GAAK,GAEAJ,EAAGK,OACAC,MAGPF,GAAK,EACLD,EAAII,KAAMN,EAAKO,KAAMN,EAASE,IAE/B,OAAOD,CACR,CAWA,SAASM,EAAiBN,EAAKF,EAAMC,GACpC,IAAIE,EACJ,IAAMA,EAAI,EAAGA,EAAID,EAAIO,OAAQN,IAC5BD,EAAIQ,IAAKV,EAAKO,KAAMN,EAASE,GAAKA,GAEnC,OAAOD,CACR,CA4JA,SAASS,IACR,IAAIV,EACAW,EACAC,EACAb,EACAc,EACAZ,EACAa,EACAC,EAKJ,GAAe,KAHfJ,EAAQK,UAAUR,QAKjB,OAAO,IADPK,EAAOI,EAzNW,YA0ND,GAIlB,GAAKC,EADLN,EAAQI,UAAW,IACM,CAExB,GAAKL,EAAQ,EACZ,MAAM,IAAIQ,UAAWC,EAAQ,UAG9B,GAAc,QADdP,EAAOI,EAAOL,IAEb,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAGvC,OAAO,IAAIC,EAAM,EACjB,CAED,GAAKF,EAAQ,EACZ,MAAM,IAAIQ,UAAWC,EAAQ,UAM9B,GAAKC,EAAYL,UAHjBL,GAAS,IAKR,GAAKU,EAAYL,UAAWL,EAAM,KAMjC,GALAX,EAAUgB,UAAWL,GAErBZ,EAAOiB,UADPL,GAAS,GAIM,IAAVA,EACJ,MAAM,IAAIQ,UAAWC,EAAQ,eAI9BrB,EAAOiB,UAAWL,OAIf,MAAKA,GAAS,GAUlB,MAAM,IAAIQ,UAAWC,EAAQ,UAN7B,GAHApB,EAAUgB,UAAWL,IAGfU,EADNtB,EAAOiB,UADPL,GAAS,IAGR,MAAM,IAAIQ,UAAWC,EAAQ,QAASrB,GAMvC,CAUD,IARAY,GAAS,IACK,GAAKO,EAAUF,UAAWL,KACvCC,EAAQI,UAAWL,GACnBA,GAAS,GAETC,EArRkB,UAwRL,QADdC,EAAOI,EAAOL,IAEb,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAGvC,GAAe,YAAVA,EAAsB,CAE1B,GADAG,EAAMC,UAAW,GACF,IAAVL,EAAc,CAMlB,GALKW,EAAsBP,GAC1BD,EAAMC,EACKQ,EAAcR,KACzBD,EAAMC,EAAIP,aAEE,IAARM,EACJ,OAAOU,EAAaV,EAAKf,EAAMC,GAEhC,GAAKyB,EAAeV,GACnB,MAAM,IAAIW,MAAON,EAAQ,UAE1B,GAAKO,EAAUZ,GAAQ,CACtB,IAA6B,IAAxBpB,EACJ,MAAM,IAAIwB,UAAWC,EAAQ,QAASL,IAEvC,IAAMM,EAAYN,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASL,IAGvC,GADAA,EAAMA,EAAKa,MACLP,EAAYN,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,QAASL,IAEvC,OAAOlB,EAAqBkB,EAAKhB,EAAMC,EACvC,CACD,MAAM,IAAImB,UAAWC,EAAQ,QAASL,GACzC,CAAS,GAAKU,EAAeV,GAC1B,MAAM,IAAIW,MAAON,EAAQ,UAE1B,MAAM,IAAID,UAAWC,EAAQ,QAASL,GACtC,CACD,GAAe,IAAVJ,EAEJ,GAAKY,EADLR,EAAMC,UAAW,IAEhBf,EAAM,IAAIY,EAAME,EAAIP,aACd,GAAKiB,EAAeV,GAC1Bd,EAAM,IAAIY,EAAME,QACV,GAAKO,EAAsBP,GACjCd,EAAM,IAAIY,EAAME,OACV,KAAKY,EAAUZ,GAarB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAZtC,IAA6B,IAAxBpB,EACJ,MAAM,IAAIwB,UAAWC,EAAQ,QAASL,IAEvC,IAAMM,EAAYN,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASL,IAGvC,GADAA,EAAMA,EAAKa,MACLP,EAAYN,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,QAASL,IAEvCd,EAAM,IAAIY,EAAMgB,EAAYd,GAG5B,MAEDd,EADqB,IAAVU,EACL,IAAIE,EAAMG,UAAU,GAAIA,UAAU,IAElC,IAAIH,EAAMG,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKf,EAAIO,OAAS,IACZ,WAAWsB,KAAMlB,GACrBL,EAAiBN,EAAKF,EAAMC,GAE5B+B,EAAS9B,EAAIO,OAAQP,EAAK,EAAG+B,IAGxB/B,EAYP,SAAS+B,EAAUC,EAAOC,GACzB,OAAOnC,EAAKO,KAAMN,EAASkC,EAC3B,CACF"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d115cf0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,192 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -/** -* Create a filled array according to a provided callback function. -* -* @module @stdlib/array-filled-by -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* var arr = filledarrayBy(); -* // returns -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'generic', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( [ 0.5, 0.5 ], clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1; -* } -* -* var arr = filledarrayBy( [ 5, -3 ], 'int32', clbk ); -* // returns [ 1, 1 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk1() { -* return 10; -* } -* -* function clbk2() { -* return 1.0; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, clbk2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk1() { -* return 1.0; -* } -* -* function clbk2() { -* return 2; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, 'uint32', clbk2 ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 'float32', clbk ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, clbk ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, 'int32', clbk ); -* // returns [ 1, 1 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index d6fbe5e..0000000 --- a/lib/main.js +++ /dev/null @@ -1,413 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var isCollection = require( '@stdlib/assert-is-collection' ); -var isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isObject = require( '@stdlib/assert-is-object' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var ctors = require( '@stdlib/array-ctors' ); -var gfillBy = require( '@stdlib/blas-ext-base-gfill-by' ); -var filledArray = require( '@stdlib/array-base-filled-by' ); -var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var iterLength = require( '@stdlib/iter-length' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport(); -var DEFAULT_DTYPE = 'float64'; - - -// FUNCTIONS // - -/** -* Creates a filled "generic" array from an iterator. -* -* @private -* @param {Iterable} it - iterator -* @param {Callback} clbk - callback function -* @param {*} thisArg - callback function execution context -* @returns {Array} filled array -*/ -function filledArrayIterator( it, clbk, thisArg ) { - var arr; - var i; - var v; - - arr = []; - i = -1; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - i += 1; - arr.push( clbk.call( thisArg, i ) ); - } - return arr; -} - -/** -* Fills an array exposing accessors for getting and setting array elements. -* -* @private -* @param {Collection} arr - input array -* @param {Callback} clbk - callback function -* @param {*} thisArg - callback function execution context -* @returns {Collection} input array -*/ -function filledAccessors( arr, clbk, thisArg ) { - var i; - for ( i = 0; i < arr.length; i++ ) { - arr.set( clbk.call( thisArg, i ), i ); - } - return arr; -} - - -// MAIN // - -/** -* Creates a filled array according to a provided callback function. -* -* @param {(NonNegativeInteger|TypedArray|ArrayLikeObject|ArrayBuffer|Iterable)} [arg] - a length, typed array, array-like object, buffer, or iterable -* @param {NonNegativeInteger} [byteOffset=0] - byte offset -* @param {NonNegativeInteger} [length] - view length -* @param {string} [dtype="float64"] - data type -* @param {Callback} [clbk] - callback to invoke -* @param {*} [thisArg] - callback execution context -* @throws {TypeError} must provide a recognized data type -* @throws {TypeError} must provide a length, typed array, array-like object, buffer, or iterable -* @throws {TypeError} callback argument must be a function. -* @throws {Error} creating a generic array from an `ArrayBuffer` is not supported -* @returns {(TypedArray|Array)} array or typed array -* -* @example -* var arr = filledarrayBy(); -* // returns -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'generic', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( [ 0.5, 0.5 ], clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1; -* } -* -* var arr = filledarrayBy( [ 5, -3 ], 'int32', clbk ); -* // returns [ 1, 1 ] -* -* @example -* function clbk1() { -* return 10; -* } -* -* function clbk2() { -* return 1.0; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, clbk2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk1() { -* return 1.0; -* } -* -* function clbk2() { -* return 2; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, 'uint32', clbk2 ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 'float32', clbk ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, clbk ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, 'int32', clbk ); -* // returns [ 1, 1 ] -*/ -function filledarrayBy() { - var thisArg; - var nargs; - var dtype; - var clbk; - var ctor; - var arr; - var len; - var arg; - - nargs = arguments.length; - - // If we weren't provided any arguments, return an empty array... - if ( nargs === 0 ) { - ctor = ctors( DEFAULT_DTYPE ); - return new ctor( 0 ); - } - // Check if we were provided a dtype as the first argument... - dtype = arguments[ 0 ]; - if ( isString( dtype ) ) { - // Invoking this function with arguments `f( dtype, clbk[, thisArg] )` is not allowed (otherwise, we'd need to also allow `f( clbk[, thisArg] )`)... - if ( nargs > 1 ) { - throw new TypeError( format( '00L05' ) ); - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '00L2k', dtype ) ); - } - // Return an empty array having the specified dtype: - return new ctor( 0 ); - } - // For all other supported invocations, we need at least two arguments... - if ( nargs < 2 ) { - throw new TypeError( format( '00L05' ) ); - } - // At this point, we need to do some argument juggling... - nargs -= 1; // henceforth, the number of available arguments is `nargs+1` - - // Determine whether the last argument is a callback or "this" context... - if ( isFunction( arguments[ nargs ] ) ) { - // 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... - if ( isFunction( arguments[ nargs-1 ] ) ) { - thisArg = arguments[ nargs ]; - nargs -= 1; - clbk = arguments[ nargs ]; - - // Check if we were provided only a callback and a "this" context.. - if ( nargs === 0 ) { - throw new TypeError( format( '00L05' ) ); - } - } else { - // "this" context is left undefined... - clbk = arguments[ nargs ]; - } - } - // 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... - else if ( nargs >= 2 ) { - thisArg = arguments[ nargs ]; - nargs -= 1; - clbk = arguments[ nargs ]; - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '00L2n', clbk ) ); - } - } - // If were were only provided 2 arguments and the last argument was not a function, we've been provided an insufficient number of arguments... - else { - throw new TypeError( format( '00L05' ) ); - } - // Now that we've processed the callback arguments, let's continue working backward to see if we've been provided a `dtype` argument... - nargs -= 1; - if ( nargs >= 0 && isString( arguments[ nargs ] ) ) { - dtype = arguments[ nargs ]; - nargs -= 1; - } else { - dtype = DEFAULT_DTYPE; - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '00L2k', dtype ) ); - } - // At this point, we've resolved the output array data type, and now we can actually create the output array... - if ( dtype === 'generic' ) { - arg = arguments[ 0 ]; - if ( nargs === 0 ) { - if ( isNonNegativeInteger( arg ) ) { - len = arg; - } else if ( isCollection( arg ) ) { - len = arg.length; - } - if ( len !== void 0 ) { - return filledArray( len, clbk, thisArg ); - } - if ( isArrayBuffer( arg ) ) { - throw new Error( format( '00L04' ) ); - } - if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( '00L2l', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00L2m', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00L2m', arg ) ); - } - return filledArrayIterator( arg, clbk, thisArg ); - } - throw new TypeError( format( '00L2m', arg ) ); - } else if ( isArrayBuffer( arg ) ) { - throw new Error( format( '00L04' ) ); - } - throw new TypeError( format( '00L2m', arg ) ); - } - if ( nargs === 0 ) { // length || array-like || ArrayBuffer || iterable - arg = arguments[ 0 ]; - if ( isCollection( arg ) ) { - arr = new ctor( arg.length ); - } else if ( isArrayBuffer( arg ) ) { - arr = new ctor( arg ); - } else if ( isNonNegativeInteger( arg ) ) { - arr = new ctor( arg ); - } else if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( '00L2l', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00L2m', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00L2m', arg ) ); - } - arr = new ctor( iterLength( arg ) ); - } else { - throw new TypeError( format( '00L2m', arg ) ); - } - } else if ( nargs === 1 ) { - arr = new ctor( arguments[0], arguments[1] ); // (ArrayBuffer, byteOffset) - } else { - arr = new ctor( arguments[0], arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset, length) - } - if ( arr.length > 0 ) { - if ( /^complex/.test( dtype ) ) { - filledAccessors( arr, clbk, thisArg ); - } else { - gfillBy( arr.length, arr, 1, callback ); - } - } - return arr; - - /** - * Callback which wraps a provided callback and is invoked for each array element. - * - * @private - * @param {*} value - element value - * @param {NonNegativeInteger} aidx - array index - * @param {NonNegativeInteger} sidx - strided index - * @param {Collection} array - input array/collection - * @returns {*} callback return value - */ - function callback( value, aidx ) { - return clbk.call( thisArg, aidx ); - } -} - - -// EXPORTS // - -module.exports = filledarrayBy; diff --git a/package.json b/package.json index 6511a88..498622b 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.2", "description": "Create a filled array according to a provided callback function.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,69 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-filled-by": "^0.0.x", - "@stdlib/array-ctors": "^0.0.x", - "@stdlib/assert-has-iterator-symbol-support": "^0.0.x", - "@stdlib/assert-is-arraybuffer": "^0.0.x", - "@stdlib/assert-is-collection": "^0.0.x", - "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/assert-is-nonnegative-integer": "^0.0.x", - "@stdlib/assert-is-object": "^0.0.x", - "@stdlib/assert-is-string": "^0.0.x", - "@stdlib/blas-ext-base-gfill-by": "^0.0.x", - "@stdlib/iter-length": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x", - "@stdlib/symbol-iterator": "^0.0.x", - "@stdlib/types": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-buffer": "^0.0.x", - "@stdlib/array-complex128": "^0.0.x", - "@stdlib/array-complex64": "^0.0.x", - "@stdlib/array-float32": "^0.0.x", - "@stdlib/array-float64": "^0.0.x", - "@stdlib/array-int16": "^0.0.x", - "@stdlib/array-int32": "^0.0.x", - "@stdlib/array-int8": "^0.0.x", - "@stdlib/array-typed-real-dtypes": "^0.0.x", - "@stdlib/array-uint16": "^0.0.x", - "@stdlib/array-uint32": "^0.0.x", - "@stdlib/array-uint8": "^0.0.x", - "@stdlib/array-uint8c": "^0.0.x", - "@stdlib/assert-instance-of": "^0.0.x", - "@stdlib/assert-is-array": "^0.0.x", - "@stdlib/assert-is-typed-array": "^0.0.x", - "@stdlib/assert-is-typed-array-like": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/complex-float32": "^0.0.x", - "@stdlib/complex-float64": "^0.0.x", - "@stdlib/iter-constant": "^0.0.x", - "@stdlib/math-base-special-pow": "^0.0.x", - "@stdlib/random-base-discrete-uniform": "^0.0.x", - "@stdlib/strided-base-reinterpret-complex128": "^0.0.x", - "@stdlib/strided-base-reinterpret-complex64": "^0.0.x", - "@stdlib/utils-constant-function": "^0.0.x", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..892348a --- /dev/null +++ b/stats.html @@ -0,0 +1,4044 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index b55aa4a..0000000 --- a/test/test.js +++ /dev/null @@ -1,4248 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 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. -*/ - -/* eslint-disable max-len */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -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 ArrayBuffer = require( '@stdlib/array-buffer' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var iterConstant = require( '@stdlib/iter-constant' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var filledarrayBy = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': !hasIteratorSymbolSupport() -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof filledarrayBy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if only provided callback arguments', function test( t ) { - t.throws( clbk1, TypeError, 'throws an error' ); - t.throws( clbk2, TypeError, 'throws an error' ); - t.throws( clbk3, TypeError, 'throws an error' ); - t.end(); - - function clbk1() { - filledarrayBy( constantFunction( 1.0 ) ); - } - - function clbk2() { - filledarrayBy( constantFunction( 1.0 ), {} ); - } - - function clbk3() { - filledarrayBy( constantFunction( 1.0 ), constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (only argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (typed array; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (array-like object)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (array-like object; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 8 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 8 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, 1, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (iterator)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( iterConstant( 1.0 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (iterator; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( iterConstant( 1.0 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if only provided data type and callback arguments', function test( t ) { - t.throws( clbk1, TypeError, 'throws an error' ); - t.throws( clbk2, TypeError, 'throws an error' ); - t.throws( clbk3, TypeError, 'throws an error' ); - t.end(); - - function clbk1() { - filledarrayBy( 'float64', constantFunction( 1.0 ) ); - } - - function clbk2() { - filledarrayBy( 'float64', constantFunction( 1.0 ), {} ); - } - - function clbk3() { - filledarrayBy( 'float64', constantFunction( 1.0 ), constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (array-like object)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (array-like object; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, 1, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, 1, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (no iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (no iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (non-function iterator symbol property)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (non-function iterator symbol property; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (`next` property is not a function)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ) ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (`next` property is not a function; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ), {} ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (no iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (no iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (non-function iterator symbol property)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (non-function iterator symbol property; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (`next` property is not a function)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ) ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (`next` property is not a function; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ), {} ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 1, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 1, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function returns a filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - arr = filledarrayBy(); - - t.strictEqual( instanceOf( arr, Float64Array ), 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=float64)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - arr = filledarrayBy( 'float64' ); - - t.strictEqual( instanceOf( arr, Float64Array ), 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=float32)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( 0 ); - arr = filledarrayBy( 'float32' ); - - t.strictEqual( instanceOf( arr, Float32Array ), 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; - - expected = new Complex128Array( 0 ); - arr = filledarrayBy( 'complex128' ); - - t.strictEqual( instanceOf( arr, Complex128Array ), 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=complex64)', function test( t ) { - var expected; - var arr; - - expected = new Complex64Array( 0 ); - arr = filledarrayBy( 'complex64' ); - - t.strictEqual( instanceOf( arr, Complex64Array ), 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=int32)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( 0 ); - arr = filledarrayBy( 'int32' ); - - t.strictEqual( instanceOf( arr, Int32Array ), 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=uint32)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( 0 ); - arr = filledarrayBy( 'uint32' ); - - t.strictEqual( instanceOf( arr, Uint32Array ), 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=int16)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( 0 ); - arr = filledarrayBy( 'int16' ); - - t.strictEqual( instanceOf( arr, Int16Array ), 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=uint16)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( 0 ); - arr = filledarrayBy( 'uint16' ); - - t.strictEqual( instanceOf( arr, Uint16Array ), 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=int8)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( 0 ); - arr = filledarrayBy( 'int8' ); - - t.strictEqual( instanceOf( arr, Int8Array ), 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=uint8)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( 0 ); - arr = filledarrayBy( 'uint8' ); - - t.strictEqual( instanceOf( arr, Uint8Array ), 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=uint8c)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( 0 ); - arr = filledarrayBy( 'uint8c' ); - - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), 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=generic)', function test( t ) { - var expected; - var arr; - - expected = []; - arr = filledarrayBy( 'generic' ); - - t.strictEqual( instanceOf( arr, Array ), 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 (default, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, length=0)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array(); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 0, clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, clbk, ctx ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (default, length; thisArg=function)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, clbk, context ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this(); // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } - - function context() { - ctx.count += 1; - } -}); - -tape( 'the function returns a filled array (dtype=float64, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, 'float64', clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, length; thisArg=function)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, 'float64', clbk, context ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this(); // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } - - function context() { - ctx.count += 1; - } -}); - -tape( 'the function returns a filled array (dtype=float32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, 'float32', clbk ); - - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex128, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = filledarrayBy( 5, 'complex128', clbk ); - - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = filledarrayBy( 5, 'complex64', clbk ); - - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int32Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int32', clbk ); - - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint32Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint32', clbk ); - - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int16Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int16', clbk ); - - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint16', clbk ); - - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int8Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int8', clbk ); - - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint8', clbk ); - - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint8c', clbk ); - - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = [ 1, 1, 1, 1, 1 ]; - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'generic', clbk ); - - t.strictEqual( instanceOf( arr, Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex128, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = [ 1.0, 2.0 ]; - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = [ 1.0, 2.0 ]; - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int32', clbk ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, typed array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, typed array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex128, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = new Float64Array( [ 1.0, 2.0 ] ); - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = new Float64Array( [ 1.0, 2.0 ] ); - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (default, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex128, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer, byteoffset; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer, byteoffset; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, 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; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 48 ); - out = filledarrayBy( buf, 16, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 24 ); - out = filledarrayBy( buf, 8, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int32', clbk ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint8c', clbk ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, 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; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 64 ); - out = filledarrayBy( buf, 16, 2, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset, length)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 1, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 1, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled array (default, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, iterator; thisArg)', opts, function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - ctx = { - 'count': 0 - }; - indices = []; - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, iterator; thisArg)', opts, function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - ctx = { - 'count': 0 - }; - indices = []; - out = filledarrayBy( arr, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex128, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = iterConstant( new Complex128( 3.0, 3.0 ), { - 'iter': 2 - }); - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = iterConstant( new Complex64( 3.0, 3.0 ), { - 'iter': 2 - }); - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); From 61e7bfc4b2ef0c18c6ae8d877162bac6fc0a3ad7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Dec 2022 04:48:09 +0000 Subject: [PATCH 026/117] Transform error messages --- lib/main.js | 38 +++++++++++++++++++------------------- package.json | 2 +- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/lib/main.js b/lib/main.js index d27b055..d6fbe5e 100644 --- a/lib/main.js +++ b/lib/main.js @@ -32,7 +32,7 @@ var filledArray = require( '@stdlib/array-base-filled-by' ); var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); var iterLength = require( '@stdlib/iter-length' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -263,18 +263,18 @@ function filledarrayBy() { if ( isString( dtype ) ) { // Invoking this function with arguments `f( dtype, clbk[, thisArg] )` is not allowed (otherwise, we'd need to also allow `f( clbk[, thisArg] )`)... if ( nargs > 1 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format( '00L05' ) ); } ctor = ctors( dtype ); if ( ctor === null ) { - throw new TypeError( format( 'invalid argument. Must provide a recognized data type. Value: `%s`.', dtype ) ); + throw new TypeError( format( '00L2k', dtype ) ); } // Return an empty array having the specified dtype: return new ctor( 0 ); } // For all other supported invocations, we need at least two arguments... if ( nargs < 2 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format( '00L05' ) ); } // At this point, we need to do some argument juggling... nargs -= 1; // henceforth, the number of available arguments is `nargs+1` @@ -289,7 +289,7 @@ function filledarrayBy() { // Check if we were provided only a callback and a "this" context.. if ( nargs === 0 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format( '00L05' ) ); } } else { // "this" context is left undefined... @@ -302,12 +302,12 @@ function filledarrayBy() { nargs -= 1; clbk = arguments[ nargs ]; if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '00L2n', clbk ) ); } } // If were were only provided 2 arguments and the last argument was not a function, we've been provided an insufficient number of arguments... else { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format( '00L05' ) ); } // Now that we've processed the callback arguments, let's continue working backward to see if we've been provided a `dtype` argument... nargs -= 1; @@ -319,7 +319,7 @@ function filledarrayBy() { } ctor = ctors( dtype ); if ( ctor === null ) { - throw new TypeError( format( 'invalid argument. Must provide a recognized data type. Value: `%s`.', dtype ) ); + throw new TypeError( format( '00L2k', dtype ) ); } // At this point, we've resolved the output array data type, and now we can actually create the output array... if ( dtype === 'generic' ) { @@ -334,26 +334,26 @@ function filledarrayBy() { return filledArray( len, clbk, thisArg ); } if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format( '00L04' ) ); } if ( isObject( arg ) ) { if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.', arg ) ); + throw new TypeError( format( '00L2l', arg ) ); } if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00L2m', arg ) ); } arg = arg[ ITERATOR_SYMBOL ](); if ( !isFunction( arg.next ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00L2m', arg ) ); } return filledArrayIterator( arg, clbk, thisArg ); } - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00L2m', arg ) ); } else if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format( '00L04' ) ); } - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00L2m', arg ) ); } if ( nargs === 0 ) { // length || array-like || ArrayBuffer || iterable arg = arguments[ 0 ]; @@ -365,18 +365,18 @@ function filledarrayBy() { arr = new ctor( arg ); } else if ( isObject( arg ) ) { if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.', arg ) ); + throw new TypeError( format( '00L2l', arg ) ); } if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00L2m', arg ) ); } arg = arg[ ITERATOR_SYMBOL ](); if ( !isFunction( arg.next ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00L2m', arg ) ); } arr = new ctor( iterLength( arg ) ); } else { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00L2m', arg ) ); } } else if ( nargs === 1 ) { arr = new ctor( arguments[0], arguments[1] ); // (ArrayBuffer, byteOffset) diff --git a/package.json b/package.json index ae07654..6201757 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "@stdlib/assert-is-string": "^0.0.x", "@stdlib/blas-ext-base-gfill-by": "^0.0.x", "@stdlib/iter-length": "^0.0.x", - "@stdlib/string-format": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x", "@stdlib/symbol-iterator": "^0.0.x", "@stdlib/types": "^0.0.x" }, From 08aecc2d459cbcac74d7d24269fb254f1a4d0636 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Dec 2022 19:00:17 +0000 Subject: [PATCH 027/117] Remove files --- index.d.ts | 427 ------ index.mjs | 4 - index.mjs.map | 1 - stats.html | 4044 ------------------------------------------------- 4 files changed, 4476 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 2156674..0000000 --- a/index.d.ts +++ /dev/null @@ -1,427 +0,0 @@ -/* -* @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. -*/ - -// TypeScript Version: 2.0 - -/// - -import { RealOrComplexTypedArray, DataType } from '@stdlib/types/array'; -import { Collection } from '@stdlib/types/object'; -import { IterableIterator } from '@stdlib/types/iter'; - -/** -* Array or typed array. -*/ -type ArrayOrTypedArray = Array | RealOrComplexTypedArray; - -/** -* Nullary callback function. -* -* @returns fill value -*/ -type Nullary = () => any; - -/** -* Unary callback function. -* -* @param i - current array index -* @returns fill value -*/ -type Unary = ( i: number ) => any; - -/** -* Callback function. -* -* @param i - current array index -* @returns fill value -*/ -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 -* -* @example -* var arr = filledarrayBy(); -* // returns -* -* @example -* var arr = filledarrayBy( 'float32' ); -* // returns -*/ -declare function filledarrayBy( dtype?: DataType ): ArrayOrTypedArray; // tslint:disable-line:unified-signatures - -/** -* Creates a filled array according to a provided callback function and having a specified `length`. -* -* @param length - array length -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* -* var arr = filledarrayBy( 5, constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( length: number, clbk: Callback, thisArg?: any ): ArrayOrTypedArray; // tslint:disable-line:max-line-length unified-signatures - -/** -* 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 -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* -* var arr = filledarrayBy( 5, 'float64', constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( length: number, dtype: DataType, clbk: Callback, thisArg?: any ): ArrayOrTypedArray; // tslint:disable-line:max-line-length unified-signatures - -/** -* Creates a filled array from another `array` according to a provided callback function. -* -* @param array - typed array or array-like object -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* -* 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; // tslint:disable-line:max-line-length 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 -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* -* 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; // tslint:disable-line:max-line-length unified-signatures - -/** -* Creates a filled array from an iterable according to a callback function. -* -* @param iterable - iterable -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* var iterConstant = require( `@stdlib/iter/constant` ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarrayBy( it, constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( iterable: IterableIterator, callback: Callback, thisArg?: any ): ArrayOrTypedArray; // tslint:disable-line:max-line-length 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 -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* var iterConstant = require( `@stdlib/iter/constant` ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* 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; // tslint:disable-line:max-line-length unified-signatures - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; // tslint:disable-line:max-line-length - -/** -* 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. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; // tslint:disable-line:max-line-length unified-signatures - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; // tslint:disable-line:max-line-length - -/** -* 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. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; // tslint:disable-line:max-line-length unified-signatures - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; // tslint:disable-line:max-line-length 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. -* -* @param buffer - `ArrayBuffer` -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; // tslint:disable-line:max-line-length unified-signatures - - -// EXPORTS // - -export = filledarrayBy; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index ce0d7c1..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-ctors@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill-by@v0.0.10-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled-by@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";var w=d();function j(r,e,t){var s,i;for(s=[],i=-1;!r.next().done;)i+=1,s.push(e.call(t,i));return s}function a(r,e,t){var s;for(s=0;s1)throw new TypeError(p("00L05"));if(null===(b=o(g)))throw new TypeError(p("00L2k",g));return new b(0)}if(c<2)throw new TypeError(p("00L05"));if(n(arguments[c-=1]))if(n(arguments[c-1])){if(d=arguments[c],y=arguments[c-=1],0===c)throw new TypeError(p("00L05"))}else y=arguments[c];else{if(!(c>=2))throw new TypeError(p("00L05"));if(d=arguments[c],!n(y=arguments[c-=1]))throw new TypeError(p("00L2n",y))}if((c-=1)>=0&&r(arguments[c])?(g=arguments[c],c-=1):g="float64",null===(b=o(g)))throw new TypeError(p("00L2k",g));if("generic"===g){if(x=arguments[0],0===c){if(e(x)?u=x:t(x)&&(u=x.length),void 0!==u)return m(u,y,d);if(s(x))throw new Error(p("00L04"));if(i(x)){if(!1===w)throw new TypeError(p("00L2l",x));if(!n(x[f]))throw new TypeError(p("00L2m",x));if(x=x[f](),!n(x.next))throw new TypeError(p("00L2m",x));return j(x,y,d)}throw new TypeError(p("00L2m",x))}if(s(x))throw new Error(p("00L04"));throw new TypeError(p("00L2m",x))}if(0===c)if(t(x=arguments[0]))v=new b(x.length);else if(s(x))v=new b(x);else if(e(x))v=new b(x);else{if(!i(x))throw new TypeError(p("00L2m",x));if(!1===w)throw new TypeError(p("00L2l",x));if(!n(x[f]))throw new TypeError(p("00L2m",x));if(x=x[f](),!n(x.next))throw new TypeError(p("00L2m",x));v=new b(h(x))}else v=1===c?new b(arguments[0],arguments[1]):new b(arguments[0],arguments[1],arguments[2]);return v.length>0&&(/^complex/.test(g)?a(v,y,d):l(v.length,v,1,E)),v;function E(r,e){return y.call(d,e)}}export{c as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 4c947f8..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.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\nimport { isPrimitive as isString } from '@stdlib/assert-is-string' ;\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer' ;\nimport isCollection from '@stdlib/assert-is-collection' ;\nimport isArrayBuffer from '@stdlib/assert-is-arraybuffer' ;\nimport isObject from '@stdlib/assert-is-object' ;\nimport isFunction from '@stdlib/assert-is-function' ;\nimport ctors from '@stdlib/array-ctors' ;\nimport gfillBy from '@stdlib/blas-ext-base-gfill-by' ;\nimport filledArray from '@stdlib/array-base-filled-by' ;\nimport hasIteratorSymbolSupport from '@stdlib/assert-has-iterator-symbol-support' ;\nimport ITERATOR_SYMBOL from '@stdlib/symbol-iterator' ;\nimport iterLength from '@stdlib/iter-length' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\n\n\n// VARIABLES //\n\nvar HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport();\nvar DEFAULT_DTYPE = 'float64';\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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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( format( '00L05' ) );\n\t\t}\n\t\tctor = ctors( dtype );\n\t\tif ( ctor === null ) {\n\t\t\tthrow new TypeError( format( '00L2k', 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( format( '00L05' ) );\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( format( '00L05' ) );\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( '00L2n', 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( format( '00L05' ) );\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( '00L2k', 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( format( '00L04' ) );\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( '00L2l', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00L2m', 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( '00L2m', 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( '00L2m', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format( '00L04' ) );\n\t\t}\n\t\tthrow new TypeError( format( '00L2m', 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( '00L2l', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00L2m', 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( '00L2m', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00L2m', 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\nexport default filledarrayBy;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","filledArrayIterator","it","clbk","thisArg","arr","i","next","done","push","call","filledAccessors","length","set","filledarrayBy","nargs","dtype","ctor","len","arg","arguments","ctors","isString","TypeError","format","isFunction","isNonNegativeInteger","isCollection","filledArray","isArrayBuffer","Error","isObject","ITERATOR_SYMBOL","iterLength","test","gfillBy","callback","value","aidx"],"mappings":";;gqCAuCA,IAAIA,EAAsBC,IAe1B,SAASC,EAAqBC,EAAIC,EAAMC,GACvC,IAAIC,EACAC,EAKJ,IAFAD,EAAM,GACNC,GAAK,GAEAJ,EAAGK,OACAC,MAGPF,GAAK,EACLD,EAAII,KAAMN,EAAKO,KAAMN,EAASE,IAE/B,OAAOD,CACR,CAWA,SAASM,EAAiBN,EAAKF,EAAMC,GACpC,IAAIE,EACJ,IAAMA,EAAI,EAAGA,EAAID,EAAIO,OAAQN,IAC5BD,EAAIQ,IAAKV,EAAKO,KAAMN,EAASE,GAAKA,GAEnC,OAAOD,CACR,CA4JA,SAASS,IACR,IAAIV,EACAW,EACAC,EACAb,EACAc,EACAZ,EACAa,EACAC,EAKJ,GAAe,KAHfJ,EAAQK,UAAUR,QAKjB,OAAO,IADPK,EAAOI,EAzNW,YA0ND,GAIlB,GAAKC,EADLN,EAAQI,UAAW,IACM,CAExB,GAAKL,EAAQ,EACZ,MAAM,IAAIQ,UAAWC,EAAQ,UAG9B,GAAc,QADdP,EAAOI,EAAOL,IAEb,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAGvC,OAAO,IAAIC,EAAM,EACjB,CAED,GAAKF,EAAQ,EACZ,MAAM,IAAIQ,UAAWC,EAAQ,UAM9B,GAAKC,EAAYL,UAHjBL,GAAS,IAKR,GAAKU,EAAYL,UAAWL,EAAM,KAMjC,GALAX,EAAUgB,UAAWL,GAErBZ,EAAOiB,UADPL,GAAS,GAIM,IAAVA,EACJ,MAAM,IAAIQ,UAAWC,EAAQ,eAI9BrB,EAAOiB,UAAWL,OAIf,MAAKA,GAAS,GAUlB,MAAM,IAAIQ,UAAWC,EAAQ,UAN7B,GAHApB,EAAUgB,UAAWL,IAGfU,EADNtB,EAAOiB,UADPL,GAAS,IAGR,MAAM,IAAIQ,UAAWC,EAAQ,QAASrB,GAMvC,CAUD,IARAY,GAAS,IACK,GAAKO,EAAUF,UAAWL,KACvCC,EAAQI,UAAWL,GACnBA,GAAS,GAETC,EArRkB,UAwRL,QADdC,EAAOI,EAAOL,IAEb,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAGvC,GAAe,YAAVA,EAAsB,CAE1B,GADAG,EAAMC,UAAW,GACF,IAAVL,EAAc,CAMlB,GALKW,EAAsBP,GAC1BD,EAAMC,EACKQ,EAAcR,KACzBD,EAAMC,EAAIP,aAEE,IAARM,EACJ,OAAOU,EAAaV,EAAKf,EAAMC,GAEhC,GAAKyB,EAAeV,GACnB,MAAM,IAAIW,MAAON,EAAQ,UAE1B,GAAKO,EAAUZ,GAAQ,CACtB,IAA6B,IAAxBpB,EACJ,MAAM,IAAIwB,UAAWC,EAAQ,QAASL,IAEvC,IAAMM,EAAYN,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASL,IAGvC,GADAA,EAAMA,EAAKa,MACLP,EAAYN,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,QAASL,IAEvC,OAAOlB,EAAqBkB,EAAKhB,EAAMC,EACvC,CACD,MAAM,IAAImB,UAAWC,EAAQ,QAASL,GACzC,CAAS,GAAKU,EAAeV,GAC1B,MAAM,IAAIW,MAAON,EAAQ,UAE1B,MAAM,IAAID,UAAWC,EAAQ,QAASL,GACtC,CACD,GAAe,IAAVJ,EAEJ,GAAKY,EADLR,EAAMC,UAAW,IAEhBf,EAAM,IAAIY,EAAME,EAAIP,aACd,GAAKiB,EAAeV,GAC1Bd,EAAM,IAAIY,EAAME,QACV,GAAKO,EAAsBP,GACjCd,EAAM,IAAIY,EAAME,OACV,KAAKY,EAAUZ,GAarB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAZtC,IAA6B,IAAxBpB,EACJ,MAAM,IAAIwB,UAAWC,EAAQ,QAASL,IAEvC,IAAMM,EAAYN,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASL,IAGvC,GADAA,EAAMA,EAAKa,MACLP,EAAYN,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,QAASL,IAEvCd,EAAM,IAAIY,EAAMgB,EAAYd,GAG5B,MAEDd,EADqB,IAAVU,EACL,IAAIE,EAAMG,UAAU,GAAIA,UAAU,IAElC,IAAIH,EAAMG,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKf,EAAIO,OAAS,IACZ,WAAWsB,KAAMlB,GACrBL,EAAiBN,EAAKF,EAAMC,GAE5B+B,EAAS9B,EAAIO,OAAQP,EAAK,EAAG+B,IAGxB/B,EAYP,SAAS+B,EAAUC,EAAOC,GACzB,OAAOnC,EAAKO,KAAMN,EAASkC,EAC3B,CACF"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 892348a..0000000 --- a/stats.html +++ /dev/null @@ -1,4044 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From dcd5bda8002104299cec8381f02984aa1fa5c09a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Dec 2022 19:01:20 +0000 Subject: [PATCH 028/117] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 781 ---- .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 183 - .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 41 +- benchmark/benchmark.js | 319 -- benchmark/benchmark.length.complex128.js | 98 - benchmark/benchmark.length.complex64.js | 98 - benchmark/benchmark.length.float32.js | 97 - benchmark/benchmark.length.float64.js | 97 - benchmark/benchmark.length.generic.js | 97 - benchmark/benchmark.length.int16.js | 97 - benchmark/benchmark.length.int32.js | 97 - benchmark/benchmark.length.int8.js | 97 - benchmark/benchmark.length.uint16.js | 97 - benchmark/benchmark.length.uint32.js | 97 - benchmark/benchmark.length.uint8.js | 97 - benchmark/benchmark.length.uint8c.js | 97 - branches.md | 53 - docs/repl.txt | 174 - docs/types/test.ts | 606 --- examples/index.js | 37 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 192 - lib/main.js | 413 -- package.json | 90 +- stats.html | 4044 ++++++++++++++++++++ test/test.js | 4248 --------------------- 49 files changed, 4069 insertions(+), 10251 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.length.complex128.js delete mode 100644 benchmark/benchmark.length.complex64.js delete mode 100644 benchmark/benchmark.length.float32.js delete mode 100644 benchmark/benchmark.length.float64.js delete mode 100644 benchmark/benchmark.length.generic.js delete mode 100644 benchmark/benchmark.length.int16.js delete mode 100644 benchmark/benchmark.length.int32.js delete mode 100644 benchmark/benchmark.length.int8.js delete mode 100644 benchmark/benchmark.length.uint16.js delete mode 100644 benchmark/benchmark.length.uint32.js delete mode 100644 benchmark/benchmark.length.uint8.js delete mode 100644 benchmark/benchmark.length.uint8c.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 80ce634..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-12-01T02:59:25.636Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 8be0b82..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 06a9a75..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index a00dbe5..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.11.0 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index df9d9d7..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 7902a7d..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 16e02e6..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '42 6 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 37ddb4f..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,781 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -273,7 +266,7 @@ for ( i = 0; i < dt.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 421b48e..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,319 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); -var isArray = require( '@stdlib/assert-is-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var pkg = require( './../package.json' ).name; -var filledarrayBy = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 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=float64', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'float64', 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=float32', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'float32', 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; - var i; - - clbk = constantFunction( new Complex128( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'complex128', 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=complex64', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( new Complex64( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'complex64', 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=int32', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int32', 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=uint32', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint32', 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=int16', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int16', 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=uint16', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint16', 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=int8', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int8', 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=uint8', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint8', 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=uint8c', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint8c', 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=generic', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'generic', clbk ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.length.complex128.js b/benchmark/benchmark.length.complex128.js deleted file mode 100644 index 671de86..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var Complex128 = require( '@stdlib/complex-float64' ); -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( new Complex128( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'complex128', 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=complex128,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.complex64.js b/benchmark/benchmark.length.complex64.js deleted file mode 100644 index 52da4e3..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var Complex64 = require( '@stdlib/complex-float32' ); -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( new Complex64( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'complex64', 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=complex64,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.float32.js b/benchmark/benchmark.length.float32.js deleted file mode 100644 index 9b4ef9b..0000000 --- a/benchmark/benchmark.length.float32.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'float32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=float32,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.float64.js b/benchmark/benchmark.length.float64.js deleted file mode 100644 index 66cb6b6..0000000 --- a/benchmark/benchmark.length.float64.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'float64', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=float64,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.generic.js b/benchmark/benchmark.length.generic.js deleted file mode 100644 index 5194c1b..0000000 --- a/benchmark/benchmark.length.generic.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isArray = require( '@stdlib/assert-is-array' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'generic', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isArray( 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=generic,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int16.js b/benchmark/benchmark.length.int16.js deleted file mode 100644 index 6669b28..0000000 --- a/benchmark/benchmark.length.int16.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int16', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=int16,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int32.js b/benchmark/benchmark.length.int32.js deleted file mode 100644 index e9c5c88..0000000 --- a/benchmark/benchmark.length.int32.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=int32,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int8.js b/benchmark/benchmark.length.int8.js deleted file mode 100644 index 14bbadf..0000000 --- a/benchmark/benchmark.length.int8.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int8', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=int8,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint16.js b/benchmark/benchmark.length.uint16.js deleted file mode 100644 index d03b23e..0000000 --- a/benchmark/benchmark.length.uint16.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint16', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint16,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint32.js b/benchmark/benchmark.length.uint32.js deleted file mode 100644 index 1382134..0000000 --- a/benchmark/benchmark.length.uint32.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint32,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint8.js b/benchmark/benchmark.length.uint8.js deleted file mode 100644 index c135d6c..0000000 --- a/benchmark/benchmark.length.uint8.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint8', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint8,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint8c.js b/benchmark/benchmark.length.uint8c.js deleted file mode 100644 index 2f7523a..0000000 --- a/benchmark/benchmark.length.uint8c.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint8c', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint8c,len='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 18101fd..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by" -click B href "https://github.com/stdlib-js/array-filled-by/tree/main" -click C href "https://github.com/stdlib-js/array-filled-by/tree/production" -click D href "https://github.com/stdlib-js/array-filled-by/tree/esm" -click E href "https://github.com/stdlib-js/array-filled-by/tree/deno" -click F href "https://github.com/stdlib-js/array-filled-by/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by -[production-url]: https://github.com/stdlib-js/array-filled-by/tree/production -[deno-url]: https://github.com/stdlib-js/array-filled-by/tree/deno -[umd-url]: https://github.com/stdlib-js/array-filled-by/tree/umd -[esm-url]: https://github.com/stdlib-js/array-filled-by/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 5a68984..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,174 +0,0 @@ - -{{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) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr = {{alias}}() - - > arr = {{alias}}( 'float32' ) - - - -{{alias}}( length[, dtype], clbk[, thisArg] ) - Returns a filled array according to a provided callback function and having - a specified length. - - Parameters - ---------- - length: integer - Array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > function clbk() { return 1.0; }; - > var arr = {{alias}}( 5, clbk ) - [ 1.0, 1.0, 1.0, 1.0, 1.0 ] - > arr = {{alias}}( 5, 'int32', clbk ) - [ 1, 1, 1, 1, 1 ] - - -{{alias}}( array[, dtype], clbk[, thisArg] ) - Creates a filled array from another array (or array-like object) according - to a provided callback function. - - Parameters - ---------- - array: ArrayLikeObject - Array from which to generate another array. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias}}( [ 0.5, 0.5, 0.5 ], {{alias:@stdlib/utils/constant-function}}( 2.0 ) ) - [ 2.0, 2.0, 2.0 ] - > var arr2 = {{alias}}( arr1, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( iterable[, dtype], clbk[, thisArg] ) - Creates a filled array from an iterable according to a provided callback - function. - - Parameters - ---------- - iterable: Iterable - Iterable from which to generate an array. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias:@stdlib/iter/constant}}( 3.0, {'iter': 3} ); - > var arr2 = {{alias}}( arr1, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( buffer[, byteOffset[, length]][, dtype], clbk[, thisArg] ) - Returns a filled typed array view of an ArrayBuffer according to a provided - callback function. - - The 'generic' array data type is *not* supported. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( buf, 0, 4, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0, 1.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 394ac49..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,606 +0,0 @@ -/* -* @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. -*/ - -/// - -import { IterableIterator } from '@stdlib/types/iter'; -import filledarrayBy = require( './index' ); - - -/** -* Returns an iterator protocol-compliant object. -* -* @returns iterator protocol-compliant object -*/ -function iterator(): IterableIterator { - const obj: IterableIterator = { - [Symbol.iterator]: iterator, - 'next': next - }; - return obj; -} - -/** -* Implements the iterator protocol `next` method. -* -* @returns iterator protocol-compliant object -*/ -function next(): any { - return { - 'value': 1.0, - 'done': false - }; -} - -/** -* Callback function. -* -* @param i - current array index -* @returns return value -*/ -function clbk( i: number ): number { - return i; -} - - -// TESTS // - -// The function returns an array or typed array... -{ - filledarrayBy(); // $ExpectType ArrayOrTypedArray - filledarrayBy( 'float32' ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( 10, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( 10, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( 10, 'int32', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( 10, 'int32', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const x = new Float64Array( 10 ); - filledarrayBy( x, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( x, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( x, 'uint8', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( x, 'uint8', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const y = [ 2.0, 2.0, 2.0 ]; - filledarrayBy( y, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( y, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( y, 'float64', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( y, 'float64', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const it = iterator(); - filledarrayBy( it, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( it, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( it, 'uint8c', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( it, 'uint8c', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const buf = new ArrayBuffer( 32 ); - filledarrayBy( buf, clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 'uint32', clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 'uint32', clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 8, clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 8, clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 8, 'uint16', clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 8, 'uint16', clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 8, 2, clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 8, 2, clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 8, 2, 'int16', clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 8, 2, 'int16', clbk, {} ); // $ExpectType RealOrComplexTypedArray -} - -// The compiler throws an error if a callback function argument is not a function... -{ - filledarrayBy( 'float64', '5' ); // $ExpectError - filledarrayBy( 'float64', 1.0 ); // $ExpectError - filledarrayBy( 'float64', false ); // $ExpectError - filledarrayBy( 'float64', true ); // $ExpectError - filledarrayBy( 'float64', null ); // $ExpectError - filledarrayBy( 'float64', undefined ); // $ExpectError - filledarrayBy( 'float64', [] ); // $ExpectError - filledarrayBy( 'float64', {} ); // $ExpectError - - filledarrayBy( 'float64', '5', {} ); // $ExpectError - filledarrayBy( 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( 'float64', false, {} ); // $ExpectError - filledarrayBy( 'float64', true, {} ); // $ExpectError - filledarrayBy( 'float64', null, {} ); // $ExpectError - filledarrayBy( 'float64', undefined, {} ); // $ExpectError - filledarrayBy( 'float64', [], {} ); // $ExpectError - filledarrayBy( 'float64', {}, {} ); // $ExpectError - - filledarrayBy( 10, '5' ); // $ExpectError - filledarrayBy( 10, 1.0 ); // $ExpectError - filledarrayBy( 10, false ); // $ExpectError - filledarrayBy( 10, true ); // $ExpectError - filledarrayBy( 10, null ); // $ExpectError - filledarrayBy( 10, undefined ); // $ExpectError - filledarrayBy( 10, [] ); // $ExpectError - filledarrayBy( 10, {} ); // $ExpectError - - filledarrayBy( 10, '5', {} ); // $ExpectError - filledarrayBy( 10, 1.0, {} ); // $ExpectError - filledarrayBy( 10, false, {} ); // $ExpectError - filledarrayBy( 10, true, {} ); // $ExpectError - filledarrayBy( 10, null, {} ); // $ExpectError - filledarrayBy( 10, undefined, {} ); // $ExpectError - filledarrayBy( 10, [], {} ); // $ExpectError - filledarrayBy( 10, {}, {} ); // $ExpectError - - filledarrayBy( 10, 'float64', '5' ); // $ExpectError - filledarrayBy( 10, 'float64', 1.0 ); // $ExpectError - filledarrayBy( 10, 'float64', false ); // $ExpectError - filledarrayBy( 10, 'float64', true ); // $ExpectError - filledarrayBy( 10, 'float64', null ); // $ExpectError - filledarrayBy( 10, 'float64', undefined ); // $ExpectError - filledarrayBy( 10, 'float64', [] ); // $ExpectError - filledarrayBy( 10, 'float64', {} ); // $ExpectError - - filledarrayBy( 10, 'float64', '5', {} ); // $ExpectError - filledarrayBy( 10, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( 10, 'float64', false, {} ); // $ExpectError - filledarrayBy( 10, 'float64', true, {} ); // $ExpectError - filledarrayBy( 10, 'float64', null, {} ); // $ExpectError - filledarrayBy( 10, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( 10, 'float64', [], {} ); // $ExpectError - filledarrayBy( 10, 'float64', {}, {} ); // $ExpectError - - const x = new Float64Array( 10 ); - filledarrayBy( x, '5' ); // $ExpectError - filledarrayBy( x, 1.0 ); // $ExpectError - filledarrayBy( x, false ); // $ExpectError - filledarrayBy( x, true ); // $ExpectError - filledarrayBy( x, null ); // $ExpectError - filledarrayBy( x, undefined ); // $ExpectError - filledarrayBy( x, [] ); // $ExpectError - filledarrayBy( x, {} ); // $ExpectError - - filledarrayBy( x, '5', {} ); // $ExpectError - filledarrayBy( x, 1.0, {} ); // $ExpectError - filledarrayBy( x, false, {} ); // $ExpectError - filledarrayBy( x, true, {} ); // $ExpectError - filledarrayBy( x, null, {} ); // $ExpectError - filledarrayBy( x, undefined, {} ); // $ExpectError - filledarrayBy( x, [], {} ); // $ExpectError - filledarrayBy( x, {}, {} ); // $ExpectError - - filledarrayBy( x, 'float64', '5' ); // $ExpectError - filledarrayBy( x, 'float64', 1.0 ); // $ExpectError - filledarrayBy( x, 'float64', false ); // $ExpectError - filledarrayBy( x, 'float64', true ); // $ExpectError - filledarrayBy( x, 'float64', null ); // $ExpectError - filledarrayBy( x, 'float64', undefined ); // $ExpectError - filledarrayBy( x, 'float64', [] ); // $ExpectError - filledarrayBy( x, 'float64', {} ); // $ExpectError - - filledarrayBy( x, 'float64', '5', {} ); // $ExpectError - filledarrayBy( x, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( x, 'float64', false, {} ); // $ExpectError - filledarrayBy( x, 'float64', true, {} ); // $ExpectError - filledarrayBy( x, 'float64', null, {} ); // $ExpectError - filledarrayBy( x, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( x, 'float64', [], {} ); // $ExpectError - filledarrayBy( x, 'float64', {}, {} ); // $ExpectError - - const y = [ 2.0, 2.0, 2.0 ]; - filledarrayBy( y, '5' ); // $ExpectError - filledarrayBy( y, 1.0 ); // $ExpectError - filledarrayBy( y, false ); // $ExpectError - filledarrayBy( y, true ); // $ExpectError - filledarrayBy( y, null ); // $ExpectError - filledarrayBy( y, undefined ); // $ExpectError - filledarrayBy( y, [] ); // $ExpectError - filledarrayBy( y, {} ); // $ExpectError - - filledarrayBy( y, '5', {} ); // $ExpectError - filledarrayBy( y, 1.0, {} ); // $ExpectError - filledarrayBy( y, false, {} ); // $ExpectError - filledarrayBy( y, true, {} ); // $ExpectError - filledarrayBy( y, null, {} ); // $ExpectError - filledarrayBy( y, undefined, {} ); // $ExpectError - filledarrayBy( y, [], {} ); // $ExpectError - filledarrayBy( y, {}, {} ); // $ExpectError - - filledarrayBy( y, 'float64', '5' ); // $ExpectError - filledarrayBy( y, 'float64', 1.0 ); // $ExpectError - filledarrayBy( y, 'float64', false ); // $ExpectError - filledarrayBy( y, 'float64', true ); // $ExpectError - filledarrayBy( y, 'float64', null ); // $ExpectError - filledarrayBy( y, 'float64', undefined ); // $ExpectError - filledarrayBy( y, 'float64', [] ); // $ExpectError - filledarrayBy( y, 'float64', {} ); // $ExpectError - - filledarrayBy( y, 'float64', '5', {} ); // $ExpectError - filledarrayBy( y, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( y, 'float64', false, {} ); // $ExpectError - filledarrayBy( y, 'float64', true, {} ); // $ExpectError - filledarrayBy( y, 'float64', null, {} ); // $ExpectError - filledarrayBy( y, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( y, 'float64', [], {} ); // $ExpectError - filledarrayBy( y, 'float64', {}, {} ); // $ExpectError - - const it = iterator(); - filledarrayBy( it, '5' ); // $ExpectError - filledarrayBy( it, 1.0 ); // $ExpectError - filledarrayBy( it, false ); // $ExpectError - filledarrayBy( it, true ); // $ExpectError - filledarrayBy( it, null ); // $ExpectError - filledarrayBy( it, undefined ); // $ExpectError - filledarrayBy( it, [] ); // $ExpectError - filledarrayBy( it, {} ); // $ExpectError - - filledarrayBy( it, '5', {} ); // $ExpectError - filledarrayBy( it, 1.0, {} ); // $ExpectError - filledarrayBy( it, false, {} ); // $ExpectError - filledarrayBy( it, true, {} ); // $ExpectError - filledarrayBy( it, null, {} ); // $ExpectError - filledarrayBy( it, undefined, {} ); // $ExpectError - filledarrayBy( it, [], {} ); // $ExpectError - filledarrayBy( it, {}, {} ); // $ExpectError - - filledarrayBy( it, 'float64', '5' ); // $ExpectError - filledarrayBy( it, 'float64', 1.0 ); // $ExpectError - filledarrayBy( it, 'float64', false ); // $ExpectError - filledarrayBy( it, 'float64', true ); // $ExpectError - filledarrayBy( it, 'float64', null ); // $ExpectError - filledarrayBy( it, 'float64', undefined ); // $ExpectError - filledarrayBy( it, 'float64', [] ); // $ExpectError - filledarrayBy( it, 'float64', {} ); // $ExpectError - - filledarrayBy( it, 'float64', '5', {} ); // $ExpectError - filledarrayBy( it, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( it, 'float64', false, {} ); // $ExpectError - filledarrayBy( it, 'float64', true, {} ); // $ExpectError - filledarrayBy( it, 'float64', null, {} ); // $ExpectError - filledarrayBy( it, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( it, 'float64', [], {} ); // $ExpectError - filledarrayBy( it, 'float64', {}, {} ); // $ExpectError - - const buf = new ArrayBuffer( 32 ); - filledarrayBy( buf, '5' ); // $ExpectError - filledarrayBy( buf, 1.0 ); // $ExpectError - filledarrayBy( buf, false ); // $ExpectError - filledarrayBy( buf, true ); // $ExpectError - filledarrayBy( buf, null ); // $ExpectError - filledarrayBy( buf, undefined ); // $ExpectError - filledarrayBy( buf, [] ); // $ExpectError - filledarrayBy( buf, {} ); // $ExpectError - - filledarrayBy( buf, '5', {} ); // $ExpectError - filledarrayBy( buf, 1.0, {} ); // $ExpectError - filledarrayBy( buf, false, {} ); // $ExpectError - filledarrayBy( buf, true, {} ); // $ExpectError - filledarrayBy( buf, null, {} ); // $ExpectError - filledarrayBy( buf, undefined, {} ); // $ExpectError - filledarrayBy( buf, [], {} ); // $ExpectError - filledarrayBy( buf, {}, {} ); // $ExpectError - - filledarrayBy( buf, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 'float64', false ); // $ExpectError - filledarrayBy( buf, 'float64', true ); // $ExpectError - filledarrayBy( buf, 'float64', null ); // $ExpectError - filledarrayBy( buf, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 'float64', {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5' ); // $ExpectError - filledarrayBy( buf, 8, 1.0 ); // $ExpectError - filledarrayBy( buf, 8, false ); // $ExpectError - filledarrayBy( buf, 8, true ); // $ExpectError - filledarrayBy( buf, 8, null ); // $ExpectError - filledarrayBy( buf, 8, undefined ); // $ExpectError - filledarrayBy( buf, 8, [] ); // $ExpectError - filledarrayBy( buf, 8, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, false, {} ); // $ExpectError - filledarrayBy( buf, 8, true, {} ); // $ExpectError - filledarrayBy( buf, 8, null, {} ); // $ExpectError - filledarrayBy( buf, 8, undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, [], {} ); // $ExpectError - filledarrayBy( buf, 8, {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 8, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 'float64', false ); // $ExpectError - filledarrayBy( buf, 8, 'float64', true ); // $ExpectError - filledarrayBy( buf, 8, 'float64', null ); // $ExpectError - filledarrayBy( buf, 8, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 8, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 8, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 8, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, '5' ); // $ExpectError - filledarrayBy( buf, 8, 2, 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 2, false ); // $ExpectError - filledarrayBy( buf, 8, 2, true ); // $ExpectError - filledarrayBy( buf, 8, 2, null ); // $ExpectError - filledarrayBy( buf, 8, 2, undefined ); // $ExpectError - filledarrayBy( buf, 8, 2, [] ); // $ExpectError - filledarrayBy( buf, 8, 2, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, false, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, true, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, null, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, [], {} ); // $ExpectError - filledarrayBy( buf, 8, 2, {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', false ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', true ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', null ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', {}, {} ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid length, typed array, array-like object, `ArrayBuffer`, or iterable argument... -{ - filledarrayBy( false, clbk ); // $ExpectError - filledarrayBy( true, clbk ); // $ExpectError - filledarrayBy( null, clbk ); // $ExpectError - filledarrayBy( {}, clbk ); // $ExpectError - - filledarrayBy( false, clbk, {} ); // $ExpectError - filledarrayBy( true, clbk, {} ); // $ExpectError - filledarrayBy( null, clbk, {} ); // $ExpectError - filledarrayBy( {}, clbk, {} ); // $ExpectError - - filledarrayBy( false, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 'float64', clbk ); // $ExpectError - - filledarrayBy( false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, clbk ); // $ExpectError - filledarrayBy( 1.0, 8, clbk ); // $ExpectError - filledarrayBy( false, 8, clbk ); // $ExpectError - filledarrayBy( true, 8, clbk ); // $ExpectError - filledarrayBy( null, 8, clbk ); // $ExpectError - filledarrayBy( undefined, 8, clbk ); // $ExpectError - filledarrayBy( [], 8, clbk ); // $ExpectError - filledarrayBy( {}, 8, clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, clbk ); // $ExpectError - - filledarrayBy( '5', 8, clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, clbk, {} ); // $ExpectError - filledarrayBy( false, 8, clbk, {} ); // $ExpectError - filledarrayBy( true, 8, clbk, {} ); // $ExpectError - filledarrayBy( null, 8, clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, clbk, {} ); // $ExpectError - filledarrayBy( [], 8, clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 'float64', clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( false, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( [], 8, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 'float64', clbk ); // $ExpectError - - filledarrayBy( '5', 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 2, clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 2, clbk ); // $ExpectError - filledarrayBy( false, 8, 2, clbk ); // $ExpectError - filledarrayBy( true, 8, 2, clbk ); // $ExpectError - filledarrayBy( null, 8, 2, clbk ); // $ExpectError - filledarrayBy( undefined, 8, 2, clbk ); // $ExpectError - filledarrayBy( [], 8, 2, clbk ); // $ExpectError - filledarrayBy( {}, 8, 2, clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, clbk ); // $ExpectError - - filledarrayBy( '5', 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( false, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( [], 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, 'float64', clbk ); // $ExpectError - - filledarrayBy( '5', 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a byte offset argument which is not a number... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, false, clbk ); // $ExpectError - filledarrayBy( buf, true, clbk ); // $ExpectError - filledarrayBy( buf, null, clbk ); // $ExpectError - filledarrayBy( buf, [], clbk ); // $ExpectError - filledarrayBy( buf, {}, clbk ); // $ExpectError - - filledarrayBy( buf, false, clbk, {} ); // $ExpectError - filledarrayBy( buf, true, clbk, {} ); // $ExpectError - filledarrayBy( buf, null, clbk, {} ); // $ExpectError - filledarrayBy( buf, [], clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, clbk, {} ); // $ExpectError - - filledarrayBy( buf, '5', 'float64', clbk ); // $ExpectError - filledarrayBy( buf, false, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, true, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, null, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, [], 'float64', clbk ); // $ExpectError - filledarrayBy( buf, {}, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, '5', 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( buf, false, 2, clbk ); // $ExpectError - filledarrayBy( buf, true, 2, clbk ); // $ExpectError - filledarrayBy( buf, null, 2, clbk ); // $ExpectError - filledarrayBy( buf, [], 2, clbk ); // $ExpectError - filledarrayBy( buf, {}, 2, clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, clbk ); // $ExpectError - - filledarrayBy( buf, false, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, clbk, {} ); // $ExpectError - - filledarrayBy( buf, '5', 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, false, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, true, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, null, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, undefined, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, [], 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, {}, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, '5', 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, false, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, undefined, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a view length argument which is not a number... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, 8, false, clbk ); // $ExpectError - filledarrayBy( buf, 8, true, clbk ); // $ExpectError - filledarrayBy( buf, 8, null, clbk ); // $ExpectError - filledarrayBy( buf, 8, [], clbk ); // $ExpectError - filledarrayBy( buf, 8, {}, clbk ); // $ExpectError - - filledarrayBy( buf, 8, false, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, true, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, null, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, [], clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, {}, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, clbk, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5', 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, false, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, true, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, null, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, [], 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, {}, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, 8, '5', 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, [], 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, {}, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided too many arguments... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, 8, 2, 'float64', 1, clbk, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 997a381..0000000 --- a/examples/index.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ).factory; -var dtypes = require( '@stdlib/array-typed-real-dtypes' ); -var filledarrayBy = require( './../lib' ); - -// Create a pseudorandom number generator: -var rand = discreteUniform( 0, 100 ); - -// Get a list of array data types: -var dt = dtypes(); - -// Generate filled arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = filledarrayBy( 10, dt[ i ], rand ); - console.log( arr ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 3fc2784..2156674 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { RealOrComplexTypedArray, DataType } from '@stdlib/types/array'; import { Collection } from '@stdlib/types/object'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..ce0d7c1 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-ctors@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill-by@v0.0.10-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled-by@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";var w=d();function j(r,e,t){var s,i;for(s=[],i=-1;!r.next().done;)i+=1,s.push(e.call(t,i));return s}function a(r,e,t){var s;for(s=0;s1)throw new TypeError(p("00L05"));if(null===(b=o(g)))throw new TypeError(p("00L2k",g));return new b(0)}if(c<2)throw new TypeError(p("00L05"));if(n(arguments[c-=1]))if(n(arguments[c-1])){if(d=arguments[c],y=arguments[c-=1],0===c)throw new TypeError(p("00L05"))}else y=arguments[c];else{if(!(c>=2))throw new TypeError(p("00L05"));if(d=arguments[c],!n(y=arguments[c-=1]))throw new TypeError(p("00L2n",y))}if((c-=1)>=0&&r(arguments[c])?(g=arguments[c],c-=1):g="float64",null===(b=o(g)))throw new TypeError(p("00L2k",g));if("generic"===g){if(x=arguments[0],0===c){if(e(x)?u=x:t(x)&&(u=x.length),void 0!==u)return m(u,y,d);if(s(x))throw new Error(p("00L04"));if(i(x)){if(!1===w)throw new TypeError(p("00L2l",x));if(!n(x[f]))throw new TypeError(p("00L2m",x));if(x=x[f](),!n(x.next))throw new TypeError(p("00L2m",x));return j(x,y,d)}throw new TypeError(p("00L2m",x))}if(s(x))throw new Error(p("00L04"));throw new TypeError(p("00L2m",x))}if(0===c)if(t(x=arguments[0]))v=new b(x.length);else if(s(x))v=new b(x);else if(e(x))v=new b(x);else{if(!i(x))throw new TypeError(p("00L2m",x));if(!1===w)throw new TypeError(p("00L2l",x));if(!n(x[f]))throw new TypeError(p("00L2m",x));if(x=x[f](),!n(x.next))throw new TypeError(p("00L2m",x));v=new b(h(x))}else v=1===c?new b(arguments[0],arguments[1]):new b(arguments[0],arguments[1],arguments[2]);return v.length>0&&(/^complex/.test(g)?a(v,y,d):l(v.length,v,1,E)),v;function E(r,e){return y.call(d,e)}}export{c as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..cf25e56 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.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\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport isCollection from '@stdlib/assert-is-collection';\nimport isArrayBuffer from '@stdlib/assert-is-arraybuffer';\nimport isObject from '@stdlib/assert-is-object';\nimport isFunction from '@stdlib/assert-is-function';\nimport ctors from '@stdlib/array-ctors';\nimport gfillBy from '@stdlib/blas-ext-base-gfill-by';\nimport filledArray from '@stdlib/array-base-filled-by';\nimport hasIteratorSymbolSupport from '@stdlib/assert-has-iterator-symbol-support';\nimport ITERATOR_SYMBOL from '@stdlib/symbol-iterator';\nimport iterLength from '@stdlib/iter-length';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport();\nvar DEFAULT_DTYPE = 'float64';\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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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( format( '00L05' ) );\n\t\t}\n\t\tctor = ctors( dtype );\n\t\tif ( ctor === null ) {\n\t\t\tthrow new TypeError( format( '00L2k', 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( format( '00L05' ) );\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( format( '00L05' ) );\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( '00L2n', 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( format( '00L05' ) );\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( '00L2k', 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( format( '00L04' ) );\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( '00L2l', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00L2m', 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( '00L2m', 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( '00L2m', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format( '00L04' ) );\n\t\t}\n\t\tthrow new TypeError( format( '00L2m', 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( '00L2l', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00L2m', 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( '00L2m', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00L2m', 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\nexport default filledarrayBy;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","filledArrayIterator","it","clbk","thisArg","arr","i","next","done","push","call","filledAccessors","length","set","filledarrayBy","nargs","dtype","ctor","len","arg","arguments","ctors","isString","TypeError","format","isFunction","isNonNegativeInteger","isCollection","filledArray","isArrayBuffer","Error","isObject","ITERATOR_SYMBOL","iterLength","test","gfillBy","callback","value","aidx"],"mappings":";;gqCAuCA,IAAIA,EAAsBC,IAe1B,SAASC,EAAqBC,EAAIC,EAAMC,GACvC,IAAIC,EACAC,EAKJ,IAFAD,EAAM,GACNC,GAAK,GAEAJ,EAAGK,OACAC,MAGPF,GAAK,EACLD,EAAII,KAAMN,EAAKO,KAAMN,EAASE,IAE/B,OAAOD,CACR,CAWA,SAASM,EAAiBN,EAAKF,EAAMC,GACpC,IAAIE,EACJ,IAAMA,EAAI,EAAGA,EAAID,EAAIO,OAAQN,IAC5BD,EAAIQ,IAAKV,EAAKO,KAAMN,EAASE,GAAKA,GAEnC,OAAOD,CACR,CA4JA,SAASS,IACR,IAAIV,EACAW,EACAC,EACAb,EACAc,EACAZ,EACAa,EACAC,EAKJ,GAAe,KAHfJ,EAAQK,UAAUR,QAKjB,OAAO,IADPK,EAAOI,EAzNW,YA0ND,GAIlB,GAAKC,EADLN,EAAQI,UAAW,IACM,CAExB,GAAKL,EAAQ,EACZ,MAAM,IAAIQ,UAAWC,EAAQ,UAG9B,GAAc,QADdP,EAAOI,EAAOL,IAEb,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAGvC,OAAO,IAAIC,EAAM,EACjB,CAED,GAAKF,EAAQ,EACZ,MAAM,IAAIQ,UAAWC,EAAQ,UAM9B,GAAKC,EAAYL,UAHjBL,GAAS,IAKR,GAAKU,EAAYL,UAAWL,EAAM,KAMjC,GALAX,EAAUgB,UAAWL,GAErBZ,EAAOiB,UADPL,GAAS,GAIM,IAAVA,EACJ,MAAM,IAAIQ,UAAWC,EAAQ,eAI9BrB,EAAOiB,UAAWL,OAIf,MAAKA,GAAS,GAUlB,MAAM,IAAIQ,UAAWC,EAAQ,UAN7B,GAHApB,EAAUgB,UAAWL,IAGfU,EADNtB,EAAOiB,UADPL,GAAS,IAGR,MAAM,IAAIQ,UAAWC,EAAQ,QAASrB,GAMvC,CAUD,IARAY,GAAS,IACK,GAAKO,EAAUF,UAAWL,KACvCC,EAAQI,UAAWL,GACnBA,GAAS,GAETC,EArRkB,UAwRL,QADdC,EAAOI,EAAOL,IAEb,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAGvC,GAAe,YAAVA,EAAsB,CAE1B,GADAG,EAAMC,UAAW,GACF,IAAVL,EAAc,CAMlB,GALKW,EAAsBP,GAC1BD,EAAMC,EACKQ,EAAcR,KACzBD,EAAMC,EAAIP,aAEE,IAARM,EACJ,OAAOU,EAAaV,EAAKf,EAAMC,GAEhC,GAAKyB,EAAeV,GACnB,MAAM,IAAIW,MAAON,EAAQ,UAE1B,GAAKO,EAAUZ,GAAQ,CACtB,IAA6B,IAAxBpB,EACJ,MAAM,IAAIwB,UAAWC,EAAQ,QAASL,IAEvC,IAAMM,EAAYN,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASL,IAGvC,GADAA,EAAMA,EAAKa,MACLP,EAAYN,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,QAASL,IAEvC,OAAOlB,EAAqBkB,EAAKhB,EAAMC,EACvC,CACD,MAAM,IAAImB,UAAWC,EAAQ,QAASL,GACzC,CAAS,GAAKU,EAAeV,GAC1B,MAAM,IAAIW,MAAON,EAAQ,UAE1B,MAAM,IAAID,UAAWC,EAAQ,QAASL,GACtC,CACD,GAAe,IAAVJ,EAEJ,GAAKY,EADLR,EAAMC,UAAW,IAEhBf,EAAM,IAAIY,EAAME,EAAIP,aACd,GAAKiB,EAAeV,GAC1Bd,EAAM,IAAIY,EAAME,QACV,GAAKO,EAAsBP,GACjCd,EAAM,IAAIY,EAAME,OACV,KAAKY,EAAUZ,GAarB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAZtC,IAA6B,IAAxBpB,EACJ,MAAM,IAAIwB,UAAWC,EAAQ,QAASL,IAEvC,IAAMM,EAAYN,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASL,IAGvC,GADAA,EAAMA,EAAKa,MACLP,EAAYN,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,QAASL,IAEvCd,EAAM,IAAIY,EAAMgB,EAAYd,GAG5B,MAEDd,EADqB,IAAVU,EACL,IAAIE,EAAMG,UAAU,GAAIA,UAAU,IAElC,IAAIH,EAAMG,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKf,EAAIO,OAAS,IACZ,WAAWsB,KAAMlB,GACrBL,EAAiBN,EAAKF,EAAMC,GAE5B+B,EAAS9B,EAAIO,OAAQP,EAAK,EAAG+B,IAGxB/B,EAYP,SAAS+B,EAAUC,EAAOC,GACzB,OAAOnC,EAAKO,KAAMN,EAASkC,EAC3B,CACF"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d115cf0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,192 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -/** -* Create a filled array according to a provided callback function. -* -* @module @stdlib/array-filled-by -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* var arr = filledarrayBy(); -* // returns -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'generic', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( [ 0.5, 0.5 ], clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1; -* } -* -* var arr = filledarrayBy( [ 5, -3 ], 'int32', clbk ); -* // returns [ 1, 1 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk1() { -* return 10; -* } -* -* function clbk2() { -* return 1.0; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, clbk2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk1() { -* return 1.0; -* } -* -* function clbk2() { -* return 2; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, 'uint32', clbk2 ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 'float32', clbk ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, clbk ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, 'int32', clbk ); -* // returns [ 1, 1 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index d6fbe5e..0000000 --- a/lib/main.js +++ /dev/null @@ -1,413 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var isCollection = require( '@stdlib/assert-is-collection' ); -var isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isObject = require( '@stdlib/assert-is-object' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var ctors = require( '@stdlib/array-ctors' ); -var gfillBy = require( '@stdlib/blas-ext-base-gfill-by' ); -var filledArray = require( '@stdlib/array-base-filled-by' ); -var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var iterLength = require( '@stdlib/iter-length' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport(); -var DEFAULT_DTYPE = 'float64'; - - -// FUNCTIONS // - -/** -* Creates a filled "generic" array from an iterator. -* -* @private -* @param {Iterable} it - iterator -* @param {Callback} clbk - callback function -* @param {*} thisArg - callback function execution context -* @returns {Array} filled array -*/ -function filledArrayIterator( it, clbk, thisArg ) { - var arr; - var i; - var v; - - arr = []; - i = -1; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - i += 1; - arr.push( clbk.call( thisArg, i ) ); - } - return arr; -} - -/** -* Fills an array exposing accessors for getting and setting array elements. -* -* @private -* @param {Collection} arr - input array -* @param {Callback} clbk - callback function -* @param {*} thisArg - callback function execution context -* @returns {Collection} input array -*/ -function filledAccessors( arr, clbk, thisArg ) { - var i; - for ( i = 0; i < arr.length; i++ ) { - arr.set( clbk.call( thisArg, i ), i ); - } - return arr; -} - - -// MAIN // - -/** -* Creates a filled array according to a provided callback function. -* -* @param {(NonNegativeInteger|TypedArray|ArrayLikeObject|ArrayBuffer|Iterable)} [arg] - a length, typed array, array-like object, buffer, or iterable -* @param {NonNegativeInteger} [byteOffset=0] - byte offset -* @param {NonNegativeInteger} [length] - view length -* @param {string} [dtype="float64"] - data type -* @param {Callback} [clbk] - callback to invoke -* @param {*} [thisArg] - callback execution context -* @throws {TypeError} must provide a recognized data type -* @throws {TypeError} must provide a length, typed array, array-like object, buffer, or iterable -* @throws {TypeError} callback argument must be a function. -* @throws {Error} creating a generic array from an `ArrayBuffer` is not supported -* @returns {(TypedArray|Array)} array or typed array -* -* @example -* var arr = filledarrayBy(); -* // returns -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'generic', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( [ 0.5, 0.5 ], clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1; -* } -* -* var arr = filledarrayBy( [ 5, -3 ], 'int32', clbk ); -* // returns [ 1, 1 ] -* -* @example -* function clbk1() { -* return 10; -* } -* -* function clbk2() { -* return 1.0; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, clbk2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk1() { -* return 1.0; -* } -* -* function clbk2() { -* return 2; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, 'uint32', clbk2 ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 'float32', clbk ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, clbk ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, 'int32', clbk ); -* // returns [ 1, 1 ] -*/ -function filledarrayBy() { - var thisArg; - var nargs; - var dtype; - var clbk; - var ctor; - var arr; - var len; - var arg; - - nargs = arguments.length; - - // If we weren't provided any arguments, return an empty array... - if ( nargs === 0 ) { - ctor = ctors( DEFAULT_DTYPE ); - return new ctor( 0 ); - } - // Check if we were provided a dtype as the first argument... - dtype = arguments[ 0 ]; - if ( isString( dtype ) ) { - // Invoking this function with arguments `f( dtype, clbk[, thisArg] )` is not allowed (otherwise, we'd need to also allow `f( clbk[, thisArg] )`)... - if ( nargs > 1 ) { - throw new TypeError( format( '00L05' ) ); - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '00L2k', dtype ) ); - } - // Return an empty array having the specified dtype: - return new ctor( 0 ); - } - // For all other supported invocations, we need at least two arguments... - if ( nargs < 2 ) { - throw new TypeError( format( '00L05' ) ); - } - // At this point, we need to do some argument juggling... - nargs -= 1; // henceforth, the number of available arguments is `nargs+1` - - // Determine whether the last argument is a callback or "this" context... - if ( isFunction( arguments[ nargs ] ) ) { - // 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... - if ( isFunction( arguments[ nargs-1 ] ) ) { - thisArg = arguments[ nargs ]; - nargs -= 1; - clbk = arguments[ nargs ]; - - // Check if we were provided only a callback and a "this" context.. - if ( nargs === 0 ) { - throw new TypeError( format( '00L05' ) ); - } - } else { - // "this" context is left undefined... - clbk = arguments[ nargs ]; - } - } - // 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... - else if ( nargs >= 2 ) { - thisArg = arguments[ nargs ]; - nargs -= 1; - clbk = arguments[ nargs ]; - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '00L2n', clbk ) ); - } - } - // If were were only provided 2 arguments and the last argument was not a function, we've been provided an insufficient number of arguments... - else { - throw new TypeError( format( '00L05' ) ); - } - // Now that we've processed the callback arguments, let's continue working backward to see if we've been provided a `dtype` argument... - nargs -= 1; - if ( nargs >= 0 && isString( arguments[ nargs ] ) ) { - dtype = arguments[ nargs ]; - nargs -= 1; - } else { - dtype = DEFAULT_DTYPE; - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '00L2k', dtype ) ); - } - // At this point, we've resolved the output array data type, and now we can actually create the output array... - if ( dtype === 'generic' ) { - arg = arguments[ 0 ]; - if ( nargs === 0 ) { - if ( isNonNegativeInteger( arg ) ) { - len = arg; - } else if ( isCollection( arg ) ) { - len = arg.length; - } - if ( len !== void 0 ) { - return filledArray( len, clbk, thisArg ); - } - if ( isArrayBuffer( arg ) ) { - throw new Error( format( '00L04' ) ); - } - if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( '00L2l', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00L2m', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00L2m', arg ) ); - } - return filledArrayIterator( arg, clbk, thisArg ); - } - throw new TypeError( format( '00L2m', arg ) ); - } else if ( isArrayBuffer( arg ) ) { - throw new Error( format( '00L04' ) ); - } - throw new TypeError( format( '00L2m', arg ) ); - } - if ( nargs === 0 ) { // length || array-like || ArrayBuffer || iterable - arg = arguments[ 0 ]; - if ( isCollection( arg ) ) { - arr = new ctor( arg.length ); - } else if ( isArrayBuffer( arg ) ) { - arr = new ctor( arg ); - } else if ( isNonNegativeInteger( arg ) ) { - arr = new ctor( arg ); - } else if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( '00L2l', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00L2m', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00L2m', arg ) ); - } - arr = new ctor( iterLength( arg ) ); - } else { - throw new TypeError( format( '00L2m', arg ) ); - } - } else if ( nargs === 1 ) { - arr = new ctor( arguments[0], arguments[1] ); // (ArrayBuffer, byteOffset) - } else { - arr = new ctor( arguments[0], arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset, length) - } - if ( arr.length > 0 ) { - if ( /^complex/.test( dtype ) ) { - filledAccessors( arr, clbk, thisArg ); - } else { - gfillBy( arr.length, arr, 1, callback ); - } - } - return arr; - - /** - * Callback which wraps a provided callback and is invoked for each array element. - * - * @private - * @param {*} value - element value - * @param {NonNegativeInteger} aidx - array index - * @param {NonNegativeInteger} sidx - strided index - * @param {Collection} array - input array/collection - * @returns {*} callback return value - */ - function callback( value, aidx ) { - return clbk.call( thisArg, aidx ); - } -} - - -// EXPORTS // - -module.exports = filledarrayBy; diff --git a/package.json b/package.json index 6201757..498622b 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.2", "description": "Create a filled array according to a provided callback function.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,69 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-filled-by": "^0.0.x", - "@stdlib/array-ctors": "^0.0.x", - "@stdlib/assert-has-iterator-symbol-support": "^0.0.x", - "@stdlib/assert-is-arraybuffer": "^0.0.x", - "@stdlib/assert-is-collection": "^0.0.x", - "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/assert-is-nonnegative-integer": "^0.0.x", - "@stdlib/assert-is-object": "^0.0.x", - "@stdlib/assert-is-string": "^0.0.x", - "@stdlib/blas-ext-base-gfill-by": "^0.0.x", - "@stdlib/iter-length": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x", - "@stdlib/symbol-iterator": "^0.0.x", - "@stdlib/types": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-buffer": "^0.0.x", - "@stdlib/array-complex128": "^0.0.x", - "@stdlib/array-complex64": "^0.0.x", - "@stdlib/array-float32": "^0.0.x", - "@stdlib/array-float64": "^0.0.x", - "@stdlib/array-int16": "^0.0.x", - "@stdlib/array-int32": "^0.0.x", - "@stdlib/array-int8": "^0.0.x", - "@stdlib/array-typed-real-dtypes": "^0.0.x", - "@stdlib/array-uint16": "^0.0.x", - "@stdlib/array-uint32": "^0.0.x", - "@stdlib/array-uint8": "^0.0.x", - "@stdlib/array-uint8c": "^0.0.x", - "@stdlib/assert-instance-of": "^0.0.x", - "@stdlib/assert-is-array": "^0.0.x", - "@stdlib/assert-is-typed-array": "^0.0.x", - "@stdlib/assert-is-typed-array-like": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/complex-float32": "^0.0.x", - "@stdlib/complex-float64": "^0.0.x", - "@stdlib/iter-constant": "^0.0.x", - "@stdlib/math-base-special-pow": "^0.0.x", - "@stdlib/random-base-discrete-uniform": "^0.0.x", - "@stdlib/strided-base-reinterpret-complex128": "^0.0.x", - "@stdlib/strided-base-reinterpret-complex64": "^0.0.x", - "@stdlib/utils-constant-function": "^0.0.x", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "2.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..9c5f55f --- /dev/null +++ b/stats.html @@ -0,0 +1,4044 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index b55aa4a..0000000 --- a/test/test.js +++ /dev/null @@ -1,4248 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 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. -*/ - -/* eslint-disable max-len */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -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 ArrayBuffer = require( '@stdlib/array-buffer' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var iterConstant = require( '@stdlib/iter-constant' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var filledarrayBy = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': !hasIteratorSymbolSupport() -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof filledarrayBy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if only provided callback arguments', function test( t ) { - t.throws( clbk1, TypeError, 'throws an error' ); - t.throws( clbk2, TypeError, 'throws an error' ); - t.throws( clbk3, TypeError, 'throws an error' ); - t.end(); - - function clbk1() { - filledarrayBy( constantFunction( 1.0 ) ); - } - - function clbk2() { - filledarrayBy( constantFunction( 1.0 ), {} ); - } - - function clbk3() { - filledarrayBy( constantFunction( 1.0 ), constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (only argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (typed array; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (array-like object)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (array-like object; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 8 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 8 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, 1, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (iterator)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( iterConstant( 1.0 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (iterator; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( iterConstant( 1.0 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if only provided data type and callback arguments', function test( t ) { - t.throws( clbk1, TypeError, 'throws an error' ); - t.throws( clbk2, TypeError, 'throws an error' ); - t.throws( clbk3, TypeError, 'throws an error' ); - t.end(); - - function clbk1() { - filledarrayBy( 'float64', constantFunction( 1.0 ) ); - } - - function clbk2() { - filledarrayBy( 'float64', constantFunction( 1.0 ), {} ); - } - - function clbk3() { - filledarrayBy( 'float64', constantFunction( 1.0 ), constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (array-like object)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (array-like object; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, 1, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, 1, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (no iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (no iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (non-function iterator symbol property)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (non-function iterator symbol property; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (`next` property is not a function)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ) ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (`next` property is not a function; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ), {} ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (no iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (no iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (non-function iterator symbol property)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (non-function iterator symbol property; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (`next` property is not a function)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ) ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (`next` property is not a function; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ), {} ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 1, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 1, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function returns a filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - arr = filledarrayBy(); - - t.strictEqual( instanceOf( arr, Float64Array ), 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=float64)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - arr = filledarrayBy( 'float64' ); - - t.strictEqual( instanceOf( arr, Float64Array ), 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=float32)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( 0 ); - arr = filledarrayBy( 'float32' ); - - t.strictEqual( instanceOf( arr, Float32Array ), 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; - - expected = new Complex128Array( 0 ); - arr = filledarrayBy( 'complex128' ); - - t.strictEqual( instanceOf( arr, Complex128Array ), 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=complex64)', function test( t ) { - var expected; - var arr; - - expected = new Complex64Array( 0 ); - arr = filledarrayBy( 'complex64' ); - - t.strictEqual( instanceOf( arr, Complex64Array ), 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=int32)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( 0 ); - arr = filledarrayBy( 'int32' ); - - t.strictEqual( instanceOf( arr, Int32Array ), 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=uint32)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( 0 ); - arr = filledarrayBy( 'uint32' ); - - t.strictEqual( instanceOf( arr, Uint32Array ), 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=int16)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( 0 ); - arr = filledarrayBy( 'int16' ); - - t.strictEqual( instanceOf( arr, Int16Array ), 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=uint16)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( 0 ); - arr = filledarrayBy( 'uint16' ); - - t.strictEqual( instanceOf( arr, Uint16Array ), 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=int8)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( 0 ); - arr = filledarrayBy( 'int8' ); - - t.strictEqual( instanceOf( arr, Int8Array ), 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=uint8)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( 0 ); - arr = filledarrayBy( 'uint8' ); - - t.strictEqual( instanceOf( arr, Uint8Array ), 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=uint8c)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( 0 ); - arr = filledarrayBy( 'uint8c' ); - - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), 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=generic)', function test( t ) { - var expected; - var arr; - - expected = []; - arr = filledarrayBy( 'generic' ); - - t.strictEqual( instanceOf( arr, Array ), 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 (default, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, length=0)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array(); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 0, clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, clbk, ctx ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (default, length; thisArg=function)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, clbk, context ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this(); // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } - - function context() { - ctx.count += 1; - } -}); - -tape( 'the function returns a filled array (dtype=float64, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, 'float64', clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, length; thisArg=function)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, 'float64', clbk, context ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this(); // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } - - function context() { - ctx.count += 1; - } -}); - -tape( 'the function returns a filled array (dtype=float32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, 'float32', clbk ); - - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex128, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = filledarrayBy( 5, 'complex128', clbk ); - - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = filledarrayBy( 5, 'complex64', clbk ); - - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int32Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int32', clbk ); - - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint32Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint32', clbk ); - - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int16Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int16', clbk ); - - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint16', clbk ); - - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int8Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int8', clbk ); - - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint8', clbk ); - - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint8c', clbk ); - - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = [ 1, 1, 1, 1, 1 ]; - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'generic', clbk ); - - t.strictEqual( instanceOf( arr, Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex128, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = [ 1.0, 2.0 ]; - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = [ 1.0, 2.0 ]; - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int32', clbk ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, typed array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, typed array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex128, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = new Float64Array( [ 1.0, 2.0 ] ); - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = new Float64Array( [ 1.0, 2.0 ] ); - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (default, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex128, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer, byteoffset; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer, byteoffset; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, 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; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 48 ); - out = filledarrayBy( buf, 16, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 24 ); - out = filledarrayBy( buf, 8, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int32', clbk ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint8c', clbk ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, 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; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 64 ); - out = filledarrayBy( buf, 16, 2, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset, length)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 1, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 1, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled array (default, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, iterator; thisArg)', opts, function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - ctx = { - 'count': 0 - }; - indices = []; - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, iterator; thisArg)', opts, function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - ctx = { - 'count': 0 - }; - indices = []; - out = filledarrayBy( arr, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex128, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = iterConstant( new Complex128( 3.0, 3.0 ), { - 'iter': 2 - }); - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = iterConstant( new Complex64( 3.0, 3.0 ), { - 'iter': 2 - }); - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); From e29f495e4d204821f188acc985ec483cdc7cb293 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Feb 2023 04:17:21 +0000 Subject: [PATCH 029/117] Transform error messages --- lib/main.js | 38 +++++++++++++++++++------------------- package.json | 2 +- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/lib/main.js b/lib/main.js index d27b055..d6fbe5e 100644 --- a/lib/main.js +++ b/lib/main.js @@ -32,7 +32,7 @@ var filledArray = require( '@stdlib/array-base-filled-by' ); var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); var iterLength = require( '@stdlib/iter-length' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -263,18 +263,18 @@ function filledarrayBy() { if ( isString( dtype ) ) { // Invoking this function with arguments `f( dtype, clbk[, thisArg] )` is not allowed (otherwise, we'd need to also allow `f( clbk[, thisArg] )`)... if ( nargs > 1 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format( '00L05' ) ); } ctor = ctors( dtype ); if ( ctor === null ) { - throw new TypeError( format( 'invalid argument. Must provide a recognized data type. Value: `%s`.', dtype ) ); + throw new TypeError( format( '00L2k', dtype ) ); } // Return an empty array having the specified dtype: return new ctor( 0 ); } // For all other supported invocations, we need at least two arguments... if ( nargs < 2 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format( '00L05' ) ); } // At this point, we need to do some argument juggling... nargs -= 1; // henceforth, the number of available arguments is `nargs+1` @@ -289,7 +289,7 @@ function filledarrayBy() { // Check if we were provided only a callback and a "this" context.. if ( nargs === 0 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format( '00L05' ) ); } } else { // "this" context is left undefined... @@ -302,12 +302,12 @@ function filledarrayBy() { nargs -= 1; clbk = arguments[ nargs ]; if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '00L2n', clbk ) ); } } // If were were only provided 2 arguments and the last argument was not a function, we've been provided an insufficient number of arguments... else { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format( '00L05' ) ); } // Now that we've processed the callback arguments, let's continue working backward to see if we've been provided a `dtype` argument... nargs -= 1; @@ -319,7 +319,7 @@ function filledarrayBy() { } ctor = ctors( dtype ); if ( ctor === null ) { - throw new TypeError( format( 'invalid argument. Must provide a recognized data type. Value: `%s`.', dtype ) ); + throw new TypeError( format( '00L2k', dtype ) ); } // At this point, we've resolved the output array data type, and now we can actually create the output array... if ( dtype === 'generic' ) { @@ -334,26 +334,26 @@ function filledarrayBy() { return filledArray( len, clbk, thisArg ); } if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format( '00L04' ) ); } if ( isObject( arg ) ) { if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.', arg ) ); + throw new TypeError( format( '00L2l', arg ) ); } if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00L2m', arg ) ); } arg = arg[ ITERATOR_SYMBOL ](); if ( !isFunction( arg.next ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00L2m', arg ) ); } return filledArrayIterator( arg, clbk, thisArg ); } - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00L2m', arg ) ); } else if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format( '00L04' ) ); } - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00L2m', arg ) ); } if ( nargs === 0 ) { // length || array-like || ArrayBuffer || iterable arg = arguments[ 0 ]; @@ -365,18 +365,18 @@ function filledarrayBy() { arr = new ctor( arg ); } else if ( isObject( arg ) ) { if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.', arg ) ); + throw new TypeError( format( '00L2l', arg ) ); } if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00L2m', arg ) ); } arg = arg[ ITERATOR_SYMBOL ](); if ( !isFunction( arg.next ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00L2m', arg ) ); } arr = new ctor( iterLength( arg ) ); } else { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00L2m', arg ) ); } } else if ( nargs === 1 ) { arr = new ctor( arguments[0], arguments[1] ); // (ArrayBuffer, byteOffset) diff --git a/package.json b/package.json index af68a13..65f63fa 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "@stdlib/assert-is-string": "^0.0.x", "@stdlib/blas-ext-base-gfill-by": "^0.0.x", "@stdlib/iter-length": "^0.0.x", - "@stdlib/string-format": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x", "@stdlib/symbol-iterator": "^0.0.x", "@stdlib/types": "^0.0.x" }, From 413020c8c6c6caf2da07e2df9cc8e5ff96a7b75e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Feb 2023 16:06:56 +0000 Subject: [PATCH 030/117] Remove files --- index.d.ts | 427 ------ index.mjs | 4 - index.mjs.map | 1 - stats.html | 4044 ------------------------------------------------- 4 files changed, 4476 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 2156674..0000000 --- a/index.d.ts +++ /dev/null @@ -1,427 +0,0 @@ -/* -* @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. -*/ - -// TypeScript Version: 2.0 - -/// - -import { RealOrComplexTypedArray, DataType } from '@stdlib/types/array'; -import { Collection } from '@stdlib/types/object'; -import { IterableIterator } from '@stdlib/types/iter'; - -/** -* Array or typed array. -*/ -type ArrayOrTypedArray = Array | RealOrComplexTypedArray; - -/** -* Nullary callback function. -* -* @returns fill value -*/ -type Nullary = () => any; - -/** -* Unary callback function. -* -* @param i - current array index -* @returns fill value -*/ -type Unary = ( i: number ) => any; - -/** -* Callback function. -* -* @param i - current array index -* @returns fill value -*/ -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 -* -* @example -* var arr = filledarrayBy(); -* // returns -* -* @example -* var arr = filledarrayBy( 'float32' ); -* // returns -*/ -declare function filledarrayBy( dtype?: DataType ): ArrayOrTypedArray; // tslint:disable-line:unified-signatures - -/** -* Creates a filled array according to a provided callback function and having a specified `length`. -* -* @param length - array length -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* -* var arr = filledarrayBy( 5, constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( length: number, clbk: Callback, thisArg?: any ): ArrayOrTypedArray; // tslint:disable-line:max-line-length unified-signatures - -/** -* 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 -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* -* var arr = filledarrayBy( 5, 'float64', constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( length: number, dtype: DataType, clbk: Callback, thisArg?: any ): ArrayOrTypedArray; // tslint:disable-line:max-line-length unified-signatures - -/** -* Creates a filled array from another `array` according to a provided callback function. -* -* @param array - typed array or array-like object -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* -* 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; // tslint:disable-line:max-line-length 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 -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* -* 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; // tslint:disable-line:max-line-length unified-signatures - -/** -* Creates a filled array from an iterable according to a callback function. -* -* @param iterable - iterable -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* var iterConstant = require( `@stdlib/iter/constant` ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarrayBy( it, constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( iterable: IterableIterator, callback: Callback, thisArg?: any ): ArrayOrTypedArray; // tslint:disable-line:max-line-length 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 -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* var iterConstant = require( `@stdlib/iter/constant` ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* 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; // tslint:disable-line:max-line-length unified-signatures - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; // tslint:disable-line:max-line-length - -/** -* 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. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; // tslint:disable-line:max-line-length unified-signatures - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; // tslint:disable-line:max-line-length - -/** -* 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. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; // tslint:disable-line:max-line-length unified-signatures - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; // tslint:disable-line:max-line-length 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. -* -* @param buffer - `ArrayBuffer` -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; // tslint:disable-line:max-line-length unified-signatures - - -// EXPORTS // - -export = filledarrayBy; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index ce0d7c1..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-ctors@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill-by@v0.0.10-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled-by@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";var w=d();function j(r,e,t){var s,i;for(s=[],i=-1;!r.next().done;)i+=1,s.push(e.call(t,i));return s}function a(r,e,t){var s;for(s=0;s1)throw new TypeError(p("00L05"));if(null===(b=o(g)))throw new TypeError(p("00L2k",g));return new b(0)}if(c<2)throw new TypeError(p("00L05"));if(n(arguments[c-=1]))if(n(arguments[c-1])){if(d=arguments[c],y=arguments[c-=1],0===c)throw new TypeError(p("00L05"))}else y=arguments[c];else{if(!(c>=2))throw new TypeError(p("00L05"));if(d=arguments[c],!n(y=arguments[c-=1]))throw new TypeError(p("00L2n",y))}if((c-=1)>=0&&r(arguments[c])?(g=arguments[c],c-=1):g="float64",null===(b=o(g)))throw new TypeError(p("00L2k",g));if("generic"===g){if(x=arguments[0],0===c){if(e(x)?u=x:t(x)&&(u=x.length),void 0!==u)return m(u,y,d);if(s(x))throw new Error(p("00L04"));if(i(x)){if(!1===w)throw new TypeError(p("00L2l",x));if(!n(x[f]))throw new TypeError(p("00L2m",x));if(x=x[f](),!n(x.next))throw new TypeError(p("00L2m",x));return j(x,y,d)}throw new TypeError(p("00L2m",x))}if(s(x))throw new Error(p("00L04"));throw new TypeError(p("00L2m",x))}if(0===c)if(t(x=arguments[0]))v=new b(x.length);else if(s(x))v=new b(x);else if(e(x))v=new b(x);else{if(!i(x))throw new TypeError(p("00L2m",x));if(!1===w)throw new TypeError(p("00L2l",x));if(!n(x[f]))throw new TypeError(p("00L2m",x));if(x=x[f](),!n(x.next))throw new TypeError(p("00L2m",x));v=new b(h(x))}else v=1===c?new b(arguments[0],arguments[1]):new b(arguments[0],arguments[1],arguments[2]);return v.length>0&&(/^complex/.test(g)?a(v,y,d):l(v.length,v,1,E)),v;function E(r,e){return y.call(d,e)}}export{c as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index cf25e56..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.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\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport isCollection from '@stdlib/assert-is-collection';\nimport isArrayBuffer from '@stdlib/assert-is-arraybuffer';\nimport isObject from '@stdlib/assert-is-object';\nimport isFunction from '@stdlib/assert-is-function';\nimport ctors from '@stdlib/array-ctors';\nimport gfillBy from '@stdlib/blas-ext-base-gfill-by';\nimport filledArray from '@stdlib/array-base-filled-by';\nimport hasIteratorSymbolSupport from '@stdlib/assert-has-iterator-symbol-support';\nimport ITERATOR_SYMBOL from '@stdlib/symbol-iterator';\nimport iterLength from '@stdlib/iter-length';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport();\nvar DEFAULT_DTYPE = 'float64';\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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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( format( '00L05' ) );\n\t\t}\n\t\tctor = ctors( dtype );\n\t\tif ( ctor === null ) {\n\t\t\tthrow new TypeError( format( '00L2k', 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( format( '00L05' ) );\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( format( '00L05' ) );\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( '00L2n', 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( format( '00L05' ) );\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( '00L2k', 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( format( '00L04' ) );\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( '00L2l', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00L2m', 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( '00L2m', 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( '00L2m', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format( '00L04' ) );\n\t\t}\n\t\tthrow new TypeError( format( '00L2m', 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( '00L2l', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00L2m', 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( '00L2m', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00L2m', 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\nexport default filledarrayBy;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","filledArrayIterator","it","clbk","thisArg","arr","i","next","done","push","call","filledAccessors","length","set","filledarrayBy","nargs","dtype","ctor","len","arg","arguments","ctors","isString","TypeError","format","isFunction","isNonNegativeInteger","isCollection","filledArray","isArrayBuffer","Error","isObject","ITERATOR_SYMBOL","iterLength","test","gfillBy","callback","value","aidx"],"mappings":";;gqCAuCA,IAAIA,EAAsBC,IAe1B,SAASC,EAAqBC,EAAIC,EAAMC,GACvC,IAAIC,EACAC,EAKJ,IAFAD,EAAM,GACNC,GAAK,GAEAJ,EAAGK,OACAC,MAGPF,GAAK,EACLD,EAAII,KAAMN,EAAKO,KAAMN,EAASE,IAE/B,OAAOD,CACR,CAWA,SAASM,EAAiBN,EAAKF,EAAMC,GACpC,IAAIE,EACJ,IAAMA,EAAI,EAAGA,EAAID,EAAIO,OAAQN,IAC5BD,EAAIQ,IAAKV,EAAKO,KAAMN,EAASE,GAAKA,GAEnC,OAAOD,CACR,CA4JA,SAASS,IACR,IAAIV,EACAW,EACAC,EACAb,EACAc,EACAZ,EACAa,EACAC,EAKJ,GAAe,KAHfJ,EAAQK,UAAUR,QAKjB,OAAO,IADPK,EAAOI,EAzNW,YA0ND,GAIlB,GAAKC,EADLN,EAAQI,UAAW,IACM,CAExB,GAAKL,EAAQ,EACZ,MAAM,IAAIQ,UAAWC,EAAQ,UAG9B,GAAc,QADdP,EAAOI,EAAOL,IAEb,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAGvC,OAAO,IAAIC,EAAM,EACjB,CAED,GAAKF,EAAQ,EACZ,MAAM,IAAIQ,UAAWC,EAAQ,UAM9B,GAAKC,EAAYL,UAHjBL,GAAS,IAKR,GAAKU,EAAYL,UAAWL,EAAM,KAMjC,GALAX,EAAUgB,UAAWL,GAErBZ,EAAOiB,UADPL,GAAS,GAIM,IAAVA,EACJ,MAAM,IAAIQ,UAAWC,EAAQ,eAI9BrB,EAAOiB,UAAWL,OAIf,MAAKA,GAAS,GAUlB,MAAM,IAAIQ,UAAWC,EAAQ,UAN7B,GAHApB,EAAUgB,UAAWL,IAGfU,EADNtB,EAAOiB,UADPL,GAAS,IAGR,MAAM,IAAIQ,UAAWC,EAAQ,QAASrB,GAMvC,CAUD,IARAY,GAAS,IACK,GAAKO,EAAUF,UAAWL,KACvCC,EAAQI,UAAWL,GACnBA,GAAS,GAETC,EArRkB,UAwRL,QADdC,EAAOI,EAAOL,IAEb,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAGvC,GAAe,YAAVA,EAAsB,CAE1B,GADAG,EAAMC,UAAW,GACF,IAAVL,EAAc,CAMlB,GALKW,EAAsBP,GAC1BD,EAAMC,EACKQ,EAAcR,KACzBD,EAAMC,EAAIP,aAEE,IAARM,EACJ,OAAOU,EAAaV,EAAKf,EAAMC,GAEhC,GAAKyB,EAAeV,GACnB,MAAM,IAAIW,MAAON,EAAQ,UAE1B,GAAKO,EAAUZ,GAAQ,CACtB,IAA6B,IAAxBpB,EACJ,MAAM,IAAIwB,UAAWC,EAAQ,QAASL,IAEvC,IAAMM,EAAYN,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASL,IAGvC,GADAA,EAAMA,EAAKa,MACLP,EAAYN,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,QAASL,IAEvC,OAAOlB,EAAqBkB,EAAKhB,EAAMC,EACvC,CACD,MAAM,IAAImB,UAAWC,EAAQ,QAASL,GACzC,CAAS,GAAKU,EAAeV,GAC1B,MAAM,IAAIW,MAAON,EAAQ,UAE1B,MAAM,IAAID,UAAWC,EAAQ,QAASL,GACtC,CACD,GAAe,IAAVJ,EAEJ,GAAKY,EADLR,EAAMC,UAAW,IAEhBf,EAAM,IAAIY,EAAME,EAAIP,aACd,GAAKiB,EAAeV,GAC1Bd,EAAM,IAAIY,EAAME,QACV,GAAKO,EAAsBP,GACjCd,EAAM,IAAIY,EAAME,OACV,KAAKY,EAAUZ,GAarB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAZtC,IAA6B,IAAxBpB,EACJ,MAAM,IAAIwB,UAAWC,EAAQ,QAASL,IAEvC,IAAMM,EAAYN,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASL,IAGvC,GADAA,EAAMA,EAAKa,MACLP,EAAYN,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,QAASL,IAEvCd,EAAM,IAAIY,EAAMgB,EAAYd,GAG5B,MAEDd,EADqB,IAAVU,EACL,IAAIE,EAAMG,UAAU,GAAIA,UAAU,IAElC,IAAIH,EAAMG,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKf,EAAIO,OAAS,IACZ,WAAWsB,KAAMlB,GACrBL,EAAiBN,EAAKF,EAAMC,GAE5B+B,EAAS9B,EAAIO,OAAQP,EAAK,EAAG+B,IAGxB/B,EAYP,SAAS+B,EAAUC,EAAOC,GACzB,OAAOnC,EAAKO,KAAMN,EAASkC,EAC3B,CACF"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 9c5f55f..0000000 --- a/stats.html +++ /dev/null @@ -1,4044 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From f138b041995ac48620a75ca3fc983dc8ab50c7db Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Feb 2023 16:08:25 +0000 Subject: [PATCH 031/117] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 791 --- .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 184 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 41 +- benchmark/benchmark.js | 319 -- benchmark/benchmark.length.complex128.js | 98 - benchmark/benchmark.length.complex64.js | 98 - benchmark/benchmark.length.float32.js | 97 - benchmark/benchmark.length.float64.js | 97 - benchmark/benchmark.length.generic.js | 97 - benchmark/benchmark.length.int16.js | 97 - benchmark/benchmark.length.int32.js | 97 - benchmark/benchmark.length.int8.js | 97 - benchmark/benchmark.length.uint16.js | 97 - benchmark/benchmark.length.uint32.js | 97 - benchmark/benchmark.length.uint8.js | 97 - benchmark/benchmark.length.uint8c.js | 97 - branches.md | 53 - docs/repl.txt | 174 - docs/types/test.ts | 606 -- examples/index.js | 37 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 192 - lib/main.js | 413 -- package.json | 90 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 4248 -------------- 49 files changed, 6202 insertions(+), 10262 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.length.complex128.js delete mode 100644 benchmark/benchmark.length.complex64.js delete mode 100644 benchmark/benchmark.length.float32.js delete mode 100644 benchmark/benchmark.length.float64.js delete mode 100644 benchmark/benchmark.length.generic.js delete mode 100644 benchmark/benchmark.length.int16.js delete mode 100644 benchmark/benchmark.length.int32.js delete mode 100644 benchmark/benchmark.length.int8.js delete mode 100644 benchmark/benchmark.length.uint16.js delete mode 100644 benchmark/benchmark.length.uint32.js delete mode 100644 benchmark/benchmark.length.uint8.js delete mode 100644 benchmark/benchmark.length.uint8c.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 29b5ceb..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-02-01T02:36:02.099Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 8be0b82..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 06a9a75..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index a00dbe5..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.11.0 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index df9d9d7..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 7902a7d..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 16e02e6..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '42 6 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4eea88..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,791 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -273,7 +266,7 @@ for ( i = 0; i < dt.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 421b48e..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,319 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); -var isArray = require( '@stdlib/assert-is-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var pkg = require( './../package.json' ).name; -var filledarrayBy = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 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=float64', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'float64', 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=float32', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'float32', 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; - var i; - - clbk = constantFunction( new Complex128( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'complex128', 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=complex64', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( new Complex64( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'complex64', 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=int32', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int32', 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=uint32', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint32', 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=int16', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int16', 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=uint16', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint16', 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=int8', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int8', 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=uint8', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint8', 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=uint8c', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint8c', 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=generic', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'generic', clbk ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.length.complex128.js b/benchmark/benchmark.length.complex128.js deleted file mode 100644 index 671de86..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var Complex128 = require( '@stdlib/complex-float64' ); -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( new Complex128( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'complex128', 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=complex128,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.complex64.js b/benchmark/benchmark.length.complex64.js deleted file mode 100644 index 52da4e3..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var Complex64 = require( '@stdlib/complex-float32' ); -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( new Complex64( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'complex64', 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=complex64,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.float32.js b/benchmark/benchmark.length.float32.js deleted file mode 100644 index 9b4ef9b..0000000 --- a/benchmark/benchmark.length.float32.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'float32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=float32,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.float64.js b/benchmark/benchmark.length.float64.js deleted file mode 100644 index 66cb6b6..0000000 --- a/benchmark/benchmark.length.float64.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'float64', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=float64,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.generic.js b/benchmark/benchmark.length.generic.js deleted file mode 100644 index 5194c1b..0000000 --- a/benchmark/benchmark.length.generic.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isArray = require( '@stdlib/assert-is-array' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'generic', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isArray( 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=generic,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int16.js b/benchmark/benchmark.length.int16.js deleted file mode 100644 index 6669b28..0000000 --- a/benchmark/benchmark.length.int16.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int16', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=int16,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int32.js b/benchmark/benchmark.length.int32.js deleted file mode 100644 index e9c5c88..0000000 --- a/benchmark/benchmark.length.int32.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=int32,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int8.js b/benchmark/benchmark.length.int8.js deleted file mode 100644 index 14bbadf..0000000 --- a/benchmark/benchmark.length.int8.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int8', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=int8,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint16.js b/benchmark/benchmark.length.uint16.js deleted file mode 100644 index d03b23e..0000000 --- a/benchmark/benchmark.length.uint16.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint16', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint16,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint32.js b/benchmark/benchmark.length.uint32.js deleted file mode 100644 index 1382134..0000000 --- a/benchmark/benchmark.length.uint32.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint32,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint8.js b/benchmark/benchmark.length.uint8.js deleted file mode 100644 index c135d6c..0000000 --- a/benchmark/benchmark.length.uint8.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint8', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint8,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint8c.js b/benchmark/benchmark.length.uint8c.js deleted file mode 100644 index 2f7523a..0000000 --- a/benchmark/benchmark.length.uint8c.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint8c', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint8c,len='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 18101fd..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by" -click B href "https://github.com/stdlib-js/array-filled-by/tree/main" -click C href "https://github.com/stdlib-js/array-filled-by/tree/production" -click D href "https://github.com/stdlib-js/array-filled-by/tree/esm" -click E href "https://github.com/stdlib-js/array-filled-by/tree/deno" -click F href "https://github.com/stdlib-js/array-filled-by/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by -[production-url]: https://github.com/stdlib-js/array-filled-by/tree/production -[deno-url]: https://github.com/stdlib-js/array-filled-by/tree/deno -[umd-url]: https://github.com/stdlib-js/array-filled-by/tree/umd -[esm-url]: https://github.com/stdlib-js/array-filled-by/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 5a68984..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,174 +0,0 @@ - -{{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) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr = {{alias}}() - - > arr = {{alias}}( 'float32' ) - - - -{{alias}}( length[, dtype], clbk[, thisArg] ) - Returns a filled array according to a provided callback function and having - a specified length. - - Parameters - ---------- - length: integer - Array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > function clbk() { return 1.0; }; - > var arr = {{alias}}( 5, clbk ) - [ 1.0, 1.0, 1.0, 1.0, 1.0 ] - > arr = {{alias}}( 5, 'int32', clbk ) - [ 1, 1, 1, 1, 1 ] - - -{{alias}}( array[, dtype], clbk[, thisArg] ) - Creates a filled array from another array (or array-like object) according - to a provided callback function. - - Parameters - ---------- - array: ArrayLikeObject - Array from which to generate another array. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias}}( [ 0.5, 0.5, 0.5 ], {{alias:@stdlib/utils/constant-function}}( 2.0 ) ) - [ 2.0, 2.0, 2.0 ] - > var arr2 = {{alias}}( arr1, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( iterable[, dtype], clbk[, thisArg] ) - Creates a filled array from an iterable according to a provided callback - function. - - Parameters - ---------- - iterable: Iterable - Iterable from which to generate an array. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias:@stdlib/iter/constant}}( 3.0, {'iter': 3} ); - > var arr2 = {{alias}}( arr1, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( buffer[, byteOffset[, length]][, dtype], clbk[, thisArg] ) - Returns a filled typed array view of an ArrayBuffer according to a provided - callback function. - - The 'generic' array data type is *not* supported. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( buf, 0, 4, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0, 1.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 394ac49..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,606 +0,0 @@ -/* -* @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. -*/ - -/// - -import { IterableIterator } from '@stdlib/types/iter'; -import filledarrayBy = require( './index' ); - - -/** -* Returns an iterator protocol-compliant object. -* -* @returns iterator protocol-compliant object -*/ -function iterator(): IterableIterator { - const obj: IterableIterator = { - [Symbol.iterator]: iterator, - 'next': next - }; - return obj; -} - -/** -* Implements the iterator protocol `next` method. -* -* @returns iterator protocol-compliant object -*/ -function next(): any { - return { - 'value': 1.0, - 'done': false - }; -} - -/** -* Callback function. -* -* @param i - current array index -* @returns return value -*/ -function clbk( i: number ): number { - return i; -} - - -// TESTS // - -// The function returns an array or typed array... -{ - filledarrayBy(); // $ExpectType ArrayOrTypedArray - filledarrayBy( 'float32' ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( 10, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( 10, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( 10, 'int32', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( 10, 'int32', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const x = new Float64Array( 10 ); - filledarrayBy( x, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( x, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( x, 'uint8', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( x, 'uint8', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const y = [ 2.0, 2.0, 2.0 ]; - filledarrayBy( y, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( y, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( y, 'float64', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( y, 'float64', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const it = iterator(); - filledarrayBy( it, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( it, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( it, 'uint8c', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( it, 'uint8c', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const buf = new ArrayBuffer( 32 ); - filledarrayBy( buf, clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 'uint32', clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 'uint32', clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 8, clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 8, clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 8, 'uint16', clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 8, 'uint16', clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 8, 2, clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 8, 2, clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 8, 2, 'int16', clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 8, 2, 'int16', clbk, {} ); // $ExpectType RealOrComplexTypedArray -} - -// The compiler throws an error if a callback function argument is not a function... -{ - filledarrayBy( 'float64', '5' ); // $ExpectError - filledarrayBy( 'float64', 1.0 ); // $ExpectError - filledarrayBy( 'float64', false ); // $ExpectError - filledarrayBy( 'float64', true ); // $ExpectError - filledarrayBy( 'float64', null ); // $ExpectError - filledarrayBy( 'float64', undefined ); // $ExpectError - filledarrayBy( 'float64', [] ); // $ExpectError - filledarrayBy( 'float64', {} ); // $ExpectError - - filledarrayBy( 'float64', '5', {} ); // $ExpectError - filledarrayBy( 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( 'float64', false, {} ); // $ExpectError - filledarrayBy( 'float64', true, {} ); // $ExpectError - filledarrayBy( 'float64', null, {} ); // $ExpectError - filledarrayBy( 'float64', undefined, {} ); // $ExpectError - filledarrayBy( 'float64', [], {} ); // $ExpectError - filledarrayBy( 'float64', {}, {} ); // $ExpectError - - filledarrayBy( 10, '5' ); // $ExpectError - filledarrayBy( 10, 1.0 ); // $ExpectError - filledarrayBy( 10, false ); // $ExpectError - filledarrayBy( 10, true ); // $ExpectError - filledarrayBy( 10, null ); // $ExpectError - filledarrayBy( 10, undefined ); // $ExpectError - filledarrayBy( 10, [] ); // $ExpectError - filledarrayBy( 10, {} ); // $ExpectError - - filledarrayBy( 10, '5', {} ); // $ExpectError - filledarrayBy( 10, 1.0, {} ); // $ExpectError - filledarrayBy( 10, false, {} ); // $ExpectError - filledarrayBy( 10, true, {} ); // $ExpectError - filledarrayBy( 10, null, {} ); // $ExpectError - filledarrayBy( 10, undefined, {} ); // $ExpectError - filledarrayBy( 10, [], {} ); // $ExpectError - filledarrayBy( 10, {}, {} ); // $ExpectError - - filledarrayBy( 10, 'float64', '5' ); // $ExpectError - filledarrayBy( 10, 'float64', 1.0 ); // $ExpectError - filledarrayBy( 10, 'float64', false ); // $ExpectError - filledarrayBy( 10, 'float64', true ); // $ExpectError - filledarrayBy( 10, 'float64', null ); // $ExpectError - filledarrayBy( 10, 'float64', undefined ); // $ExpectError - filledarrayBy( 10, 'float64', [] ); // $ExpectError - filledarrayBy( 10, 'float64', {} ); // $ExpectError - - filledarrayBy( 10, 'float64', '5', {} ); // $ExpectError - filledarrayBy( 10, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( 10, 'float64', false, {} ); // $ExpectError - filledarrayBy( 10, 'float64', true, {} ); // $ExpectError - filledarrayBy( 10, 'float64', null, {} ); // $ExpectError - filledarrayBy( 10, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( 10, 'float64', [], {} ); // $ExpectError - filledarrayBy( 10, 'float64', {}, {} ); // $ExpectError - - const x = new Float64Array( 10 ); - filledarrayBy( x, '5' ); // $ExpectError - filledarrayBy( x, 1.0 ); // $ExpectError - filledarrayBy( x, false ); // $ExpectError - filledarrayBy( x, true ); // $ExpectError - filledarrayBy( x, null ); // $ExpectError - filledarrayBy( x, undefined ); // $ExpectError - filledarrayBy( x, [] ); // $ExpectError - filledarrayBy( x, {} ); // $ExpectError - - filledarrayBy( x, '5', {} ); // $ExpectError - filledarrayBy( x, 1.0, {} ); // $ExpectError - filledarrayBy( x, false, {} ); // $ExpectError - filledarrayBy( x, true, {} ); // $ExpectError - filledarrayBy( x, null, {} ); // $ExpectError - filledarrayBy( x, undefined, {} ); // $ExpectError - filledarrayBy( x, [], {} ); // $ExpectError - filledarrayBy( x, {}, {} ); // $ExpectError - - filledarrayBy( x, 'float64', '5' ); // $ExpectError - filledarrayBy( x, 'float64', 1.0 ); // $ExpectError - filledarrayBy( x, 'float64', false ); // $ExpectError - filledarrayBy( x, 'float64', true ); // $ExpectError - filledarrayBy( x, 'float64', null ); // $ExpectError - filledarrayBy( x, 'float64', undefined ); // $ExpectError - filledarrayBy( x, 'float64', [] ); // $ExpectError - filledarrayBy( x, 'float64', {} ); // $ExpectError - - filledarrayBy( x, 'float64', '5', {} ); // $ExpectError - filledarrayBy( x, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( x, 'float64', false, {} ); // $ExpectError - filledarrayBy( x, 'float64', true, {} ); // $ExpectError - filledarrayBy( x, 'float64', null, {} ); // $ExpectError - filledarrayBy( x, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( x, 'float64', [], {} ); // $ExpectError - filledarrayBy( x, 'float64', {}, {} ); // $ExpectError - - const y = [ 2.0, 2.0, 2.0 ]; - filledarrayBy( y, '5' ); // $ExpectError - filledarrayBy( y, 1.0 ); // $ExpectError - filledarrayBy( y, false ); // $ExpectError - filledarrayBy( y, true ); // $ExpectError - filledarrayBy( y, null ); // $ExpectError - filledarrayBy( y, undefined ); // $ExpectError - filledarrayBy( y, [] ); // $ExpectError - filledarrayBy( y, {} ); // $ExpectError - - filledarrayBy( y, '5', {} ); // $ExpectError - filledarrayBy( y, 1.0, {} ); // $ExpectError - filledarrayBy( y, false, {} ); // $ExpectError - filledarrayBy( y, true, {} ); // $ExpectError - filledarrayBy( y, null, {} ); // $ExpectError - filledarrayBy( y, undefined, {} ); // $ExpectError - filledarrayBy( y, [], {} ); // $ExpectError - filledarrayBy( y, {}, {} ); // $ExpectError - - filledarrayBy( y, 'float64', '5' ); // $ExpectError - filledarrayBy( y, 'float64', 1.0 ); // $ExpectError - filledarrayBy( y, 'float64', false ); // $ExpectError - filledarrayBy( y, 'float64', true ); // $ExpectError - filledarrayBy( y, 'float64', null ); // $ExpectError - filledarrayBy( y, 'float64', undefined ); // $ExpectError - filledarrayBy( y, 'float64', [] ); // $ExpectError - filledarrayBy( y, 'float64', {} ); // $ExpectError - - filledarrayBy( y, 'float64', '5', {} ); // $ExpectError - filledarrayBy( y, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( y, 'float64', false, {} ); // $ExpectError - filledarrayBy( y, 'float64', true, {} ); // $ExpectError - filledarrayBy( y, 'float64', null, {} ); // $ExpectError - filledarrayBy( y, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( y, 'float64', [], {} ); // $ExpectError - filledarrayBy( y, 'float64', {}, {} ); // $ExpectError - - const it = iterator(); - filledarrayBy( it, '5' ); // $ExpectError - filledarrayBy( it, 1.0 ); // $ExpectError - filledarrayBy( it, false ); // $ExpectError - filledarrayBy( it, true ); // $ExpectError - filledarrayBy( it, null ); // $ExpectError - filledarrayBy( it, undefined ); // $ExpectError - filledarrayBy( it, [] ); // $ExpectError - filledarrayBy( it, {} ); // $ExpectError - - filledarrayBy( it, '5', {} ); // $ExpectError - filledarrayBy( it, 1.0, {} ); // $ExpectError - filledarrayBy( it, false, {} ); // $ExpectError - filledarrayBy( it, true, {} ); // $ExpectError - filledarrayBy( it, null, {} ); // $ExpectError - filledarrayBy( it, undefined, {} ); // $ExpectError - filledarrayBy( it, [], {} ); // $ExpectError - filledarrayBy( it, {}, {} ); // $ExpectError - - filledarrayBy( it, 'float64', '5' ); // $ExpectError - filledarrayBy( it, 'float64', 1.0 ); // $ExpectError - filledarrayBy( it, 'float64', false ); // $ExpectError - filledarrayBy( it, 'float64', true ); // $ExpectError - filledarrayBy( it, 'float64', null ); // $ExpectError - filledarrayBy( it, 'float64', undefined ); // $ExpectError - filledarrayBy( it, 'float64', [] ); // $ExpectError - filledarrayBy( it, 'float64', {} ); // $ExpectError - - filledarrayBy( it, 'float64', '5', {} ); // $ExpectError - filledarrayBy( it, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( it, 'float64', false, {} ); // $ExpectError - filledarrayBy( it, 'float64', true, {} ); // $ExpectError - filledarrayBy( it, 'float64', null, {} ); // $ExpectError - filledarrayBy( it, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( it, 'float64', [], {} ); // $ExpectError - filledarrayBy( it, 'float64', {}, {} ); // $ExpectError - - const buf = new ArrayBuffer( 32 ); - filledarrayBy( buf, '5' ); // $ExpectError - filledarrayBy( buf, 1.0 ); // $ExpectError - filledarrayBy( buf, false ); // $ExpectError - filledarrayBy( buf, true ); // $ExpectError - filledarrayBy( buf, null ); // $ExpectError - filledarrayBy( buf, undefined ); // $ExpectError - filledarrayBy( buf, [] ); // $ExpectError - filledarrayBy( buf, {} ); // $ExpectError - - filledarrayBy( buf, '5', {} ); // $ExpectError - filledarrayBy( buf, 1.0, {} ); // $ExpectError - filledarrayBy( buf, false, {} ); // $ExpectError - filledarrayBy( buf, true, {} ); // $ExpectError - filledarrayBy( buf, null, {} ); // $ExpectError - filledarrayBy( buf, undefined, {} ); // $ExpectError - filledarrayBy( buf, [], {} ); // $ExpectError - filledarrayBy( buf, {}, {} ); // $ExpectError - - filledarrayBy( buf, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 'float64', false ); // $ExpectError - filledarrayBy( buf, 'float64', true ); // $ExpectError - filledarrayBy( buf, 'float64', null ); // $ExpectError - filledarrayBy( buf, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 'float64', {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5' ); // $ExpectError - filledarrayBy( buf, 8, 1.0 ); // $ExpectError - filledarrayBy( buf, 8, false ); // $ExpectError - filledarrayBy( buf, 8, true ); // $ExpectError - filledarrayBy( buf, 8, null ); // $ExpectError - filledarrayBy( buf, 8, undefined ); // $ExpectError - filledarrayBy( buf, 8, [] ); // $ExpectError - filledarrayBy( buf, 8, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, false, {} ); // $ExpectError - filledarrayBy( buf, 8, true, {} ); // $ExpectError - filledarrayBy( buf, 8, null, {} ); // $ExpectError - filledarrayBy( buf, 8, undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, [], {} ); // $ExpectError - filledarrayBy( buf, 8, {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 8, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 'float64', false ); // $ExpectError - filledarrayBy( buf, 8, 'float64', true ); // $ExpectError - filledarrayBy( buf, 8, 'float64', null ); // $ExpectError - filledarrayBy( buf, 8, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 8, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 8, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 8, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, '5' ); // $ExpectError - filledarrayBy( buf, 8, 2, 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 2, false ); // $ExpectError - filledarrayBy( buf, 8, 2, true ); // $ExpectError - filledarrayBy( buf, 8, 2, null ); // $ExpectError - filledarrayBy( buf, 8, 2, undefined ); // $ExpectError - filledarrayBy( buf, 8, 2, [] ); // $ExpectError - filledarrayBy( buf, 8, 2, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, false, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, true, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, null, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, [], {} ); // $ExpectError - filledarrayBy( buf, 8, 2, {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', false ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', true ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', null ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', {}, {} ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid length, typed array, array-like object, `ArrayBuffer`, or iterable argument... -{ - filledarrayBy( false, clbk ); // $ExpectError - filledarrayBy( true, clbk ); // $ExpectError - filledarrayBy( null, clbk ); // $ExpectError - filledarrayBy( {}, clbk ); // $ExpectError - - filledarrayBy( false, clbk, {} ); // $ExpectError - filledarrayBy( true, clbk, {} ); // $ExpectError - filledarrayBy( null, clbk, {} ); // $ExpectError - filledarrayBy( {}, clbk, {} ); // $ExpectError - - filledarrayBy( false, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 'float64', clbk ); // $ExpectError - - filledarrayBy( false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, clbk ); // $ExpectError - filledarrayBy( 1.0, 8, clbk ); // $ExpectError - filledarrayBy( false, 8, clbk ); // $ExpectError - filledarrayBy( true, 8, clbk ); // $ExpectError - filledarrayBy( null, 8, clbk ); // $ExpectError - filledarrayBy( undefined, 8, clbk ); // $ExpectError - filledarrayBy( [], 8, clbk ); // $ExpectError - filledarrayBy( {}, 8, clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, clbk ); // $ExpectError - - filledarrayBy( '5', 8, clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, clbk, {} ); // $ExpectError - filledarrayBy( false, 8, clbk, {} ); // $ExpectError - filledarrayBy( true, 8, clbk, {} ); // $ExpectError - filledarrayBy( null, 8, clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, clbk, {} ); // $ExpectError - filledarrayBy( [], 8, clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 'float64', clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( false, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( [], 8, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 'float64', clbk ); // $ExpectError - - filledarrayBy( '5', 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 2, clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 2, clbk ); // $ExpectError - filledarrayBy( false, 8, 2, clbk ); // $ExpectError - filledarrayBy( true, 8, 2, clbk ); // $ExpectError - filledarrayBy( null, 8, 2, clbk ); // $ExpectError - filledarrayBy( undefined, 8, 2, clbk ); // $ExpectError - filledarrayBy( [], 8, 2, clbk ); // $ExpectError - filledarrayBy( {}, 8, 2, clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, clbk ); // $ExpectError - - filledarrayBy( '5', 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( false, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( [], 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, 'float64', clbk ); // $ExpectError - - filledarrayBy( '5', 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a byte offset argument which is not a number... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, false, clbk ); // $ExpectError - filledarrayBy( buf, true, clbk ); // $ExpectError - filledarrayBy( buf, null, clbk ); // $ExpectError - filledarrayBy( buf, [], clbk ); // $ExpectError - filledarrayBy( buf, {}, clbk ); // $ExpectError - - filledarrayBy( buf, false, clbk, {} ); // $ExpectError - filledarrayBy( buf, true, clbk, {} ); // $ExpectError - filledarrayBy( buf, null, clbk, {} ); // $ExpectError - filledarrayBy( buf, [], clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, clbk, {} ); // $ExpectError - - filledarrayBy( buf, '5', 'float64', clbk ); // $ExpectError - filledarrayBy( buf, false, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, true, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, null, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, [], 'float64', clbk ); // $ExpectError - filledarrayBy( buf, {}, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, '5', 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( buf, false, 2, clbk ); // $ExpectError - filledarrayBy( buf, true, 2, clbk ); // $ExpectError - filledarrayBy( buf, null, 2, clbk ); // $ExpectError - filledarrayBy( buf, [], 2, clbk ); // $ExpectError - filledarrayBy( buf, {}, 2, clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, clbk ); // $ExpectError - - filledarrayBy( buf, false, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, clbk, {} ); // $ExpectError - - filledarrayBy( buf, '5', 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, false, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, true, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, null, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, undefined, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, [], 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, {}, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, '5', 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, false, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, undefined, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a view length argument which is not a number... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, 8, false, clbk ); // $ExpectError - filledarrayBy( buf, 8, true, clbk ); // $ExpectError - filledarrayBy( buf, 8, null, clbk ); // $ExpectError - filledarrayBy( buf, 8, [], clbk ); // $ExpectError - filledarrayBy( buf, 8, {}, clbk ); // $ExpectError - - filledarrayBy( buf, 8, false, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, true, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, null, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, [], clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, {}, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, clbk, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5', 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, false, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, true, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, null, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, [], 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, {}, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, 8, '5', 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, [], 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, {}, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided too many arguments... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, 8, 2, 'float64', 1, clbk, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 997a381..0000000 --- a/examples/index.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ).factory; -var dtypes = require( '@stdlib/array-typed-real-dtypes' ); -var filledarrayBy = require( './../lib' ); - -// Create a pseudorandom number generator: -var rand = discreteUniform( 0, 100 ); - -// Get a list of array data types: -var dt = dtypes(); - -// Generate filled arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = filledarrayBy( 10, dt[ i ], rand ); - console.log( arr ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 3fc2784..2156674 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { RealOrComplexTypedArray, DataType } from '@stdlib/types/array'; import { Collection } from '@stdlib/types/object'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..a86535e --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-ctors@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill-by@v0.0.10-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled-by@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";var w=d();function j(r,e,t){var s,i;for(s=[],i=-1;!r.next().done;)i+=1,s.push(e.call(t,i));return s}function a(r,e,t){var s;for(s=0;s1)throw new TypeError(p("00L05"));if(null===(b=o(g)))throw new TypeError(p("00L2k",g));return new b(0)}if(c<2)throw new TypeError(p("00L05"));if(n(arguments[c-=1]))if(n(arguments[c-1])){if(d=arguments[c],y=arguments[c-=1],0===c)throw new TypeError(p("00L05"))}else y=arguments[c];else{if(!(c>=2))throw new TypeError(p("00L05"));if(d=arguments[c],!n(y=arguments[c-=1]))throw new TypeError(p("00L2n",y))}if((c-=1)>=0&&r(arguments[c])?(g=arguments[c],c-=1):g="float64",null===(b=o(g)))throw new TypeError(p("00L2k",g));if("generic"===g){if(x=arguments[0],0===c){if(e(x)?u=x:t(x)&&(u=x.length),void 0!==u)return m(u,y,d);if(s(x))throw new Error(p("00L04"));if(i(x)){if(!1===w)throw new TypeError(p("00L2l",x));if(!n(x[f]))throw new TypeError(p("00L2m",x));if(x=x[f](),!n(x.next))throw new TypeError(p("00L2m",x));return j(x,y,d)}throw new TypeError(p("00L2m",x))}if(s(x))throw new Error(p("00L04"));throw new TypeError(p("00L2m",x))}if(0===c)if(t(x=arguments[0]))v=new b(x.length);else if(s(x))v=new b(x);else if(e(x))v=new b(x);else{if(!i(x))throw new TypeError(p("00L2m",x));if(!1===w)throw new TypeError(p("00L2l",x));if(!n(x[f]))throw new TypeError(p("00L2m",x));if(x=x[f](),!n(x.next))throw new TypeError(p("00L2m",x));v=new b(h(x))}else v=1===c?new b(arguments[0],arguments[1]):new b(arguments[0],arguments[1],arguments[2]);return v.length>0&&(/^complex/.test(g)?a(v,y,d):l(v.length,v,1,E)),v;function E(r,e){return y.call(d,e)}}export{c as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..cf25e56 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.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\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport isCollection from '@stdlib/assert-is-collection';\nimport isArrayBuffer from '@stdlib/assert-is-arraybuffer';\nimport isObject from '@stdlib/assert-is-object';\nimport isFunction from '@stdlib/assert-is-function';\nimport ctors from '@stdlib/array-ctors';\nimport gfillBy from '@stdlib/blas-ext-base-gfill-by';\nimport filledArray from '@stdlib/array-base-filled-by';\nimport hasIteratorSymbolSupport from '@stdlib/assert-has-iterator-symbol-support';\nimport ITERATOR_SYMBOL from '@stdlib/symbol-iterator';\nimport iterLength from '@stdlib/iter-length';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport();\nvar DEFAULT_DTYPE = 'float64';\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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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( format( '00L05' ) );\n\t\t}\n\t\tctor = ctors( dtype );\n\t\tif ( ctor === null ) {\n\t\t\tthrow new TypeError( format( '00L2k', 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( format( '00L05' ) );\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( format( '00L05' ) );\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( '00L2n', 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( format( '00L05' ) );\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( '00L2k', 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( format( '00L04' ) );\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( '00L2l', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00L2m', 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( '00L2m', 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( '00L2m', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format( '00L04' ) );\n\t\t}\n\t\tthrow new TypeError( format( '00L2m', 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( '00L2l', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00L2m', 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( '00L2m', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00L2m', 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\nexport default filledarrayBy;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","filledArrayIterator","it","clbk","thisArg","arr","i","next","done","push","call","filledAccessors","length","set","filledarrayBy","nargs","dtype","ctor","len","arg","arguments","ctors","isString","TypeError","format","isFunction","isNonNegativeInteger","isCollection","filledArray","isArrayBuffer","Error","isObject","ITERATOR_SYMBOL","iterLength","test","gfillBy","callback","value","aidx"],"mappings":";;gqCAuCA,IAAIA,EAAsBC,IAe1B,SAASC,EAAqBC,EAAIC,EAAMC,GACvC,IAAIC,EACAC,EAKJ,IAFAD,EAAM,GACNC,GAAK,GAEAJ,EAAGK,OACAC,MAGPF,GAAK,EACLD,EAAII,KAAMN,EAAKO,KAAMN,EAASE,IAE/B,OAAOD,CACR,CAWA,SAASM,EAAiBN,EAAKF,EAAMC,GACpC,IAAIE,EACJ,IAAMA,EAAI,EAAGA,EAAID,EAAIO,OAAQN,IAC5BD,EAAIQ,IAAKV,EAAKO,KAAMN,EAASE,GAAKA,GAEnC,OAAOD,CACR,CA4JA,SAASS,IACR,IAAIV,EACAW,EACAC,EACAb,EACAc,EACAZ,EACAa,EACAC,EAKJ,GAAe,KAHfJ,EAAQK,UAAUR,QAKjB,OAAO,IADPK,EAAOI,EAzNW,YA0ND,GAIlB,GAAKC,EADLN,EAAQI,UAAW,IACM,CAExB,GAAKL,EAAQ,EACZ,MAAM,IAAIQ,UAAWC,EAAQ,UAG9B,GAAc,QADdP,EAAOI,EAAOL,IAEb,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAGvC,OAAO,IAAIC,EAAM,EACjB,CAED,GAAKF,EAAQ,EACZ,MAAM,IAAIQ,UAAWC,EAAQ,UAM9B,GAAKC,EAAYL,UAHjBL,GAAS,IAKR,GAAKU,EAAYL,UAAWL,EAAM,KAMjC,GALAX,EAAUgB,UAAWL,GAErBZ,EAAOiB,UADPL,GAAS,GAIM,IAAVA,EACJ,MAAM,IAAIQ,UAAWC,EAAQ,eAI9BrB,EAAOiB,UAAWL,OAIf,MAAKA,GAAS,GAUlB,MAAM,IAAIQ,UAAWC,EAAQ,UAN7B,GAHApB,EAAUgB,UAAWL,IAGfU,EADNtB,EAAOiB,UADPL,GAAS,IAGR,MAAM,IAAIQ,UAAWC,EAAQ,QAASrB,GAMvC,CAUD,IARAY,GAAS,IACK,GAAKO,EAAUF,UAAWL,KACvCC,EAAQI,UAAWL,GACnBA,GAAS,GAETC,EArRkB,UAwRL,QADdC,EAAOI,EAAOL,IAEb,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAGvC,GAAe,YAAVA,EAAsB,CAE1B,GADAG,EAAMC,UAAW,GACF,IAAVL,EAAc,CAMlB,GALKW,EAAsBP,GAC1BD,EAAMC,EACKQ,EAAcR,KACzBD,EAAMC,EAAIP,aAEE,IAARM,EACJ,OAAOU,EAAaV,EAAKf,EAAMC,GAEhC,GAAKyB,EAAeV,GACnB,MAAM,IAAIW,MAAON,EAAQ,UAE1B,GAAKO,EAAUZ,GAAQ,CACtB,IAA6B,IAAxBpB,EACJ,MAAM,IAAIwB,UAAWC,EAAQ,QAASL,IAEvC,IAAMM,EAAYN,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASL,IAGvC,GADAA,EAAMA,EAAKa,MACLP,EAAYN,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,QAASL,IAEvC,OAAOlB,EAAqBkB,EAAKhB,EAAMC,EACvC,CACD,MAAM,IAAImB,UAAWC,EAAQ,QAASL,GACzC,CAAS,GAAKU,EAAeV,GAC1B,MAAM,IAAIW,MAAON,EAAQ,UAE1B,MAAM,IAAID,UAAWC,EAAQ,QAASL,GACtC,CACD,GAAe,IAAVJ,EAEJ,GAAKY,EADLR,EAAMC,UAAW,IAEhBf,EAAM,IAAIY,EAAME,EAAIP,aACd,GAAKiB,EAAeV,GAC1Bd,EAAM,IAAIY,EAAME,QACV,GAAKO,EAAsBP,GACjCd,EAAM,IAAIY,EAAME,OACV,KAAKY,EAAUZ,GAarB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAZtC,IAA6B,IAAxBpB,EACJ,MAAM,IAAIwB,UAAWC,EAAQ,QAASL,IAEvC,IAAMM,EAAYN,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASL,IAGvC,GADAA,EAAMA,EAAKa,MACLP,EAAYN,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,QAASL,IAEvCd,EAAM,IAAIY,EAAMgB,EAAYd,GAG5B,MAEDd,EADqB,IAAVU,EACL,IAAIE,EAAMG,UAAU,GAAIA,UAAU,IAElC,IAAIH,EAAMG,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKf,EAAIO,OAAS,IACZ,WAAWsB,KAAMlB,GACrBL,EAAiBN,EAAKF,EAAMC,GAE5B+B,EAAS9B,EAAIO,OAAQP,EAAK,EAAG+B,IAGxB/B,EAYP,SAAS+B,EAAUC,EAAOC,GACzB,OAAOnC,EAAKO,KAAMN,EAASkC,EAC3B,CACF"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d115cf0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,192 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -/** -* Create a filled array according to a provided callback function. -* -* @module @stdlib/array-filled-by -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* var arr = filledarrayBy(); -* // returns -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'generic', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( [ 0.5, 0.5 ], clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1; -* } -* -* var arr = filledarrayBy( [ 5, -3 ], 'int32', clbk ); -* // returns [ 1, 1 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk1() { -* return 10; -* } -* -* function clbk2() { -* return 1.0; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, clbk2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk1() { -* return 1.0; -* } -* -* function clbk2() { -* return 2; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, 'uint32', clbk2 ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 'float32', clbk ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, clbk ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, 'int32', clbk ); -* // returns [ 1, 1 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index d6fbe5e..0000000 --- a/lib/main.js +++ /dev/null @@ -1,413 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var isCollection = require( '@stdlib/assert-is-collection' ); -var isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isObject = require( '@stdlib/assert-is-object' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var ctors = require( '@stdlib/array-ctors' ); -var gfillBy = require( '@stdlib/blas-ext-base-gfill-by' ); -var filledArray = require( '@stdlib/array-base-filled-by' ); -var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var iterLength = require( '@stdlib/iter-length' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport(); -var DEFAULT_DTYPE = 'float64'; - - -// FUNCTIONS // - -/** -* Creates a filled "generic" array from an iterator. -* -* @private -* @param {Iterable} it - iterator -* @param {Callback} clbk - callback function -* @param {*} thisArg - callback function execution context -* @returns {Array} filled array -*/ -function filledArrayIterator( it, clbk, thisArg ) { - var arr; - var i; - var v; - - arr = []; - i = -1; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - i += 1; - arr.push( clbk.call( thisArg, i ) ); - } - return arr; -} - -/** -* Fills an array exposing accessors for getting and setting array elements. -* -* @private -* @param {Collection} arr - input array -* @param {Callback} clbk - callback function -* @param {*} thisArg - callback function execution context -* @returns {Collection} input array -*/ -function filledAccessors( arr, clbk, thisArg ) { - var i; - for ( i = 0; i < arr.length; i++ ) { - arr.set( clbk.call( thisArg, i ), i ); - } - return arr; -} - - -// MAIN // - -/** -* Creates a filled array according to a provided callback function. -* -* @param {(NonNegativeInteger|TypedArray|ArrayLikeObject|ArrayBuffer|Iterable)} [arg] - a length, typed array, array-like object, buffer, or iterable -* @param {NonNegativeInteger} [byteOffset=0] - byte offset -* @param {NonNegativeInteger} [length] - view length -* @param {string} [dtype="float64"] - data type -* @param {Callback} [clbk] - callback to invoke -* @param {*} [thisArg] - callback execution context -* @throws {TypeError} must provide a recognized data type -* @throws {TypeError} must provide a length, typed array, array-like object, buffer, or iterable -* @throws {TypeError} callback argument must be a function. -* @throws {Error} creating a generic array from an `ArrayBuffer` is not supported -* @returns {(TypedArray|Array)} array or typed array -* -* @example -* var arr = filledarrayBy(); -* // returns -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'generic', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( [ 0.5, 0.5 ], clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1; -* } -* -* var arr = filledarrayBy( [ 5, -3 ], 'int32', clbk ); -* // returns [ 1, 1 ] -* -* @example -* function clbk1() { -* return 10; -* } -* -* function clbk2() { -* return 1.0; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, clbk2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk1() { -* return 1.0; -* } -* -* function clbk2() { -* return 2; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, 'uint32', clbk2 ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 'float32', clbk ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, clbk ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, 'int32', clbk ); -* // returns [ 1, 1 ] -*/ -function filledarrayBy() { - var thisArg; - var nargs; - var dtype; - var clbk; - var ctor; - var arr; - var len; - var arg; - - nargs = arguments.length; - - // If we weren't provided any arguments, return an empty array... - if ( nargs === 0 ) { - ctor = ctors( DEFAULT_DTYPE ); - return new ctor( 0 ); - } - // Check if we were provided a dtype as the first argument... - dtype = arguments[ 0 ]; - if ( isString( dtype ) ) { - // Invoking this function with arguments `f( dtype, clbk[, thisArg] )` is not allowed (otherwise, we'd need to also allow `f( clbk[, thisArg] )`)... - if ( nargs > 1 ) { - throw new TypeError( format( '00L05' ) ); - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '00L2k', dtype ) ); - } - // Return an empty array having the specified dtype: - return new ctor( 0 ); - } - // For all other supported invocations, we need at least two arguments... - if ( nargs < 2 ) { - throw new TypeError( format( '00L05' ) ); - } - // At this point, we need to do some argument juggling... - nargs -= 1; // henceforth, the number of available arguments is `nargs+1` - - // Determine whether the last argument is a callback or "this" context... - if ( isFunction( arguments[ nargs ] ) ) { - // 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... - if ( isFunction( arguments[ nargs-1 ] ) ) { - thisArg = arguments[ nargs ]; - nargs -= 1; - clbk = arguments[ nargs ]; - - // Check if we were provided only a callback and a "this" context.. - if ( nargs === 0 ) { - throw new TypeError( format( '00L05' ) ); - } - } else { - // "this" context is left undefined... - clbk = arguments[ nargs ]; - } - } - // 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... - else if ( nargs >= 2 ) { - thisArg = arguments[ nargs ]; - nargs -= 1; - clbk = arguments[ nargs ]; - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '00L2n', clbk ) ); - } - } - // If were were only provided 2 arguments and the last argument was not a function, we've been provided an insufficient number of arguments... - else { - throw new TypeError( format( '00L05' ) ); - } - // Now that we've processed the callback arguments, let's continue working backward to see if we've been provided a `dtype` argument... - nargs -= 1; - if ( nargs >= 0 && isString( arguments[ nargs ] ) ) { - dtype = arguments[ nargs ]; - nargs -= 1; - } else { - dtype = DEFAULT_DTYPE; - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '00L2k', dtype ) ); - } - // At this point, we've resolved the output array data type, and now we can actually create the output array... - if ( dtype === 'generic' ) { - arg = arguments[ 0 ]; - if ( nargs === 0 ) { - if ( isNonNegativeInteger( arg ) ) { - len = arg; - } else if ( isCollection( arg ) ) { - len = arg.length; - } - if ( len !== void 0 ) { - return filledArray( len, clbk, thisArg ); - } - if ( isArrayBuffer( arg ) ) { - throw new Error( format( '00L04' ) ); - } - if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( '00L2l', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00L2m', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00L2m', arg ) ); - } - return filledArrayIterator( arg, clbk, thisArg ); - } - throw new TypeError( format( '00L2m', arg ) ); - } else if ( isArrayBuffer( arg ) ) { - throw new Error( format( '00L04' ) ); - } - throw new TypeError( format( '00L2m', arg ) ); - } - if ( nargs === 0 ) { // length || array-like || ArrayBuffer || iterable - arg = arguments[ 0 ]; - if ( isCollection( arg ) ) { - arr = new ctor( arg.length ); - } else if ( isArrayBuffer( arg ) ) { - arr = new ctor( arg ); - } else if ( isNonNegativeInteger( arg ) ) { - arr = new ctor( arg ); - } else if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( '00L2l', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00L2m', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00L2m', arg ) ); - } - arr = new ctor( iterLength( arg ) ); - } else { - throw new TypeError( format( '00L2m', arg ) ); - } - } else if ( nargs === 1 ) { - arr = new ctor( arguments[0], arguments[1] ); // (ArrayBuffer, byteOffset) - } else { - arr = new ctor( arguments[0], arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset, length) - } - if ( arr.length > 0 ) { - if ( /^complex/.test( dtype ) ) { - filledAccessors( arr, clbk, thisArg ); - } else { - gfillBy( arr.length, arr, 1, callback ); - } - } - return arr; - - /** - * Callback which wraps a provided callback and is invoked for each array element. - * - * @private - * @param {*} value - element value - * @param {NonNegativeInteger} aidx - array index - * @param {NonNegativeInteger} sidx - strided index - * @param {Collection} array - input array/collection - * @returns {*} callback return value - */ - function callback( value, aidx ) { - return clbk.call( thisArg, aidx ); - } -} - - -// EXPORTS // - -module.exports = filledarrayBy; diff --git a/package.json b/package.json index 65f63fa..498622b 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.2", "description": "Create a filled array according to a provided callback function.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,69 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-filled-by": "^0.0.x", - "@stdlib/array-ctors": "^0.0.x", - "@stdlib/assert-has-iterator-symbol-support": "^0.0.x", - "@stdlib/assert-is-arraybuffer": "^0.0.x", - "@stdlib/assert-is-collection": "^0.0.x", - "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/assert-is-nonnegative-integer": "^0.0.x", - "@stdlib/assert-is-object": "^0.0.x", - "@stdlib/assert-is-string": "^0.0.x", - "@stdlib/blas-ext-base-gfill-by": "^0.0.x", - "@stdlib/iter-length": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x", - "@stdlib/symbol-iterator": "^0.0.x", - "@stdlib/types": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-buffer": "^0.0.x", - "@stdlib/array-complex128": "^0.0.x", - "@stdlib/array-complex64": "^0.0.x", - "@stdlib/array-float32": "^0.0.x", - "@stdlib/array-float64": "^0.0.x", - "@stdlib/array-int16": "^0.0.x", - "@stdlib/array-int32": "^0.0.x", - "@stdlib/array-int8": "^0.0.x", - "@stdlib/array-typed-real-dtypes": "^0.0.x", - "@stdlib/array-uint16": "^0.0.x", - "@stdlib/array-uint32": "^0.0.x", - "@stdlib/array-uint8": "^0.0.x", - "@stdlib/array-uint8c": "^0.0.x", - "@stdlib/assert-instance-of": "^0.0.x", - "@stdlib/assert-is-array": "^0.0.x", - "@stdlib/assert-is-typed-array": "^0.0.x", - "@stdlib/assert-is-typed-array-like": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/complex-float32": "^0.0.x", - "@stdlib/complex-float64": "^0.0.x", - "@stdlib/iter-constant": "^0.0.x", - "@stdlib/math-base-special-pow": "^0.0.x", - "@stdlib/random-base-discrete-uniform": "^0.0.x", - "@stdlib/strided-base-reinterpret-complex128": "^0.0.x", - "@stdlib/strided-base-reinterpret-complex64": "^0.0.x", - "@stdlib/utils-constant-function": "^0.0.x", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..17b0e73 --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index b55aa4a..0000000 --- a/test/test.js +++ /dev/null @@ -1,4248 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 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. -*/ - -/* eslint-disable max-len */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -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 ArrayBuffer = require( '@stdlib/array-buffer' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var iterConstant = require( '@stdlib/iter-constant' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var filledarrayBy = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': !hasIteratorSymbolSupport() -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof filledarrayBy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if only provided callback arguments', function test( t ) { - t.throws( clbk1, TypeError, 'throws an error' ); - t.throws( clbk2, TypeError, 'throws an error' ); - t.throws( clbk3, TypeError, 'throws an error' ); - t.end(); - - function clbk1() { - filledarrayBy( constantFunction( 1.0 ) ); - } - - function clbk2() { - filledarrayBy( constantFunction( 1.0 ), {} ); - } - - function clbk3() { - filledarrayBy( constantFunction( 1.0 ), constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (only argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (typed array; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (array-like object)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (array-like object; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 8 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 8 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, 1, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (iterator)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( iterConstant( 1.0 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (iterator; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( iterConstant( 1.0 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if only provided data type and callback arguments', function test( t ) { - t.throws( clbk1, TypeError, 'throws an error' ); - t.throws( clbk2, TypeError, 'throws an error' ); - t.throws( clbk3, TypeError, 'throws an error' ); - t.end(); - - function clbk1() { - filledarrayBy( 'float64', constantFunction( 1.0 ) ); - } - - function clbk2() { - filledarrayBy( 'float64', constantFunction( 1.0 ), {} ); - } - - function clbk3() { - filledarrayBy( 'float64', constantFunction( 1.0 ), constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (array-like object)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (array-like object; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, 1, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, 1, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (no iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (no iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (non-function iterator symbol property)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (non-function iterator symbol property; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (`next` property is not a function)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ) ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (`next` property is not a function; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ), {} ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (no iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (no iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (non-function iterator symbol property)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (non-function iterator symbol property; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (`next` property is not a function)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ) ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (`next` property is not a function; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ), {} ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 1, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 1, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function returns a filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - arr = filledarrayBy(); - - t.strictEqual( instanceOf( arr, Float64Array ), 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=float64)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - arr = filledarrayBy( 'float64' ); - - t.strictEqual( instanceOf( arr, Float64Array ), 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=float32)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( 0 ); - arr = filledarrayBy( 'float32' ); - - t.strictEqual( instanceOf( arr, Float32Array ), 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; - - expected = new Complex128Array( 0 ); - arr = filledarrayBy( 'complex128' ); - - t.strictEqual( instanceOf( arr, Complex128Array ), 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=complex64)', function test( t ) { - var expected; - var arr; - - expected = new Complex64Array( 0 ); - arr = filledarrayBy( 'complex64' ); - - t.strictEqual( instanceOf( arr, Complex64Array ), 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=int32)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( 0 ); - arr = filledarrayBy( 'int32' ); - - t.strictEqual( instanceOf( arr, Int32Array ), 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=uint32)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( 0 ); - arr = filledarrayBy( 'uint32' ); - - t.strictEqual( instanceOf( arr, Uint32Array ), 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=int16)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( 0 ); - arr = filledarrayBy( 'int16' ); - - t.strictEqual( instanceOf( arr, Int16Array ), 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=uint16)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( 0 ); - arr = filledarrayBy( 'uint16' ); - - t.strictEqual( instanceOf( arr, Uint16Array ), 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=int8)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( 0 ); - arr = filledarrayBy( 'int8' ); - - t.strictEqual( instanceOf( arr, Int8Array ), 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=uint8)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( 0 ); - arr = filledarrayBy( 'uint8' ); - - t.strictEqual( instanceOf( arr, Uint8Array ), 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=uint8c)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( 0 ); - arr = filledarrayBy( 'uint8c' ); - - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), 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=generic)', function test( t ) { - var expected; - var arr; - - expected = []; - arr = filledarrayBy( 'generic' ); - - t.strictEqual( instanceOf( arr, Array ), 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 (default, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, length=0)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array(); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 0, clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, clbk, ctx ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (default, length; thisArg=function)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, clbk, context ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this(); // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } - - function context() { - ctx.count += 1; - } -}); - -tape( 'the function returns a filled array (dtype=float64, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, 'float64', clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, length; thisArg=function)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, 'float64', clbk, context ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this(); // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } - - function context() { - ctx.count += 1; - } -}); - -tape( 'the function returns a filled array (dtype=float32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, 'float32', clbk ); - - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex128, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = filledarrayBy( 5, 'complex128', clbk ); - - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = filledarrayBy( 5, 'complex64', clbk ); - - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int32Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int32', clbk ); - - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint32Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint32', clbk ); - - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int16Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int16', clbk ); - - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint16', clbk ); - - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int8Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int8', clbk ); - - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint8', clbk ); - - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint8c', clbk ); - - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = [ 1, 1, 1, 1, 1 ]; - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'generic', clbk ); - - t.strictEqual( instanceOf( arr, Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex128, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = [ 1.0, 2.0 ]; - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = [ 1.0, 2.0 ]; - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int32', clbk ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, typed array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, typed array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex128, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = new Float64Array( [ 1.0, 2.0 ] ); - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = new Float64Array( [ 1.0, 2.0 ] ); - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (default, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex128, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer, byteoffset; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer, byteoffset; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, 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; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 48 ); - out = filledarrayBy( buf, 16, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 24 ); - out = filledarrayBy( buf, 8, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int32', clbk ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint8c', clbk ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, 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; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 64 ); - out = filledarrayBy( buf, 16, 2, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset, length)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 1, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 1, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled array (default, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, iterator; thisArg)', opts, function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - ctx = { - 'count': 0 - }; - indices = []; - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, iterator; thisArg)', opts, function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - ctx = { - 'count': 0 - }; - indices = []; - out = filledarrayBy( arr, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex128, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = iterConstant( new Complex128( 3.0, 3.0 ), { - 'iter': 2 - }); - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = iterConstant( new Complex64( 3.0, 3.0 ), { - 'iter': 2 - }); - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); From 142fcdd97e77335ce23d69148c7f3400e1ca41e3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jan 2024 08:46:42 +0000 Subject: [PATCH 032/117] Transform error messages --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b4aa9e8..d799e6b 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "@stdlib/assert-is-string": "^0.1.1", "@stdlib/blas-ext-base-gfill-by": "^0.1.0", "@stdlib/iter-length": "^0.1.1", - "@stdlib/string-format": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1", "@stdlib/symbol-iterator": "^0.1.1", "@stdlib/types": "^0.2.0" }, From ad5570d1508cc6df5a7d1d1e957d7dcc00212e99 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jan 2024 15:24:53 +0000 Subject: [PATCH 033/117] Remove files --- index.d.ts | 427 ---- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6609 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 2156674..0000000 --- a/index.d.ts +++ /dev/null @@ -1,427 +0,0 @@ -/* -* @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. -*/ - -// TypeScript Version: 2.0 - -/// - -import { RealOrComplexTypedArray, DataType } from '@stdlib/types/array'; -import { Collection } from '@stdlib/types/object'; -import { IterableIterator } from '@stdlib/types/iter'; - -/** -* Array or typed array. -*/ -type ArrayOrTypedArray = Array | RealOrComplexTypedArray; - -/** -* Nullary callback function. -* -* @returns fill value -*/ -type Nullary = () => any; - -/** -* Unary callback function. -* -* @param i - current array index -* @returns fill value -*/ -type Unary = ( i: number ) => any; - -/** -* Callback function. -* -* @param i - current array index -* @returns fill value -*/ -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 -* -* @example -* var arr = filledarrayBy(); -* // returns -* -* @example -* var arr = filledarrayBy( 'float32' ); -* // returns -*/ -declare function filledarrayBy( dtype?: DataType ): ArrayOrTypedArray; // tslint:disable-line:unified-signatures - -/** -* Creates a filled array according to a provided callback function and having a specified `length`. -* -* @param length - array length -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* -* var arr = filledarrayBy( 5, constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( length: number, clbk: Callback, thisArg?: any ): ArrayOrTypedArray; // tslint:disable-line:max-line-length unified-signatures - -/** -* 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 -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* -* var arr = filledarrayBy( 5, 'float64', constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( length: number, dtype: DataType, clbk: Callback, thisArg?: any ): ArrayOrTypedArray; // tslint:disable-line:max-line-length unified-signatures - -/** -* Creates a filled array from another `array` according to a provided callback function. -* -* @param array - typed array or array-like object -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* -* 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; // tslint:disable-line:max-line-length 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 -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* -* 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; // tslint:disable-line:max-line-length unified-signatures - -/** -* Creates a filled array from an iterable according to a callback function. -* -* @param iterable - iterable -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* var iterConstant = require( `@stdlib/iter/constant` ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarrayBy( it, constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( iterable: IterableIterator, callback: Callback, thisArg?: any ): ArrayOrTypedArray; // tslint:disable-line:max-line-length 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 -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* var iterConstant = require( `@stdlib/iter/constant` ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* 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; // tslint:disable-line:max-line-length unified-signatures - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; // tslint:disable-line:max-line-length - -/** -* 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. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; // tslint:disable-line:max-line-length unified-signatures - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; // tslint:disable-line:max-line-length - -/** -* 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. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; // tslint:disable-line:max-line-length unified-signatures - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; // tslint:disable-line:max-line-length 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. -* -* @param buffer - `ArrayBuffer` -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; // tslint:disable-line:max-line-length unified-signatures - - -// EXPORTS // - -export = filledarrayBy; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index a86535e..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-ctors@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill-by@v0.0.10-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled-by@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";var w=d();function j(r,e,t){var s,i;for(s=[],i=-1;!r.next().done;)i+=1,s.push(e.call(t,i));return s}function a(r,e,t){var s;for(s=0;s1)throw new TypeError(p("00L05"));if(null===(b=o(g)))throw new TypeError(p("00L2k",g));return new b(0)}if(c<2)throw new TypeError(p("00L05"));if(n(arguments[c-=1]))if(n(arguments[c-1])){if(d=arguments[c],y=arguments[c-=1],0===c)throw new TypeError(p("00L05"))}else y=arguments[c];else{if(!(c>=2))throw new TypeError(p("00L05"));if(d=arguments[c],!n(y=arguments[c-=1]))throw new TypeError(p("00L2n",y))}if((c-=1)>=0&&r(arguments[c])?(g=arguments[c],c-=1):g="float64",null===(b=o(g)))throw new TypeError(p("00L2k",g));if("generic"===g){if(x=arguments[0],0===c){if(e(x)?u=x:t(x)&&(u=x.length),void 0!==u)return m(u,y,d);if(s(x))throw new Error(p("00L04"));if(i(x)){if(!1===w)throw new TypeError(p("00L2l",x));if(!n(x[f]))throw new TypeError(p("00L2m",x));if(x=x[f](),!n(x.next))throw new TypeError(p("00L2m",x));return j(x,y,d)}throw new TypeError(p("00L2m",x))}if(s(x))throw new Error(p("00L04"));throw new TypeError(p("00L2m",x))}if(0===c)if(t(x=arguments[0]))v=new b(x.length);else if(s(x))v=new b(x);else if(e(x))v=new b(x);else{if(!i(x))throw new TypeError(p("00L2m",x));if(!1===w)throw new TypeError(p("00L2l",x));if(!n(x[f]))throw new TypeError(p("00L2m",x));if(x=x[f](),!n(x.next))throw new TypeError(p("00L2m",x));v=new b(h(x))}else v=1===c?new b(arguments[0],arguments[1]):new b(arguments[0],arguments[1],arguments[2]);return v.length>0&&(/^complex/.test(g)?a(v,y,d):l(v.length,v,1,E)),v;function E(r,e){return y.call(d,e)}}export{c as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index cf25e56..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.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\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport isCollection from '@stdlib/assert-is-collection';\nimport isArrayBuffer from '@stdlib/assert-is-arraybuffer';\nimport isObject from '@stdlib/assert-is-object';\nimport isFunction from '@stdlib/assert-is-function';\nimport ctors from '@stdlib/array-ctors';\nimport gfillBy from '@stdlib/blas-ext-base-gfill-by';\nimport filledArray from '@stdlib/array-base-filled-by';\nimport hasIteratorSymbolSupport from '@stdlib/assert-has-iterator-symbol-support';\nimport ITERATOR_SYMBOL from '@stdlib/symbol-iterator';\nimport iterLength from '@stdlib/iter-length';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport();\nvar DEFAULT_DTYPE = 'float64';\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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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( format( '00L05' ) );\n\t\t}\n\t\tctor = ctors( dtype );\n\t\tif ( ctor === null ) {\n\t\t\tthrow new TypeError( format( '00L2k', 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( format( '00L05' ) );\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( format( '00L05' ) );\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( '00L2n', 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( format( '00L05' ) );\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( '00L2k', 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( format( '00L04' ) );\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( '00L2l', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00L2m', 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( '00L2m', 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( '00L2m', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format( '00L04' ) );\n\t\t}\n\t\tthrow new TypeError( format( '00L2m', 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( '00L2l', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00L2m', 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( '00L2m', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00L2m', 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\nexport default filledarrayBy;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","filledArrayIterator","it","clbk","thisArg","arr","i","next","done","push","call","filledAccessors","length","set","filledarrayBy","nargs","dtype","ctor","len","arg","arguments","ctors","isString","TypeError","format","isFunction","isNonNegativeInteger","isCollection","filledArray","isArrayBuffer","Error","isObject","ITERATOR_SYMBOL","iterLength","test","gfillBy","callback","value","aidx"],"mappings":";;gqCAuCA,IAAIA,EAAsBC,IAe1B,SAASC,EAAqBC,EAAIC,EAAMC,GACvC,IAAIC,EACAC,EAKJ,IAFAD,EAAM,GACNC,GAAK,GAEAJ,EAAGK,OACAC,MAGPF,GAAK,EACLD,EAAII,KAAMN,EAAKO,KAAMN,EAASE,IAE/B,OAAOD,CACR,CAWA,SAASM,EAAiBN,EAAKF,EAAMC,GACpC,IAAIE,EACJ,IAAMA,EAAI,EAAGA,EAAID,EAAIO,OAAQN,IAC5BD,EAAIQ,IAAKV,EAAKO,KAAMN,EAASE,GAAKA,GAEnC,OAAOD,CACR,CA4JA,SAASS,IACR,IAAIV,EACAW,EACAC,EACAb,EACAc,EACAZ,EACAa,EACAC,EAKJ,GAAe,KAHfJ,EAAQK,UAAUR,QAKjB,OAAO,IADPK,EAAOI,EAzNW,YA0ND,GAIlB,GAAKC,EADLN,EAAQI,UAAW,IACM,CAExB,GAAKL,EAAQ,EACZ,MAAM,IAAIQ,UAAWC,EAAQ,UAG9B,GAAc,QADdP,EAAOI,EAAOL,IAEb,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAGvC,OAAO,IAAIC,EAAM,EACjB,CAED,GAAKF,EAAQ,EACZ,MAAM,IAAIQ,UAAWC,EAAQ,UAM9B,GAAKC,EAAYL,UAHjBL,GAAS,IAKR,GAAKU,EAAYL,UAAWL,EAAM,KAMjC,GALAX,EAAUgB,UAAWL,GAErBZ,EAAOiB,UADPL,GAAS,GAIM,IAAVA,EACJ,MAAM,IAAIQ,UAAWC,EAAQ,eAI9BrB,EAAOiB,UAAWL,OAIf,MAAKA,GAAS,GAUlB,MAAM,IAAIQ,UAAWC,EAAQ,UAN7B,GAHApB,EAAUgB,UAAWL,IAGfU,EADNtB,EAAOiB,UADPL,GAAS,IAGR,MAAM,IAAIQ,UAAWC,EAAQ,QAASrB,GAMvC,CAUD,IARAY,GAAS,IACK,GAAKO,EAAUF,UAAWL,KACvCC,EAAQI,UAAWL,GACnBA,GAAS,GAETC,EArRkB,UAwRL,QADdC,EAAOI,EAAOL,IAEb,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAGvC,GAAe,YAAVA,EAAsB,CAE1B,GADAG,EAAMC,UAAW,GACF,IAAVL,EAAc,CAMlB,GALKW,EAAsBP,GAC1BD,EAAMC,EACKQ,EAAcR,KACzBD,EAAMC,EAAIP,aAEE,IAARM,EACJ,OAAOU,EAAaV,EAAKf,EAAMC,GAEhC,GAAKyB,EAAeV,GACnB,MAAM,IAAIW,MAAON,EAAQ,UAE1B,GAAKO,EAAUZ,GAAQ,CACtB,IAA6B,IAAxBpB,EACJ,MAAM,IAAIwB,UAAWC,EAAQ,QAASL,IAEvC,IAAMM,EAAYN,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASL,IAGvC,GADAA,EAAMA,EAAKa,MACLP,EAAYN,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,QAASL,IAEvC,OAAOlB,EAAqBkB,EAAKhB,EAAMC,EACvC,CACD,MAAM,IAAImB,UAAWC,EAAQ,QAASL,GACzC,CAAS,GAAKU,EAAeV,GAC1B,MAAM,IAAIW,MAAON,EAAQ,UAE1B,MAAM,IAAID,UAAWC,EAAQ,QAASL,GACtC,CACD,GAAe,IAAVJ,EAEJ,GAAKY,EADLR,EAAMC,UAAW,IAEhBf,EAAM,IAAIY,EAAME,EAAIP,aACd,GAAKiB,EAAeV,GAC1Bd,EAAM,IAAIY,EAAME,QACV,GAAKO,EAAsBP,GACjCd,EAAM,IAAIY,EAAME,OACV,KAAKY,EAAUZ,GAarB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAZtC,IAA6B,IAAxBpB,EACJ,MAAM,IAAIwB,UAAWC,EAAQ,QAASL,IAEvC,IAAMM,EAAYN,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASL,IAGvC,GADAA,EAAMA,EAAKa,MACLP,EAAYN,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,QAASL,IAEvCd,EAAM,IAAIY,EAAMgB,EAAYd,GAG5B,MAEDd,EADqB,IAAVU,EACL,IAAIE,EAAMG,UAAU,GAAIA,UAAU,IAElC,IAAIH,EAAMG,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKf,EAAIO,OAAS,IACZ,WAAWsB,KAAMlB,GACrBL,EAAiBN,EAAKF,EAAMC,GAE5B+B,EAAS9B,EAAIO,OAAQP,EAAK,EAAG+B,IAGxB/B,EAYP,SAAS+B,EAAUC,EAAOC,GACzB,OAAOnC,EAAKO,KAAMN,EAASkC,EAC3B,CACF"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 17b0e73..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 35341ee9bbc3c6f069fd07c23617b26dc46ea145 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jan 2024 15:25:28 +0000 Subject: [PATCH 034/117] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 255 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 228 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.js | 319 -- benchmark/benchmark.length.complex128.js | 98 - benchmark/benchmark.length.complex64.js | 98 - benchmark/benchmark.length.float32.js | 97 - benchmark/benchmark.length.float64.js | 97 - benchmark/benchmark.length.generic.js | 97 - benchmark/benchmark.length.int16.js | 97 - benchmark/benchmark.length.int32.js | 97 - benchmark/benchmark.length.int8.js | 97 - benchmark/benchmark.length.uint16.js | 97 - benchmark/benchmark.length.uint32.js | 97 - benchmark/benchmark.length.uint8.js | 97 - benchmark/benchmark.length.uint8c.js | 97 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 174 - docs/types/test.ts | 606 -- examples/index.js | 37 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 192 - lib/main.js | 413 -- package.json | 90 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 4248 -------------- 55 files changed, 6204 insertions(+), 10540 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.length.complex128.js delete mode 100644 benchmark/benchmark.length.complex64.js delete mode 100644 benchmark/benchmark.length.float32.js delete mode 100644 benchmark/benchmark.length.float64.js delete mode 100644 benchmark/benchmark.length.generic.js delete mode 100644 benchmark/benchmark.length.int16.js delete mode 100644 benchmark/benchmark.length.int32.js delete mode 100644 benchmark/benchmark.length.int8.js delete mode 100644 benchmark/benchmark.length.uint16.js delete mode 100644 benchmark/benchmark.length.uint32.js delete mode 100644 benchmark/benchmark.length.uint8.js delete mode 100644 benchmark/benchmark.length.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 4118306..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-01-01T05:41:51.569Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 8be0b82..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 30656c4..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index 3acd3a9..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA corresponding to v0.11.0 - uses: styfle/cancel-workflow-action@b173b6ec0100793626c2d9e6b90435061f4fc3e5 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index f988046..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index c92f5c4..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index a80a1ae..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '42 6 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index e1e3539..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -291,7 +284,7 @@ for ( i = 0; i < dt.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -359,9 +352,9 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/filled]: https://github.com/stdlib-js/array-filled +[@stdlib/array/filled]: https://github.com/stdlib-js/array-filled/tree/esm -[@stdlib/array/typed]: https://github.com/stdlib-js/array-typed +[@stdlib/array/typed]: https://github.com/stdlib-js/array-typed/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 67ba493..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,319 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); -var isArray = require( '@stdlib/assert-is-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var pkg = require( './../package.json' ).name; -var filledarrayBy = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 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=float64', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'float64', 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=float32', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'float32', 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; - var i; - - clbk = constantFunction( new Complex128( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'complex128', 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=complex64', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( new Complex64( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'complex64', 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=int32', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int32', 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=uint32', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint32', 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=int16', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int16', 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=uint16', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint16', 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=int8', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int8', 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=uint8', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint8', 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=uint8c', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint8c', 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=generic', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'generic', clbk ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.length.complex128.js b/benchmark/benchmark.length.complex128.js deleted file mode 100644 index 27f6c66..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 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 Complex128 = require( '@stdlib/complex-float64' ); -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( new Complex128( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'complex128', 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=complex128,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.complex64.js b/benchmark/benchmark.length.complex64.js deleted file mode 100644 index c094ae9..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 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 Complex64 = require( '@stdlib/complex-float32' ); -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( new Complex64( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'complex64', 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=complex64,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.float32.js b/benchmark/benchmark.length.float32.js deleted file mode 100644 index d2b2ba7..0000000 --- a/benchmark/benchmark.length.float32.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'float32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=float32,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.float64.js b/benchmark/benchmark.length.float64.js deleted file mode 100644 index 65064e3..0000000 --- a/benchmark/benchmark.length.float64.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'float64', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=float64,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.generic.js b/benchmark/benchmark.length.generic.js deleted file mode 100644 index eb87dfa..0000000 --- a/benchmark/benchmark.length.generic.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isArray = require( '@stdlib/assert-is-array' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'generic', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isArray( 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=generic,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int16.js b/benchmark/benchmark.length.int16.js deleted file mode 100644 index 914ff7c..0000000 --- a/benchmark/benchmark.length.int16.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int16', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=int16,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int32.js b/benchmark/benchmark.length.int32.js deleted file mode 100644 index cc0f678..0000000 --- a/benchmark/benchmark.length.int32.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=int32,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int8.js b/benchmark/benchmark.length.int8.js deleted file mode 100644 index 77553b0..0000000 --- a/benchmark/benchmark.length.int8.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int8', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=int8,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint16.js b/benchmark/benchmark.length.uint16.js deleted file mode 100644 index c68efdd..0000000 --- a/benchmark/benchmark.length.uint16.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint16', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint16,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint32.js b/benchmark/benchmark.length.uint32.js deleted file mode 100644 index 27c1742..0000000 --- a/benchmark/benchmark.length.uint32.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint32,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint8.js b/benchmark/benchmark.length.uint8.js deleted file mode 100644 index 2a26be4..0000000 --- a/benchmark/benchmark.length.uint8.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint8', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint8,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint8c.js b/benchmark/benchmark.length.uint8c.js deleted file mode 100644 index dd6e8c2..0000000 --- a/benchmark/benchmark.length.uint8c.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint8c', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint8c,len='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 799f532..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by" -%% click B href "https://github.com/stdlib-js/array-filled-by/tree/main" -%% click C href "https://github.com/stdlib-js/array-filled-by/tree/production" -%% click D href "https://github.com/stdlib-js/array-filled-by/tree/esm" -%% click E href "https://github.com/stdlib-js/array-filled-by/tree/deno" -%% click F href "https://github.com/stdlib-js/array-filled-by/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by -[production-url]: https://github.com/stdlib-js/array-filled-by/tree/production -[deno-url]: https://github.com/stdlib-js/array-filled-by/tree/deno -[umd-url]: https://github.com/stdlib-js/array-filled-by/tree/umd -[esm-url]: https://github.com/stdlib-js/array-filled-by/tree/esm \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 188fc9b..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import filledarrayBy from '../docs/types/index'; -export = filledarrayBy; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 1d6bba5..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var k=function(i,e){return function(){return e||i((e={exports:{}}).exports,e),e.exports}};var b=k(function(C,h){ -var p=require('@stdlib/assert-is-string/dist').isPrimitive,d=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'),j=require('@stdlib/array-base-filled-by/dist'),q=require('@stdlib/assert-has-iterator-symbol-support/dist'),g=require('@stdlib/symbol-iterator/dist'),V=require('@stdlib/iter-length/dist'),o=require('@stdlib/error-tools-fmtprodmsg/dist'),w=q(),c="float64";function A(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 S(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&&p(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(d(r)?s=r:f(r)&&(s=r.length),s!==void 0)return j(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 A(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(d(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)?S(l,a,i):M(l.length,l,1,E)),l;function E(I,T){return a.call(i,T)}}h.exports=B -});var x=b();module.exports=x; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index deab323..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "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 format = require( '@stdlib/string-format' );\n\n\n// VARIABLES //\n\nvar HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport();\nvar DEFAULT_DTYPE = 'float64';\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,EAAS,QAAS,uBAAwB,EAK1CC,EAAsBJ,EAAyB,EAC/CK,EAAgB,UAcpB,SAASC,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,EAAQ,UAAU,OAGbA,IAAU,EACd,OAAAE,EAAOpB,EAAOQ,CAAc,EACrB,IAAIY,EAAM,CAAE,EAIpB,GADAD,EAAQ,UAAW,CAAE,EAChBzB,EAAUyB,CAAM,EAAI,CAExB,GAAKD,EAAQ,EACZ,MAAM,IAAI,UAAW,2FAA4F,EAGlH,GADAE,EAAOpB,EAAOmB,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWd,EAAQ,sEAAuEa,CAAM,CAAE,EAG7G,OAAO,IAAIC,EAAM,CAAE,CACpB,CAEA,GAAKF,EAAQ,EACZ,MAAM,IAAI,UAAW,2FAA4F,EAMlH,GAHAA,GAAS,EAGJnB,EAAY,UAAWmB,CAAM,CAAE,EAEnC,GAAKnB,EAAY,UAAWmB,EAAM,CAAE,CAAE,GAMrC,GALAN,EAAU,UAAWM,CAAM,EAC3BA,GAAS,EACTP,EAAO,UAAWO,CAAM,EAGnBA,IAAU,EACd,MAAM,IAAI,UAAW,2FAA4F,OAIlHP,EAAO,UAAWO,CAAM,UAIhBA,GAAS,GAIlB,GAHAN,EAAU,UAAWM,CAAM,EAC3BA,GAAS,EACTP,EAAO,UAAWO,CAAM,EACnB,CAACnB,EAAYY,CAAK,EACtB,MAAM,IAAI,UAAWL,EAAQ,uEAAwEK,CAAK,CAAE,MAK7G,OAAM,IAAI,UAAW,2FAA4F,EAWlH,GARAO,GAAS,EACJA,GAAS,GAAKxB,EAAU,UAAWwB,CAAM,CAAE,GAC/CC,EAAQ,UAAWD,CAAM,EACzBA,GAAS,GAETC,EAAQX,EAETY,EAAOpB,EAAOmB,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWd,EAAQ,sEAAuEa,CAAM,CAAE,EAG7G,GAAKA,IAAU,UAAY,CAE1B,GADAG,EAAM,UAAW,CAAE,EACdJ,IAAU,EAAI,CAMlB,GALKvB,EAAsB2B,CAAI,EAC9BD,EAAMC,EACK1B,EAAc0B,CAAI,IAC7BD,EAAMC,EAAI,QAEND,IAAQ,OACZ,OAAOnB,EAAamB,EAAKV,EAAMC,CAAQ,EAExC,GAAKf,EAAeyB,CAAI,EACvB,MAAM,IAAI,MAAO,mFAAoF,EAEtG,GAAKxB,EAAUwB,CAAI,EAAI,CACtB,GAAKf,IAAwB,GAC5B,MAAM,IAAI,UAAWD,EAAQ,sIAAuIgB,CAAI,CAAE,EAE3K,GAAK,CAACvB,EAAYuB,EAAKlB,CAAgB,CAAE,EACxC,MAAM,IAAI,UAAWE,EAAQ,wGAAyGgB,CAAI,CAAE,EAG7I,GADAA,EAAMA,EAAKlB,CAAgB,EAAE,EACxB,CAACL,EAAYuB,EAAI,IAAK,EAC1B,MAAM,IAAI,UAAWhB,EAAQ,wGAAyGgB,CAAI,CAAE,EAE7I,OAAOb,EAAqBa,EAAKX,EAAMC,CAAQ,CAChD,CACA,MAAM,IAAI,UAAWN,EAAQ,wGAAyGgB,CAAI,CAAE,CAC7I,SAAYzB,EAAeyB,CAAI,EAC9B,MAAM,IAAI,MAAO,mFAAoF,EAEtG,MAAM,IAAI,UAAWhB,EAAQ,wGAAyGgB,CAAI,CAAE,CAC7I,CACA,GAAKJ,IAAU,EAEd,GADAI,EAAM,UAAW,CAAE,EACd1B,EAAc0B,CAAI,EACtBT,EAAM,IAAIO,EAAME,EAAI,MAAO,UAChBzB,EAAeyB,CAAI,EAC9BT,EAAM,IAAIO,EAAME,CAAI,UACT3B,EAAsB2B,CAAI,EACrCT,EAAM,IAAIO,EAAME,CAAI,UACTxB,EAAUwB,CAAI,EAAI,CAC7B,GAAKf,IAAwB,GAC5B,MAAM,IAAI,UAAWD,EAAQ,sIAAuIgB,CAAI,CAAE,EAE3K,GAAK,CAACvB,EAAYuB,EAAKlB,CAAgB,CAAE,EACxC,MAAM,IAAI,UAAWE,EAAQ,wGAAyGgB,CAAI,CAAE,EAG7I,GADAA,EAAMA,EAAKlB,CAAgB,EAAE,EACxB,CAACL,EAAYuB,EAAI,IAAK,EAC1B,MAAM,IAAI,UAAWhB,EAAQ,wGAAyGgB,CAAI,CAAE,EAE7IT,EAAM,IAAIO,EAAMf,EAAYiB,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,EAEpCX,EAASY,EAAI,OAAQA,EAAK,EAAGU,CAAS,GAGjCV,EAYP,SAASU,EAAUC,EAAOC,EAAO,CAChC,OAAOd,EAAK,KAAMC,EAASa,CAAK,CACjC,CACD,CAKAhC,EAAO,QAAUwB,IClOjB,IAAIS,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isString", "isNonNegativeInteger", "isCollection", "isArrayBuffer", "isObject", "isFunction", "ctors", "gfillBy", "filledArray", "hasIteratorSymbolSupport", "ITERATOR_SYMBOL", "iterLength", "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 deleted file mode 100644 index 5a68984..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,174 +0,0 @@ - -{{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) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr = {{alias}}() - - > arr = {{alias}}( 'float32' ) - - - -{{alias}}( length[, dtype], clbk[, thisArg] ) - Returns a filled array according to a provided callback function and having - a specified length. - - Parameters - ---------- - length: integer - Array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > function clbk() { return 1.0; }; - > var arr = {{alias}}( 5, clbk ) - [ 1.0, 1.0, 1.0, 1.0, 1.0 ] - > arr = {{alias}}( 5, 'int32', clbk ) - [ 1, 1, 1, 1, 1 ] - - -{{alias}}( array[, dtype], clbk[, thisArg] ) - Creates a filled array from another array (or array-like object) according - to a provided callback function. - - Parameters - ---------- - array: ArrayLikeObject - Array from which to generate another array. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias}}( [ 0.5, 0.5, 0.5 ], {{alias:@stdlib/utils/constant-function}}( 2.0 ) ) - [ 2.0, 2.0, 2.0 ] - > var arr2 = {{alias}}( arr1, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( iterable[, dtype], clbk[, thisArg] ) - Creates a filled array from an iterable according to a provided callback - function. - - Parameters - ---------- - iterable: Iterable - Iterable from which to generate an array. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias:@stdlib/iter/constant}}( 3.0, {'iter': 3} ); - > var arr2 = {{alias}}( arr1, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( buffer[, byteOffset[, length]][, dtype], clbk[, thisArg] ) - Returns a filled typed array view of an ArrayBuffer according to a provided - callback function. - - The 'generic' array data type is *not* supported. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( buf, 0, 4, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0, 1.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 394ac49..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,606 +0,0 @@ -/* -* @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. -*/ - -/// - -import { IterableIterator } from '@stdlib/types/iter'; -import filledarrayBy = require( './index' ); - - -/** -* Returns an iterator protocol-compliant object. -* -* @returns iterator protocol-compliant object -*/ -function iterator(): IterableIterator { - const obj: IterableIterator = { - [Symbol.iterator]: iterator, - 'next': next - }; - return obj; -} - -/** -* Implements the iterator protocol `next` method. -* -* @returns iterator protocol-compliant object -*/ -function next(): any { - return { - 'value': 1.0, - 'done': false - }; -} - -/** -* Callback function. -* -* @param i - current array index -* @returns return value -*/ -function clbk( i: number ): number { - return i; -} - - -// TESTS // - -// The function returns an array or typed array... -{ - filledarrayBy(); // $ExpectType ArrayOrTypedArray - filledarrayBy( 'float32' ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( 10, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( 10, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( 10, 'int32', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( 10, 'int32', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const x = new Float64Array( 10 ); - filledarrayBy( x, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( x, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( x, 'uint8', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( x, 'uint8', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const y = [ 2.0, 2.0, 2.0 ]; - filledarrayBy( y, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( y, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( y, 'float64', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( y, 'float64', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const it = iterator(); - filledarrayBy( it, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( it, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( it, 'uint8c', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( it, 'uint8c', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const buf = new ArrayBuffer( 32 ); - filledarrayBy( buf, clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 'uint32', clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 'uint32', clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 8, clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 8, clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 8, 'uint16', clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 8, 'uint16', clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 8, 2, clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 8, 2, clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 8, 2, 'int16', clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 8, 2, 'int16', clbk, {} ); // $ExpectType RealOrComplexTypedArray -} - -// The compiler throws an error if a callback function argument is not a function... -{ - filledarrayBy( 'float64', '5' ); // $ExpectError - filledarrayBy( 'float64', 1.0 ); // $ExpectError - filledarrayBy( 'float64', false ); // $ExpectError - filledarrayBy( 'float64', true ); // $ExpectError - filledarrayBy( 'float64', null ); // $ExpectError - filledarrayBy( 'float64', undefined ); // $ExpectError - filledarrayBy( 'float64', [] ); // $ExpectError - filledarrayBy( 'float64', {} ); // $ExpectError - - filledarrayBy( 'float64', '5', {} ); // $ExpectError - filledarrayBy( 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( 'float64', false, {} ); // $ExpectError - filledarrayBy( 'float64', true, {} ); // $ExpectError - filledarrayBy( 'float64', null, {} ); // $ExpectError - filledarrayBy( 'float64', undefined, {} ); // $ExpectError - filledarrayBy( 'float64', [], {} ); // $ExpectError - filledarrayBy( 'float64', {}, {} ); // $ExpectError - - filledarrayBy( 10, '5' ); // $ExpectError - filledarrayBy( 10, 1.0 ); // $ExpectError - filledarrayBy( 10, false ); // $ExpectError - filledarrayBy( 10, true ); // $ExpectError - filledarrayBy( 10, null ); // $ExpectError - filledarrayBy( 10, undefined ); // $ExpectError - filledarrayBy( 10, [] ); // $ExpectError - filledarrayBy( 10, {} ); // $ExpectError - - filledarrayBy( 10, '5', {} ); // $ExpectError - filledarrayBy( 10, 1.0, {} ); // $ExpectError - filledarrayBy( 10, false, {} ); // $ExpectError - filledarrayBy( 10, true, {} ); // $ExpectError - filledarrayBy( 10, null, {} ); // $ExpectError - filledarrayBy( 10, undefined, {} ); // $ExpectError - filledarrayBy( 10, [], {} ); // $ExpectError - filledarrayBy( 10, {}, {} ); // $ExpectError - - filledarrayBy( 10, 'float64', '5' ); // $ExpectError - filledarrayBy( 10, 'float64', 1.0 ); // $ExpectError - filledarrayBy( 10, 'float64', false ); // $ExpectError - filledarrayBy( 10, 'float64', true ); // $ExpectError - filledarrayBy( 10, 'float64', null ); // $ExpectError - filledarrayBy( 10, 'float64', undefined ); // $ExpectError - filledarrayBy( 10, 'float64', [] ); // $ExpectError - filledarrayBy( 10, 'float64', {} ); // $ExpectError - - filledarrayBy( 10, 'float64', '5', {} ); // $ExpectError - filledarrayBy( 10, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( 10, 'float64', false, {} ); // $ExpectError - filledarrayBy( 10, 'float64', true, {} ); // $ExpectError - filledarrayBy( 10, 'float64', null, {} ); // $ExpectError - filledarrayBy( 10, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( 10, 'float64', [], {} ); // $ExpectError - filledarrayBy( 10, 'float64', {}, {} ); // $ExpectError - - const x = new Float64Array( 10 ); - filledarrayBy( x, '5' ); // $ExpectError - filledarrayBy( x, 1.0 ); // $ExpectError - filledarrayBy( x, false ); // $ExpectError - filledarrayBy( x, true ); // $ExpectError - filledarrayBy( x, null ); // $ExpectError - filledarrayBy( x, undefined ); // $ExpectError - filledarrayBy( x, [] ); // $ExpectError - filledarrayBy( x, {} ); // $ExpectError - - filledarrayBy( x, '5', {} ); // $ExpectError - filledarrayBy( x, 1.0, {} ); // $ExpectError - filledarrayBy( x, false, {} ); // $ExpectError - filledarrayBy( x, true, {} ); // $ExpectError - filledarrayBy( x, null, {} ); // $ExpectError - filledarrayBy( x, undefined, {} ); // $ExpectError - filledarrayBy( x, [], {} ); // $ExpectError - filledarrayBy( x, {}, {} ); // $ExpectError - - filledarrayBy( x, 'float64', '5' ); // $ExpectError - filledarrayBy( x, 'float64', 1.0 ); // $ExpectError - filledarrayBy( x, 'float64', false ); // $ExpectError - filledarrayBy( x, 'float64', true ); // $ExpectError - filledarrayBy( x, 'float64', null ); // $ExpectError - filledarrayBy( x, 'float64', undefined ); // $ExpectError - filledarrayBy( x, 'float64', [] ); // $ExpectError - filledarrayBy( x, 'float64', {} ); // $ExpectError - - filledarrayBy( x, 'float64', '5', {} ); // $ExpectError - filledarrayBy( x, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( x, 'float64', false, {} ); // $ExpectError - filledarrayBy( x, 'float64', true, {} ); // $ExpectError - filledarrayBy( x, 'float64', null, {} ); // $ExpectError - filledarrayBy( x, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( x, 'float64', [], {} ); // $ExpectError - filledarrayBy( x, 'float64', {}, {} ); // $ExpectError - - const y = [ 2.0, 2.0, 2.0 ]; - filledarrayBy( y, '5' ); // $ExpectError - filledarrayBy( y, 1.0 ); // $ExpectError - filledarrayBy( y, false ); // $ExpectError - filledarrayBy( y, true ); // $ExpectError - filledarrayBy( y, null ); // $ExpectError - filledarrayBy( y, undefined ); // $ExpectError - filledarrayBy( y, [] ); // $ExpectError - filledarrayBy( y, {} ); // $ExpectError - - filledarrayBy( y, '5', {} ); // $ExpectError - filledarrayBy( y, 1.0, {} ); // $ExpectError - filledarrayBy( y, false, {} ); // $ExpectError - filledarrayBy( y, true, {} ); // $ExpectError - filledarrayBy( y, null, {} ); // $ExpectError - filledarrayBy( y, undefined, {} ); // $ExpectError - filledarrayBy( y, [], {} ); // $ExpectError - filledarrayBy( y, {}, {} ); // $ExpectError - - filledarrayBy( y, 'float64', '5' ); // $ExpectError - filledarrayBy( y, 'float64', 1.0 ); // $ExpectError - filledarrayBy( y, 'float64', false ); // $ExpectError - filledarrayBy( y, 'float64', true ); // $ExpectError - filledarrayBy( y, 'float64', null ); // $ExpectError - filledarrayBy( y, 'float64', undefined ); // $ExpectError - filledarrayBy( y, 'float64', [] ); // $ExpectError - filledarrayBy( y, 'float64', {} ); // $ExpectError - - filledarrayBy( y, 'float64', '5', {} ); // $ExpectError - filledarrayBy( y, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( y, 'float64', false, {} ); // $ExpectError - filledarrayBy( y, 'float64', true, {} ); // $ExpectError - filledarrayBy( y, 'float64', null, {} ); // $ExpectError - filledarrayBy( y, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( y, 'float64', [], {} ); // $ExpectError - filledarrayBy( y, 'float64', {}, {} ); // $ExpectError - - const it = iterator(); - filledarrayBy( it, '5' ); // $ExpectError - filledarrayBy( it, 1.0 ); // $ExpectError - filledarrayBy( it, false ); // $ExpectError - filledarrayBy( it, true ); // $ExpectError - filledarrayBy( it, null ); // $ExpectError - filledarrayBy( it, undefined ); // $ExpectError - filledarrayBy( it, [] ); // $ExpectError - filledarrayBy( it, {} ); // $ExpectError - - filledarrayBy( it, '5', {} ); // $ExpectError - filledarrayBy( it, 1.0, {} ); // $ExpectError - filledarrayBy( it, false, {} ); // $ExpectError - filledarrayBy( it, true, {} ); // $ExpectError - filledarrayBy( it, null, {} ); // $ExpectError - filledarrayBy( it, undefined, {} ); // $ExpectError - filledarrayBy( it, [], {} ); // $ExpectError - filledarrayBy( it, {}, {} ); // $ExpectError - - filledarrayBy( it, 'float64', '5' ); // $ExpectError - filledarrayBy( it, 'float64', 1.0 ); // $ExpectError - filledarrayBy( it, 'float64', false ); // $ExpectError - filledarrayBy( it, 'float64', true ); // $ExpectError - filledarrayBy( it, 'float64', null ); // $ExpectError - filledarrayBy( it, 'float64', undefined ); // $ExpectError - filledarrayBy( it, 'float64', [] ); // $ExpectError - filledarrayBy( it, 'float64', {} ); // $ExpectError - - filledarrayBy( it, 'float64', '5', {} ); // $ExpectError - filledarrayBy( it, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( it, 'float64', false, {} ); // $ExpectError - filledarrayBy( it, 'float64', true, {} ); // $ExpectError - filledarrayBy( it, 'float64', null, {} ); // $ExpectError - filledarrayBy( it, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( it, 'float64', [], {} ); // $ExpectError - filledarrayBy( it, 'float64', {}, {} ); // $ExpectError - - const buf = new ArrayBuffer( 32 ); - filledarrayBy( buf, '5' ); // $ExpectError - filledarrayBy( buf, 1.0 ); // $ExpectError - filledarrayBy( buf, false ); // $ExpectError - filledarrayBy( buf, true ); // $ExpectError - filledarrayBy( buf, null ); // $ExpectError - filledarrayBy( buf, undefined ); // $ExpectError - filledarrayBy( buf, [] ); // $ExpectError - filledarrayBy( buf, {} ); // $ExpectError - - filledarrayBy( buf, '5', {} ); // $ExpectError - filledarrayBy( buf, 1.0, {} ); // $ExpectError - filledarrayBy( buf, false, {} ); // $ExpectError - filledarrayBy( buf, true, {} ); // $ExpectError - filledarrayBy( buf, null, {} ); // $ExpectError - filledarrayBy( buf, undefined, {} ); // $ExpectError - filledarrayBy( buf, [], {} ); // $ExpectError - filledarrayBy( buf, {}, {} ); // $ExpectError - - filledarrayBy( buf, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 'float64', false ); // $ExpectError - filledarrayBy( buf, 'float64', true ); // $ExpectError - filledarrayBy( buf, 'float64', null ); // $ExpectError - filledarrayBy( buf, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 'float64', {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5' ); // $ExpectError - filledarrayBy( buf, 8, 1.0 ); // $ExpectError - filledarrayBy( buf, 8, false ); // $ExpectError - filledarrayBy( buf, 8, true ); // $ExpectError - filledarrayBy( buf, 8, null ); // $ExpectError - filledarrayBy( buf, 8, undefined ); // $ExpectError - filledarrayBy( buf, 8, [] ); // $ExpectError - filledarrayBy( buf, 8, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, false, {} ); // $ExpectError - filledarrayBy( buf, 8, true, {} ); // $ExpectError - filledarrayBy( buf, 8, null, {} ); // $ExpectError - filledarrayBy( buf, 8, undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, [], {} ); // $ExpectError - filledarrayBy( buf, 8, {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 8, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 'float64', false ); // $ExpectError - filledarrayBy( buf, 8, 'float64', true ); // $ExpectError - filledarrayBy( buf, 8, 'float64', null ); // $ExpectError - filledarrayBy( buf, 8, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 8, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 8, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 8, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, '5' ); // $ExpectError - filledarrayBy( buf, 8, 2, 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 2, false ); // $ExpectError - filledarrayBy( buf, 8, 2, true ); // $ExpectError - filledarrayBy( buf, 8, 2, null ); // $ExpectError - filledarrayBy( buf, 8, 2, undefined ); // $ExpectError - filledarrayBy( buf, 8, 2, [] ); // $ExpectError - filledarrayBy( buf, 8, 2, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, false, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, true, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, null, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, [], {} ); // $ExpectError - filledarrayBy( buf, 8, 2, {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', false ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', true ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', null ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', {}, {} ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid length, typed array, array-like object, `ArrayBuffer`, or iterable argument... -{ - filledarrayBy( false, clbk ); // $ExpectError - filledarrayBy( true, clbk ); // $ExpectError - filledarrayBy( null, clbk ); // $ExpectError - filledarrayBy( {}, clbk ); // $ExpectError - - filledarrayBy( false, clbk, {} ); // $ExpectError - filledarrayBy( true, clbk, {} ); // $ExpectError - filledarrayBy( null, clbk, {} ); // $ExpectError - filledarrayBy( {}, clbk, {} ); // $ExpectError - - filledarrayBy( false, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 'float64', clbk ); // $ExpectError - - filledarrayBy( false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, clbk ); // $ExpectError - filledarrayBy( 1.0, 8, clbk ); // $ExpectError - filledarrayBy( false, 8, clbk ); // $ExpectError - filledarrayBy( true, 8, clbk ); // $ExpectError - filledarrayBy( null, 8, clbk ); // $ExpectError - filledarrayBy( undefined, 8, clbk ); // $ExpectError - filledarrayBy( [], 8, clbk ); // $ExpectError - filledarrayBy( {}, 8, clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, clbk ); // $ExpectError - - filledarrayBy( '5', 8, clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, clbk, {} ); // $ExpectError - filledarrayBy( false, 8, clbk, {} ); // $ExpectError - filledarrayBy( true, 8, clbk, {} ); // $ExpectError - filledarrayBy( null, 8, clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, clbk, {} ); // $ExpectError - filledarrayBy( [], 8, clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 'float64', clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( false, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( [], 8, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 'float64', clbk ); // $ExpectError - - filledarrayBy( '5', 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 2, clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 2, clbk ); // $ExpectError - filledarrayBy( false, 8, 2, clbk ); // $ExpectError - filledarrayBy( true, 8, 2, clbk ); // $ExpectError - filledarrayBy( null, 8, 2, clbk ); // $ExpectError - filledarrayBy( undefined, 8, 2, clbk ); // $ExpectError - filledarrayBy( [], 8, 2, clbk ); // $ExpectError - filledarrayBy( {}, 8, 2, clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, clbk ); // $ExpectError - - filledarrayBy( '5', 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( false, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( [], 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, 'float64', clbk ); // $ExpectError - - filledarrayBy( '5', 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a byte offset argument which is not a number... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, false, clbk ); // $ExpectError - filledarrayBy( buf, true, clbk ); // $ExpectError - filledarrayBy( buf, null, clbk ); // $ExpectError - filledarrayBy( buf, [], clbk ); // $ExpectError - filledarrayBy( buf, {}, clbk ); // $ExpectError - - filledarrayBy( buf, false, clbk, {} ); // $ExpectError - filledarrayBy( buf, true, clbk, {} ); // $ExpectError - filledarrayBy( buf, null, clbk, {} ); // $ExpectError - filledarrayBy( buf, [], clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, clbk, {} ); // $ExpectError - - filledarrayBy( buf, '5', 'float64', clbk ); // $ExpectError - filledarrayBy( buf, false, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, true, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, null, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, [], 'float64', clbk ); // $ExpectError - filledarrayBy( buf, {}, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, '5', 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( buf, false, 2, clbk ); // $ExpectError - filledarrayBy( buf, true, 2, clbk ); // $ExpectError - filledarrayBy( buf, null, 2, clbk ); // $ExpectError - filledarrayBy( buf, [], 2, clbk ); // $ExpectError - filledarrayBy( buf, {}, 2, clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, clbk ); // $ExpectError - - filledarrayBy( buf, false, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, clbk, {} ); // $ExpectError - - filledarrayBy( buf, '5', 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, false, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, true, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, null, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, undefined, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, [], 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, {}, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, '5', 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, false, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, undefined, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a view length argument which is not a number... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, 8, false, clbk ); // $ExpectError - filledarrayBy( buf, 8, true, clbk ); // $ExpectError - filledarrayBy( buf, 8, null, clbk ); // $ExpectError - filledarrayBy( buf, 8, [], clbk ); // $ExpectError - filledarrayBy( buf, 8, {}, clbk ); // $ExpectError - - filledarrayBy( buf, 8, false, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, true, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, null, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, [], clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, {}, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, clbk, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5', 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, false, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, true, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, null, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, [], 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, {}, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, 8, '5', 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, [], 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, {}, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided too many arguments... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, 8, 2, 'float64', 1, clbk, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 997a381..0000000 --- a/examples/index.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ).factory; -var dtypes = require( '@stdlib/array-typed-real-dtypes' ); -var filledarrayBy = require( './../lib' ); - -// Create a pseudorandom number generator: -var rand = discreteUniform( 0, 100 ); - -// Get a list of array data types: -var dt = dtypes(); - -// Generate filled arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = filledarrayBy( 10, dt[ i ], rand ); - console.log( arr ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 71b11cc..2cd8555 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, RealOrComplexTypedArray, DataType } from '@stdlib/types/array'; import { IterableIterator } from '@stdlib/types/iter'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..d809fe1 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.1.1-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.1.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.1.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.1.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.1.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-ctors@v0.1.0-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill-by@v0.1.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled-by@v0.1.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.1.1-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.1.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@v0.1.1-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";var y=d();function v(r,e,t){var i,a;for(i=[],a=-1;!r.next().done;)a+=1,i.push(e.call(t,a));return i}function h(r,e,t){var i;for(i=0;i1)throw new TypeError("invalid arguments. Must provide a length, typed array, array-like object, or an iterable.");if(null===(b=s(f)))throw new TypeError(u("invalid argument. Must provide a recognized data type. Value: `%s`.",f));return new b(0)}if(g<2)throw new TypeError("invalid arguments. Must provide a length, typed array, array-like object, or an iterable.");if(n(arguments[g-=1]))if(n(arguments[g-1])){if(d=arguments[g],j=arguments[g-=1],0===g)throw new TypeError("invalid arguments. Must provide a length, typed array, array-like object, or an iterable.")}else j=arguments[g];else{if(!(g>=2))throw new TypeError("invalid arguments. Must provide a length, typed array, array-like object, or an iterable.");if(d=arguments[g],!n(j=arguments[g-=1]))throw new TypeError(u("invalid argument. Callback argument must be a function. Value: `%s`.",j))}if((g-=1)>=0&&r(arguments[g])?(f=arguments[g],g-=1):f="float64",null===(b=s(f)))throw new TypeError(u("invalid argument. Must provide a recognized data type. Value: `%s`.",f));if("generic"===f){if(E=arguments[0],0===g){if(e(E)?w=E:t(E)&&(w=E.length),void 0!==w)return l(w,j,d);if(i(E))throw new Error("invalid arguments. Creating a generic array from an ArrayBuffer is not supported.");if(a(E)){if(!1===y)throw new TypeError(u("invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.",E));if(!n(E[p]))throw new TypeError(u("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",E));if(E=E[p](),!n(E.next))throw new TypeError(u("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",E));return v(E,j,d)}throw new TypeError(u("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",E))}if(i(E))throw new Error("invalid arguments. Creating a generic array from an ArrayBuffer is not supported.");throw new TypeError(u("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",E))}if(0===g)if(t(E=arguments[0]))c=new b(E.length);else if(i(E))c=new b(E);else if(e(E))c=new b(E);else{if(!a(E))throw new TypeError(u("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",E));if(!1===y)throw new TypeError(u("invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.",E));if(!n(E[p]))throw new TypeError(u("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",E));if(E=E[p](),!n(E.next))throw new TypeError(u("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",E));c=new b(m(E))}else c=1===g?new b(arguments[0],arguments[1]):new b(arguments[0],arguments[1],arguments[2]);return c.length>0&&(/^complex/.test(f)?h(c,j,d):o(c.length,c,1,x)),c;function x(r,e){return j.call(d,e)}}export{g as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..045cd6e --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.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\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport isCollection from '@stdlib/assert-is-collection';\nimport isArrayBuffer from '@stdlib/assert-is-arraybuffer';\nimport isObject from '@stdlib/assert-is-object';\nimport isFunction from '@stdlib/assert-is-function';\nimport ctors from '@stdlib/array-ctors';\nimport gfillBy from '@stdlib/blas-ext-base-gfill-by';\nimport filledArray from '@stdlib/array-base-filled-by';\nimport hasIteratorSymbolSupport from '@stdlib/assert-has-iterator-symbol-support';\nimport ITERATOR_SYMBOL from '@stdlib/symbol-iterator';\nimport iterLength from '@stdlib/iter-length';\nimport format from '@stdlib/string-format';\n\n\n// VARIABLES //\n\nvar HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport();\nvar DEFAULT_DTYPE = 'float64';\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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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\nexport default filledarrayBy;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","filledArrayIterator","it","clbk","thisArg","arr","i","next","done","push","call","filledAccessors","length","set","filledarrayBy","nargs","dtype","ctor","len","arg","arguments","ctors","isString","TypeError","format","isFunction","isNonNegativeInteger","isCollection","filledArray","isArrayBuffer","Error","isObject","ITERATOR_SYMBOL","iterLength","test","gfillBy","callback","value","aidx"],"mappings":";;muCAuCA,IAAIA,EAAsBC,IAe1B,SAASC,EAAqBC,EAAIC,EAAMC,GACvC,IAAIC,EACAC,EAKJ,IAFAD,EAAM,GACNC,GAAK,GAEAJ,EAAGK,OACAC,MAGPF,GAAK,EACLD,EAAII,KAAMN,EAAKO,KAAMN,EAASE,IAE/B,OAAOD,CACR,CAWA,SAASM,EAAiBN,EAAKF,EAAMC,GACpC,IAAIE,EACJ,IAAMA,EAAI,EAAGA,EAAID,EAAIO,OAAQN,IAC5BD,EAAIQ,IAAKV,EAAKO,KAAMN,EAASE,GAAKA,GAEnC,OAAOD,CACR,CA4JA,SAASS,IACR,IAAIV,EACAW,EACAC,EACAb,EACAc,EACAZ,EACAa,EACAC,EAKJ,GAAe,KAHfJ,EAAQK,UAAUR,QAKjB,OAAO,IADPK,EAAOI,EAzNW,YA0ND,GAIlB,GAAKC,EADLN,EAAQI,UAAW,IACM,CAExB,GAAKL,EAAQ,EACZ,MAAM,IAAIQ,UAAW,6FAGtB,GAAc,QADdN,EAAOI,EAAOL,IAEb,MAAM,IAAIO,UAAWC,EAAQ,sEAAuER,IAGrG,OAAO,IAAIC,EAAM,EACjB,CAED,GAAKF,EAAQ,EACZ,MAAM,IAAIQ,UAAW,6FAMtB,GAAKE,EAAYL,UAHjBL,GAAS,IAKR,GAAKU,EAAYL,UAAWL,EAAM,KAMjC,GALAX,EAAUgB,UAAWL,GAErBZ,EAAOiB,UADPL,GAAS,GAIM,IAAVA,EACJ,MAAM,IAAIQ,UAAW,kGAItBpB,EAAOiB,UAAWL,OAIf,MAAKA,GAAS,GAUlB,MAAM,IAAIQ,UAAW,6FANrB,GAHAnB,EAAUgB,UAAWL,IAGfU,EADNtB,EAAOiB,UADPL,GAAS,IAGR,MAAM,IAAIQ,UAAWC,EAAQ,uEAAwErB,GAMtG,CAUD,IARAY,GAAS,IACK,GAAKO,EAAUF,UAAWL,KACvCC,EAAQI,UAAWL,GACnBA,GAAS,GAETC,EArRkB,UAwRL,QADdC,EAAOI,EAAOL,IAEb,MAAM,IAAIO,UAAWC,EAAQ,sEAAuER,IAGrG,GAAe,YAAVA,EAAsB,CAE1B,GADAG,EAAMC,UAAW,GACF,IAAVL,EAAc,CAMlB,GALKW,EAAsBP,GAC1BD,EAAMC,EACKQ,EAAcR,KACzBD,EAAMC,EAAIP,aAEE,IAARM,EACJ,OAAOU,EAAaV,EAAKf,EAAMC,GAEhC,GAAKyB,EAAeV,GACnB,MAAM,IAAIW,MAAO,qFAElB,GAAKC,EAAUZ,GAAQ,CACtB,IAA6B,IAAxBpB,EACJ,MAAM,IAAIwB,UAAWC,EAAQ,sIAAuIL,IAErK,IAAMM,EAAYN,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,wGAAyGL,IAGvI,GADAA,EAAMA,EAAKa,MACLP,EAAYN,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,wGAAyGL,IAEvI,OAAOlB,EAAqBkB,EAAKhB,EAAMC,EACvC,CACD,MAAM,IAAImB,UAAWC,EAAQ,wGAAyGL,GACzI,CAAS,GAAKU,EAAeV,GAC1B,MAAM,IAAIW,MAAO,qFAElB,MAAM,IAAIP,UAAWC,EAAQ,wGAAyGL,GACtI,CACD,GAAe,IAAVJ,EAEJ,GAAKY,EADLR,EAAMC,UAAW,IAEhBf,EAAM,IAAIY,EAAME,EAAIP,aACd,GAAKiB,EAAeV,GAC1Bd,EAAM,IAAIY,EAAME,QACV,GAAKO,EAAsBP,GACjCd,EAAM,IAAIY,EAAME,OACV,KAAKY,EAAUZ,GAarB,MAAM,IAAII,UAAWC,EAAQ,wGAAyGL,IAZtI,IAA6B,IAAxBpB,EACJ,MAAM,IAAIwB,UAAWC,EAAQ,sIAAuIL,IAErK,IAAMM,EAAYN,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,wGAAyGL,IAGvI,GADAA,EAAMA,EAAKa,MACLP,EAAYN,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,wGAAyGL,IAEvId,EAAM,IAAIY,EAAMgB,EAAYd,GAG5B,MAEDd,EADqB,IAAVU,EACL,IAAIE,EAAMG,UAAU,GAAIA,UAAU,IAElC,IAAIH,EAAMG,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKf,EAAIO,OAAS,IACZ,WAAWsB,KAAMlB,GACrBL,EAAiBN,EAAKF,EAAMC,GAE5B+B,EAAS9B,EAAIO,OAAQP,EAAK,EAAG+B,IAGxB/B,EAYP,SAAS+B,EAAUC,EAAOC,GACzB,OAAOnC,EAAKO,KAAMN,EAASkC,EAC3B,CACF"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d115cf0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,192 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -/** -* Create a filled array according to a provided callback function. -* -* @module @stdlib/array-filled-by -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* var arr = filledarrayBy(); -* // returns -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'generic', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( [ 0.5, 0.5 ], clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1; -* } -* -* var arr = filledarrayBy( [ 5, -3 ], 'int32', clbk ); -* // returns [ 1, 1 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk1() { -* return 10; -* } -* -* function clbk2() { -* return 1.0; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, clbk2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk1() { -* return 1.0; -* } -* -* function clbk2() { -* return 2; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, 'uint32', clbk2 ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 'float32', clbk ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, clbk ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, 'int32', clbk ); -* // returns [ 1, 1 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index d27b055..0000000 --- a/lib/main.js +++ /dev/null @@ -1,413 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var isCollection = require( '@stdlib/assert-is-collection' ); -var isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isObject = require( '@stdlib/assert-is-object' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var ctors = require( '@stdlib/array-ctors' ); -var gfillBy = require( '@stdlib/blas-ext-base-gfill-by' ); -var filledArray = require( '@stdlib/array-base-filled-by' ); -var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var iterLength = require( '@stdlib/iter-length' ); -var format = require( '@stdlib/string-format' ); - - -// VARIABLES // - -var HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport(); -var DEFAULT_DTYPE = 'float64'; - - -// FUNCTIONS // - -/** -* Creates a filled "generic" array from an iterator. -* -* @private -* @param {Iterable} it - iterator -* @param {Callback} clbk - callback function -* @param {*} thisArg - callback function execution context -* @returns {Array} filled array -*/ -function filledArrayIterator( it, clbk, thisArg ) { - var arr; - var i; - var v; - - arr = []; - i = -1; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - i += 1; - arr.push( clbk.call( thisArg, i ) ); - } - return arr; -} - -/** -* Fills an array exposing accessors for getting and setting array elements. -* -* @private -* @param {Collection} arr - input array -* @param {Callback} clbk - callback function -* @param {*} thisArg - callback function execution context -* @returns {Collection} input array -*/ -function filledAccessors( arr, clbk, thisArg ) { - var i; - for ( i = 0; i < arr.length; i++ ) { - arr.set( clbk.call( thisArg, i ), i ); - } - return arr; -} - - -// MAIN // - -/** -* Creates a filled array according to a provided callback function. -* -* @param {(NonNegativeInteger|TypedArray|ArrayLikeObject|ArrayBuffer|Iterable)} [arg] - a length, typed array, array-like object, buffer, or iterable -* @param {NonNegativeInteger} [byteOffset=0] - byte offset -* @param {NonNegativeInteger} [length] - view length -* @param {string} [dtype="float64"] - data type -* @param {Callback} [clbk] - callback to invoke -* @param {*} [thisArg] - callback execution context -* @throws {TypeError} must provide a recognized data type -* @throws {TypeError} must provide a length, typed array, array-like object, buffer, or iterable -* @throws {TypeError} callback argument must be a function. -* @throws {Error} creating a generic array from an `ArrayBuffer` is not supported -* @returns {(TypedArray|Array)} array or typed array -* -* @example -* var arr = filledarrayBy(); -* // returns -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'generic', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( [ 0.5, 0.5 ], clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1; -* } -* -* var arr = filledarrayBy( [ 5, -3 ], 'int32', clbk ); -* // returns [ 1, 1 ] -* -* @example -* function clbk1() { -* return 10; -* } -* -* function clbk2() { -* return 1.0; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, clbk2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk1() { -* return 1.0; -* } -* -* function clbk2() { -* return 2; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, 'uint32', clbk2 ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 'float32', clbk ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, clbk ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, 'int32', clbk ); -* // returns [ 1, 1 ] -*/ -function filledarrayBy() { - var thisArg; - var nargs; - var dtype; - var clbk; - var ctor; - var arr; - var len; - var arg; - - nargs = arguments.length; - - // If we weren't provided any arguments, return an empty array... - if ( nargs === 0 ) { - ctor = ctors( DEFAULT_DTYPE ); - return new ctor( 0 ); - } - // Check if we were provided a dtype as the first argument... - dtype = arguments[ 0 ]; - if ( isString( dtype ) ) { - // Invoking this function with arguments `f( dtype, clbk[, thisArg] )` is not allowed (otherwise, we'd need to also allow `f( clbk[, thisArg] )`)... - if ( nargs > 1 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( 'invalid argument. Must provide a recognized data type. Value: `%s`.', dtype ) ); - } - // Return an empty array having the specified dtype: - return new ctor( 0 ); - } - // For all other supported invocations, we need at least two arguments... - if ( nargs < 2 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); - } - // At this point, we need to do some argument juggling... - nargs -= 1; // henceforth, the number of available arguments is `nargs+1` - - // Determine whether the last argument is a callback or "this" context... - if ( isFunction( arguments[ nargs ] ) ) { - // 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... - if ( isFunction( arguments[ nargs-1 ] ) ) { - thisArg = arguments[ nargs ]; - nargs -= 1; - clbk = arguments[ nargs ]; - - // Check if we were provided only a callback and a "this" context.. - if ( nargs === 0 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); - } - } else { - // "this" context is left undefined... - clbk = arguments[ nargs ]; - } - } - // 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... - else if ( nargs >= 2 ) { - thisArg = arguments[ nargs ]; - nargs -= 1; - clbk = arguments[ nargs ]; - if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); - } - } - // If were were only provided 2 arguments and the last argument was not a function, we've been provided an insufficient number of arguments... - else { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); - } - // Now that we've processed the callback arguments, let's continue working backward to see if we've been provided a `dtype` argument... - nargs -= 1; - if ( nargs >= 0 && isString( arguments[ nargs ] ) ) { - dtype = arguments[ nargs ]; - nargs -= 1; - } else { - dtype = DEFAULT_DTYPE; - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( 'invalid argument. Must provide a recognized data type. Value: `%s`.', dtype ) ); - } - // At this point, we've resolved the output array data type, and now we can actually create the output array... - if ( dtype === 'generic' ) { - arg = arguments[ 0 ]; - if ( nargs === 0 ) { - if ( isNonNegativeInteger( arg ) ) { - len = arg; - } else if ( isCollection( arg ) ) { - len = arg.length; - } - if ( len !== void 0 ) { - return filledArray( len, clbk, thisArg ); - } - if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); - } - if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); - } - return filledArrayIterator( arg, clbk, thisArg ); - } - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); - } else if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); - } - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); - } - if ( nargs === 0 ) { // length || array-like || ArrayBuffer || iterable - arg = arguments[ 0 ]; - if ( isCollection( arg ) ) { - arr = new ctor( arg.length ); - } else if ( isArrayBuffer( arg ) ) { - arr = new ctor( arg ); - } else if ( isNonNegativeInteger( arg ) ) { - arr = new ctor( arg ); - } else if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); - } - arr = new ctor( iterLength( arg ) ); - } else { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); - } - } else if ( nargs === 1 ) { - arr = new ctor( arguments[0], arguments[1] ); // (ArrayBuffer, byteOffset) - } else { - arr = new ctor( arguments[0], arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset, length) - } - if ( arr.length > 0 ) { - if ( /^complex/.test( dtype ) ) { - filledAccessors( arr, clbk, thisArg ); - } else { - gfillBy( arr.length, arr, 1, callback ); - } - } - return arr; - - /** - * Callback which wraps a provided callback and is invoked for each array element. - * - * @private - * @param {*} value - element value - * @param {NonNegativeInteger} aidx - array index - * @param {NonNegativeInteger} sidx - strided index - * @param {Collection} array - input array/collection - * @returns {*} callback return value - */ - function callback( value, aidx ) { - return clbk.call( thisArg, aidx ); - } -} - - -// EXPORTS // - -module.exports = filledarrayBy; diff --git a/package.json b/package.json index d799e6b..67155f1 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Create a filled array according to a provided callback function.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,69 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-filled-by": "^0.1.0", - "@stdlib/array-ctors": "^0.1.0", - "@stdlib/assert-has-iterator-symbol-support": "^0.1.1", - "@stdlib/assert-is-arraybuffer": "^0.1.1", - "@stdlib/assert-is-collection": "^0.1.0", - "@stdlib/assert-is-function": "^0.1.1", - "@stdlib/assert-is-nonnegative-integer": "^0.1.0", - "@stdlib/assert-is-object": "^0.1.1", - "@stdlib/assert-is-string": "^0.1.1", - "@stdlib/blas-ext-base-gfill-by": "^0.1.0", - "@stdlib/iter-length": "^0.1.1", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1", - "@stdlib/symbol-iterator": "^0.1.1", - "@stdlib/types": "^0.2.0" - }, - "devDependencies": { - "@stdlib/array-buffer": "^0.1.0", - "@stdlib/array-complex128": "^0.1.0", - "@stdlib/array-complex64": "^0.1.0", - "@stdlib/array-float32": "^0.1.1", - "@stdlib/array-float64": "^0.1.1", - "@stdlib/array-int16": "^0.1.1", - "@stdlib/array-int32": "^0.1.1", - "@stdlib/array-int8": "^0.1.1", - "@stdlib/array-typed-real-dtypes": "^0.1.1", - "@stdlib/array-uint16": "^0.1.1", - "@stdlib/array-uint32": "^0.1.1", - "@stdlib/array-uint8": "^0.1.1", - "@stdlib/array-uint8c": "^0.1.1", - "@stdlib/assert-instance-of": "^0.1.1", - "@stdlib/assert-is-array": "^0.1.1", - "@stdlib/assert-is-typed-array": "^0.1.0", - "@stdlib/assert-is-typed-array-like": "^0.1.0", - "@stdlib/complex-float32": "^0.1.1", - "@stdlib/complex-float64": "^0.1.1", - "@stdlib/iter-constant": "^0.1.0", - "@stdlib/math-base-special-pow": "^0.1.0", - "@stdlib/random-base-discrete-uniform": "^0.1.0", - "@stdlib/strided-base-reinterpret-complex128": "^0.1.1", - "@stdlib/strided-base-reinterpret-complex64": "^0.1.1", - "@stdlib/utils-constant-function": "^0.1.1", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.1.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..48b5ac2 --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index b55aa4a..0000000 --- a/test/test.js +++ /dev/null @@ -1,4248 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 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. -*/ - -/* eslint-disable max-len */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -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 ArrayBuffer = require( '@stdlib/array-buffer' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var iterConstant = require( '@stdlib/iter-constant' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var filledarrayBy = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': !hasIteratorSymbolSupport() -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof filledarrayBy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if only provided callback arguments', function test( t ) { - t.throws( clbk1, TypeError, 'throws an error' ); - t.throws( clbk2, TypeError, 'throws an error' ); - t.throws( clbk3, TypeError, 'throws an error' ); - t.end(); - - function clbk1() { - filledarrayBy( constantFunction( 1.0 ) ); - } - - function clbk2() { - filledarrayBy( constantFunction( 1.0 ), {} ); - } - - function clbk3() { - filledarrayBy( constantFunction( 1.0 ), constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (only argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (typed array; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (array-like object)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (array-like object; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 8 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 8 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, 1, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (iterator)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( iterConstant( 1.0 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (iterator; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( iterConstant( 1.0 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if only provided data type and callback arguments', function test( t ) { - t.throws( clbk1, TypeError, 'throws an error' ); - t.throws( clbk2, TypeError, 'throws an error' ); - t.throws( clbk3, TypeError, 'throws an error' ); - t.end(); - - function clbk1() { - filledarrayBy( 'float64', constantFunction( 1.0 ) ); - } - - function clbk2() { - filledarrayBy( 'float64', constantFunction( 1.0 ), {} ); - } - - function clbk3() { - filledarrayBy( 'float64', constantFunction( 1.0 ), constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (array-like object)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (array-like object; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, 1, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, 1, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (no iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (no iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (non-function iterator symbol property)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (non-function iterator symbol property; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (`next` property is not a function)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ) ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (`next` property is not a function; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ), {} ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (no iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (no iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (non-function iterator symbol property)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (non-function iterator symbol property; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (`next` property is not a function)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ) ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (`next` property is not a function; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ), {} ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 1, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 1, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function returns a filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - arr = filledarrayBy(); - - t.strictEqual( instanceOf( arr, Float64Array ), 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=float64)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - arr = filledarrayBy( 'float64' ); - - t.strictEqual( instanceOf( arr, Float64Array ), 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=float32)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( 0 ); - arr = filledarrayBy( 'float32' ); - - t.strictEqual( instanceOf( arr, Float32Array ), 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; - - expected = new Complex128Array( 0 ); - arr = filledarrayBy( 'complex128' ); - - t.strictEqual( instanceOf( arr, Complex128Array ), 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=complex64)', function test( t ) { - var expected; - var arr; - - expected = new Complex64Array( 0 ); - arr = filledarrayBy( 'complex64' ); - - t.strictEqual( instanceOf( arr, Complex64Array ), 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=int32)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( 0 ); - arr = filledarrayBy( 'int32' ); - - t.strictEqual( instanceOf( arr, Int32Array ), 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=uint32)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( 0 ); - arr = filledarrayBy( 'uint32' ); - - t.strictEqual( instanceOf( arr, Uint32Array ), 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=int16)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( 0 ); - arr = filledarrayBy( 'int16' ); - - t.strictEqual( instanceOf( arr, Int16Array ), 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=uint16)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( 0 ); - arr = filledarrayBy( 'uint16' ); - - t.strictEqual( instanceOf( arr, Uint16Array ), 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=int8)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( 0 ); - arr = filledarrayBy( 'int8' ); - - t.strictEqual( instanceOf( arr, Int8Array ), 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=uint8)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( 0 ); - arr = filledarrayBy( 'uint8' ); - - t.strictEqual( instanceOf( arr, Uint8Array ), 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=uint8c)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( 0 ); - arr = filledarrayBy( 'uint8c' ); - - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), 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=generic)', function test( t ) { - var expected; - var arr; - - expected = []; - arr = filledarrayBy( 'generic' ); - - t.strictEqual( instanceOf( arr, Array ), 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 (default, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, length=0)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array(); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 0, clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, clbk, ctx ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (default, length; thisArg=function)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, clbk, context ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this(); // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } - - function context() { - ctx.count += 1; - } -}); - -tape( 'the function returns a filled array (dtype=float64, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, 'float64', clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, length; thisArg=function)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, 'float64', clbk, context ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this(); // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } - - function context() { - ctx.count += 1; - } -}); - -tape( 'the function returns a filled array (dtype=float32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, 'float32', clbk ); - - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex128, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = filledarrayBy( 5, 'complex128', clbk ); - - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = filledarrayBy( 5, 'complex64', clbk ); - - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int32Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int32', clbk ); - - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint32Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint32', clbk ); - - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int16Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int16', clbk ); - - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint16', clbk ); - - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int8Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int8', clbk ); - - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint8', clbk ); - - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint8c', clbk ); - - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = [ 1, 1, 1, 1, 1 ]; - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'generic', clbk ); - - t.strictEqual( instanceOf( arr, Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex128, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = [ 1.0, 2.0 ]; - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = [ 1.0, 2.0 ]; - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int32', clbk ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, typed array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, typed array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex128, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = new Float64Array( [ 1.0, 2.0 ] ); - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = new Float64Array( [ 1.0, 2.0 ] ); - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (default, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex128, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer, byteoffset; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer, byteoffset; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, 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; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 48 ); - out = filledarrayBy( buf, 16, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 24 ); - out = filledarrayBy( buf, 8, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int32', clbk ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint8c', clbk ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, 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; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 64 ); - out = filledarrayBy( buf, 16, 2, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset, length)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 1, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 1, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled array (default, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, iterator; thisArg)', opts, function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - ctx = { - 'count': 0 - }; - indices = []; - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, iterator; thisArg)', opts, function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - ctx = { - 'count': 0 - }; - indices = []; - out = filledarrayBy( arr, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex128, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = iterConstant( new Complex128( 3.0, 3.0 ), { - 'iter': 2 - }); - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = iterConstant( new Complex64( 3.0, 3.0 ), { - 'iter': 2 - }); - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); From e2c4bae738e76275ad199071eb70a0a0c862a28d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 7 Jan 2024 22:17:55 +0000 Subject: [PATCH 035/117] Transform error messages --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b4aa9e8..d799e6b 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "@stdlib/assert-is-string": "^0.1.1", "@stdlib/blas-ext-base-gfill-by": "^0.1.0", "@stdlib/iter-length": "^0.1.1", - "@stdlib/string-format": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1", "@stdlib/symbol-iterator": "^0.1.1", "@stdlib/types": "^0.2.0" }, From 9e2e04e0f49fd72ceb0cdb389434fca7f1f2f54f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 7 Jan 2024 22:44:40 +0000 Subject: [PATCH 036/117] Remove files --- index.d.ts | 426 ---- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6608 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 2cd8555..0000000 --- a/index.d.ts +++ /dev/null @@ -1,426 +0,0 @@ -/* -* @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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, RealOrComplexTypedArray, DataType } from '@stdlib/types/array'; -import { IterableIterator } from '@stdlib/types/iter'; - -/** -* Array or typed array. -*/ -type ArrayOrTypedArray = Array | RealOrComplexTypedArray; - -/** -* Nullary callback function. -* -* @returns fill value -*/ -type Nullary = () => any; - -/** -* Unary callback function. -* -* @param i - current array index -* @returns fill value -*/ -type Unary = ( i: number ) => any; - -/** -* Callback function. -* -* @param i - current array index -* @returns fill value -*/ -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 -* -* @example -* var arr = filledarrayBy(); -* // returns -* -* @example -* var arr = filledarrayBy( 'float32' ); -* // returns -*/ -declare function filledarrayBy( dtype?: DataType ): ArrayOrTypedArray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Creates a filled array according to a provided callback function and having a specified `length`. -* -* @param length - array length -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* -* var arr = filledarrayBy( 5, constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( length: number, clbk: Callback, thisArg?: any ): ArrayOrTypedArray; - -/** -* 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 -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* -* var arr = filledarrayBy( 5, 'float64', constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( length: number, dtype: DataType, clbk: Callback, thisArg?: any ): ArrayOrTypedArray; - -/** -* Creates a filled array from another `array` according to a provided callback function. -* -* @param array - typed array or array-like object -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* -* 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; - -/** -* 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 -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* -* 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; - -/** -* Creates a filled array from an iterable according to a callback function. -* -* @param iterable - iterable -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* var iterConstant = require( `@stdlib/iter/constant` ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarrayBy( it, constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( iterable: IterableIterator, callback: Callback, thisArg?: any ): ArrayOrTypedArray; - -/** -* 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 -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* var iterConstant = require( `@stdlib/iter/constant` ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* 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; - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; - -/** -* 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. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; - -/** -* 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. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; - -/** -* 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. -* -* @param buffer - `ArrayBuffer` -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( `@stdlib/utils/constant-function` ); -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; - - -// EXPORTS // - -export = filledarrayBy; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index d809fe1..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.1.1-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.1.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.1.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.1.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.1.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-ctors@v0.1.0-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill-by@v0.1.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled-by@v0.1.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.1.1-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.1.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@v0.1.1-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";var y=d();function v(r,e,t){var i,a;for(i=[],a=-1;!r.next().done;)a+=1,i.push(e.call(t,a));return i}function h(r,e,t){var i;for(i=0;i1)throw new TypeError("invalid arguments. Must provide a length, typed array, array-like object, or an iterable.");if(null===(b=s(f)))throw new TypeError(u("invalid argument. Must provide a recognized data type. Value: `%s`.",f));return new b(0)}if(g<2)throw new TypeError("invalid arguments. Must provide a length, typed array, array-like object, or an iterable.");if(n(arguments[g-=1]))if(n(arguments[g-1])){if(d=arguments[g],j=arguments[g-=1],0===g)throw new TypeError("invalid arguments. Must provide a length, typed array, array-like object, or an iterable.")}else j=arguments[g];else{if(!(g>=2))throw new TypeError("invalid arguments. Must provide a length, typed array, array-like object, or an iterable.");if(d=arguments[g],!n(j=arguments[g-=1]))throw new TypeError(u("invalid argument. Callback argument must be a function. Value: `%s`.",j))}if((g-=1)>=0&&r(arguments[g])?(f=arguments[g],g-=1):f="float64",null===(b=s(f)))throw new TypeError(u("invalid argument. Must provide a recognized data type. Value: `%s`.",f));if("generic"===f){if(E=arguments[0],0===g){if(e(E)?w=E:t(E)&&(w=E.length),void 0!==w)return l(w,j,d);if(i(E))throw new Error("invalid arguments. Creating a generic array from an ArrayBuffer is not supported.");if(a(E)){if(!1===y)throw new TypeError(u("invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.",E));if(!n(E[p]))throw new TypeError(u("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",E));if(E=E[p](),!n(E.next))throw new TypeError(u("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",E));return v(E,j,d)}throw new TypeError(u("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",E))}if(i(E))throw new Error("invalid arguments. Creating a generic array from an ArrayBuffer is not supported.");throw new TypeError(u("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",E))}if(0===g)if(t(E=arguments[0]))c=new b(E.length);else if(i(E))c=new b(E);else if(e(E))c=new b(E);else{if(!a(E))throw new TypeError(u("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",E));if(!1===y)throw new TypeError(u("invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.",E));if(!n(E[p]))throw new TypeError(u("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",E));if(E=E[p](),!n(E.next))throw new TypeError(u("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",E));c=new b(m(E))}else c=1===g?new b(arguments[0],arguments[1]):new b(arguments[0],arguments[1],arguments[2]);return c.length>0&&(/^complex/.test(f)?h(c,j,d):o(c.length,c,1,x)),c;function x(r,e){return j.call(d,e)}}export{g as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 045cd6e..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.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\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport isCollection from '@stdlib/assert-is-collection';\nimport isArrayBuffer from '@stdlib/assert-is-arraybuffer';\nimport isObject from '@stdlib/assert-is-object';\nimport isFunction from '@stdlib/assert-is-function';\nimport ctors from '@stdlib/array-ctors';\nimport gfillBy from '@stdlib/blas-ext-base-gfill-by';\nimport filledArray from '@stdlib/array-base-filled-by';\nimport hasIteratorSymbolSupport from '@stdlib/assert-has-iterator-symbol-support';\nimport ITERATOR_SYMBOL from '@stdlib/symbol-iterator';\nimport iterLength from '@stdlib/iter-length';\nimport format from '@stdlib/string-format';\n\n\n// VARIABLES //\n\nvar HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport();\nvar DEFAULT_DTYPE = 'float64';\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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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\nexport default filledarrayBy;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","filledArrayIterator","it","clbk","thisArg","arr","i","next","done","push","call","filledAccessors","length","set","filledarrayBy","nargs","dtype","ctor","len","arg","arguments","ctors","isString","TypeError","format","isFunction","isNonNegativeInteger","isCollection","filledArray","isArrayBuffer","Error","isObject","ITERATOR_SYMBOL","iterLength","test","gfillBy","callback","value","aidx"],"mappings":";;muCAuCA,IAAIA,EAAsBC,IAe1B,SAASC,EAAqBC,EAAIC,EAAMC,GACvC,IAAIC,EACAC,EAKJ,IAFAD,EAAM,GACNC,GAAK,GAEAJ,EAAGK,OACAC,MAGPF,GAAK,EACLD,EAAII,KAAMN,EAAKO,KAAMN,EAASE,IAE/B,OAAOD,CACR,CAWA,SAASM,EAAiBN,EAAKF,EAAMC,GACpC,IAAIE,EACJ,IAAMA,EAAI,EAAGA,EAAID,EAAIO,OAAQN,IAC5BD,EAAIQ,IAAKV,EAAKO,KAAMN,EAASE,GAAKA,GAEnC,OAAOD,CACR,CA4JA,SAASS,IACR,IAAIV,EACAW,EACAC,EACAb,EACAc,EACAZ,EACAa,EACAC,EAKJ,GAAe,KAHfJ,EAAQK,UAAUR,QAKjB,OAAO,IADPK,EAAOI,EAzNW,YA0ND,GAIlB,GAAKC,EADLN,EAAQI,UAAW,IACM,CAExB,GAAKL,EAAQ,EACZ,MAAM,IAAIQ,UAAW,6FAGtB,GAAc,QADdN,EAAOI,EAAOL,IAEb,MAAM,IAAIO,UAAWC,EAAQ,sEAAuER,IAGrG,OAAO,IAAIC,EAAM,EACjB,CAED,GAAKF,EAAQ,EACZ,MAAM,IAAIQ,UAAW,6FAMtB,GAAKE,EAAYL,UAHjBL,GAAS,IAKR,GAAKU,EAAYL,UAAWL,EAAM,KAMjC,GALAX,EAAUgB,UAAWL,GAErBZ,EAAOiB,UADPL,GAAS,GAIM,IAAVA,EACJ,MAAM,IAAIQ,UAAW,kGAItBpB,EAAOiB,UAAWL,OAIf,MAAKA,GAAS,GAUlB,MAAM,IAAIQ,UAAW,6FANrB,GAHAnB,EAAUgB,UAAWL,IAGfU,EADNtB,EAAOiB,UADPL,GAAS,IAGR,MAAM,IAAIQ,UAAWC,EAAQ,uEAAwErB,GAMtG,CAUD,IARAY,GAAS,IACK,GAAKO,EAAUF,UAAWL,KACvCC,EAAQI,UAAWL,GACnBA,GAAS,GAETC,EArRkB,UAwRL,QADdC,EAAOI,EAAOL,IAEb,MAAM,IAAIO,UAAWC,EAAQ,sEAAuER,IAGrG,GAAe,YAAVA,EAAsB,CAE1B,GADAG,EAAMC,UAAW,GACF,IAAVL,EAAc,CAMlB,GALKW,EAAsBP,GAC1BD,EAAMC,EACKQ,EAAcR,KACzBD,EAAMC,EAAIP,aAEE,IAARM,EACJ,OAAOU,EAAaV,EAAKf,EAAMC,GAEhC,GAAKyB,EAAeV,GACnB,MAAM,IAAIW,MAAO,qFAElB,GAAKC,EAAUZ,GAAQ,CACtB,IAA6B,IAAxBpB,EACJ,MAAM,IAAIwB,UAAWC,EAAQ,sIAAuIL,IAErK,IAAMM,EAAYN,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,wGAAyGL,IAGvI,GADAA,EAAMA,EAAKa,MACLP,EAAYN,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,wGAAyGL,IAEvI,OAAOlB,EAAqBkB,EAAKhB,EAAMC,EACvC,CACD,MAAM,IAAImB,UAAWC,EAAQ,wGAAyGL,GACzI,CAAS,GAAKU,EAAeV,GAC1B,MAAM,IAAIW,MAAO,qFAElB,MAAM,IAAIP,UAAWC,EAAQ,wGAAyGL,GACtI,CACD,GAAe,IAAVJ,EAEJ,GAAKY,EADLR,EAAMC,UAAW,IAEhBf,EAAM,IAAIY,EAAME,EAAIP,aACd,GAAKiB,EAAeV,GAC1Bd,EAAM,IAAIY,EAAME,QACV,GAAKO,EAAsBP,GACjCd,EAAM,IAAIY,EAAME,OACV,KAAKY,EAAUZ,GAarB,MAAM,IAAII,UAAWC,EAAQ,wGAAyGL,IAZtI,IAA6B,IAAxBpB,EACJ,MAAM,IAAIwB,UAAWC,EAAQ,sIAAuIL,IAErK,IAAMM,EAAYN,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,wGAAyGL,IAGvI,GADAA,EAAMA,EAAKa,MACLP,EAAYN,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,wGAAyGL,IAEvId,EAAM,IAAIY,EAAMgB,EAAYd,GAG5B,MAEDd,EADqB,IAAVU,EACL,IAAIE,EAAMG,UAAU,GAAIA,UAAU,IAElC,IAAIH,EAAMG,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKf,EAAIO,OAAS,IACZ,WAAWsB,KAAMlB,GACrBL,EAAiBN,EAAKF,EAAMC,GAE5B+B,EAAS9B,EAAIO,OAAQP,EAAK,EAAG+B,IAGxB/B,EAYP,SAAS+B,EAAUC,EAAOC,GACzB,OAAOnC,EAAKO,KAAMN,EAASkC,EAC3B,CACF"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 48b5ac2..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 29aadd4abe2bad0f5a12d93a609138da63162f50 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 7 Jan 2024 22:45:16 +0000 Subject: [PATCH 037/117] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 255 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 228 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.js | 319 -- benchmark/benchmark.length.complex128.js | 98 - benchmark/benchmark.length.complex64.js | 98 - benchmark/benchmark.length.float32.js | 97 - benchmark/benchmark.length.float64.js | 97 - benchmark/benchmark.length.generic.js | 97 - benchmark/benchmark.length.int16.js | 97 - benchmark/benchmark.length.int32.js | 97 - benchmark/benchmark.length.int8.js | 97 - benchmark/benchmark.length.uint16.js | 97 - benchmark/benchmark.length.uint32.js | 97 - benchmark/benchmark.length.uint8.js | 97 - benchmark/benchmark.length.uint8c.js | 97 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 174 - docs/types/test.ts | 606 -- examples/index.js | 37 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 192 - lib/main.js | 413 -- package.json | 90 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 4248 -------------- 54 files changed, 6204 insertions(+), 10539 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.length.complex128.js delete mode 100644 benchmark/benchmark.length.complex64.js delete mode 100644 benchmark/benchmark.length.float32.js delete mode 100644 benchmark/benchmark.length.float64.js delete mode 100644 benchmark/benchmark.length.generic.js delete mode 100644 benchmark/benchmark.length.int16.js delete mode 100644 benchmark/benchmark.length.int32.js delete mode 100644 benchmark/benchmark.length.int8.js delete mode 100644 benchmark/benchmark.length.uint16.js delete mode 100644 benchmark/benchmark.length.uint32.js delete mode 100644 benchmark/benchmark.length.uint8.js delete mode 100644 benchmark/benchmark.length.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 8be0b82..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 30656c4..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index 3acd3a9..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA corresponding to v0.11.0 - uses: styfle/cancel-workflow-action@b173b6ec0100793626c2d9e6b90435061f4fc3e5 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index f988046..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index c92f5c4..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index a80a1ae..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '42 6 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index e1e3539..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -291,7 +284,7 @@ for ( i = 0; i < dt.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -359,9 +352,9 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/filled]: https://github.com/stdlib-js/array-filled +[@stdlib/array/filled]: https://github.com/stdlib-js/array-filled/tree/esm -[@stdlib/array/typed]: https://github.com/stdlib-js/array-typed +[@stdlib/array/typed]: https://github.com/stdlib-js/array-typed/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 67ba493..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,319 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); -var isArray = require( '@stdlib/assert-is-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var pkg = require( './../package.json' ).name; -var filledarrayBy = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 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=float64', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'float64', 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=float32', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'float32', 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; - var i; - - clbk = constantFunction( new Complex128( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'complex128', 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=complex64', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( new Complex64( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'complex64', 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=int32', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int32', 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=uint32', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint32', 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=int16', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int16', 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=uint16', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint16', 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=int8', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int8', 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=uint8', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint8', 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=uint8c', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint8c', 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=generic', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'generic', clbk ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.length.complex128.js b/benchmark/benchmark.length.complex128.js deleted file mode 100644 index 27f6c66..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 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 Complex128 = require( '@stdlib/complex-float64' ); -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( new Complex128( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'complex128', 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=complex128,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.complex64.js b/benchmark/benchmark.length.complex64.js deleted file mode 100644 index c094ae9..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 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 Complex64 = require( '@stdlib/complex-float32' ); -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( new Complex64( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'complex64', 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=complex64,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.float32.js b/benchmark/benchmark.length.float32.js deleted file mode 100644 index d2b2ba7..0000000 --- a/benchmark/benchmark.length.float32.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'float32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=float32,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.float64.js b/benchmark/benchmark.length.float64.js deleted file mode 100644 index 65064e3..0000000 --- a/benchmark/benchmark.length.float64.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'float64', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=float64,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.generic.js b/benchmark/benchmark.length.generic.js deleted file mode 100644 index eb87dfa..0000000 --- a/benchmark/benchmark.length.generic.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isArray = require( '@stdlib/assert-is-array' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'generic', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isArray( 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=generic,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int16.js b/benchmark/benchmark.length.int16.js deleted file mode 100644 index 914ff7c..0000000 --- a/benchmark/benchmark.length.int16.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int16', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=int16,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int32.js b/benchmark/benchmark.length.int32.js deleted file mode 100644 index cc0f678..0000000 --- a/benchmark/benchmark.length.int32.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=int32,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int8.js b/benchmark/benchmark.length.int8.js deleted file mode 100644 index 77553b0..0000000 --- a/benchmark/benchmark.length.int8.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int8', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=int8,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint16.js b/benchmark/benchmark.length.uint16.js deleted file mode 100644 index c68efdd..0000000 --- a/benchmark/benchmark.length.uint16.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint16', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint16,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint32.js b/benchmark/benchmark.length.uint32.js deleted file mode 100644 index 27c1742..0000000 --- a/benchmark/benchmark.length.uint32.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint32,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint8.js b/benchmark/benchmark.length.uint8.js deleted file mode 100644 index 2a26be4..0000000 --- a/benchmark/benchmark.length.uint8.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint8', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint8,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint8c.js b/benchmark/benchmark.length.uint8c.js deleted file mode 100644 index dd6e8c2..0000000 --- a/benchmark/benchmark.length.uint8c.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint8c', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint8c,len='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 799f532..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by" -%% click B href "https://github.com/stdlib-js/array-filled-by/tree/main" -%% click C href "https://github.com/stdlib-js/array-filled-by/tree/production" -%% click D href "https://github.com/stdlib-js/array-filled-by/tree/esm" -%% click E href "https://github.com/stdlib-js/array-filled-by/tree/deno" -%% click F href "https://github.com/stdlib-js/array-filled-by/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by -[production-url]: https://github.com/stdlib-js/array-filled-by/tree/production -[deno-url]: https://github.com/stdlib-js/array-filled-by/tree/deno -[umd-url]: https://github.com/stdlib-js/array-filled-by/tree/umd -[esm-url]: https://github.com/stdlib-js/array-filled-by/tree/esm \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 188fc9b..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import filledarrayBy from '../docs/types/index'; -export = filledarrayBy; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 1d6bba5..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var k=function(i,e){return function(){return e||i((e={exports:{}}).exports,e),e.exports}};var b=k(function(C,h){ -var p=require('@stdlib/assert-is-string/dist').isPrimitive,d=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'),j=require('@stdlib/array-base-filled-by/dist'),q=require('@stdlib/assert-has-iterator-symbol-support/dist'),g=require('@stdlib/symbol-iterator/dist'),V=require('@stdlib/iter-length/dist'),o=require('@stdlib/error-tools-fmtprodmsg/dist'),w=q(),c="float64";function A(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 S(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&&p(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(d(r)?s=r:f(r)&&(s=r.length),s!==void 0)return j(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 A(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(d(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)?S(l,a,i):M(l.length,l,1,E)),l;function E(I,T){return a.call(i,T)}}h.exports=B -});var x=b();module.exports=x; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index deab323..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "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 format = require( '@stdlib/string-format' );\n\n\n// VARIABLES //\n\nvar HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport();\nvar DEFAULT_DTYPE = 'float64';\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,EAAS,QAAS,uBAAwB,EAK1CC,EAAsBJ,EAAyB,EAC/CK,EAAgB,UAcpB,SAASC,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,EAAQ,UAAU,OAGbA,IAAU,EACd,OAAAE,EAAOpB,EAAOQ,CAAc,EACrB,IAAIY,EAAM,CAAE,EAIpB,GADAD,EAAQ,UAAW,CAAE,EAChBzB,EAAUyB,CAAM,EAAI,CAExB,GAAKD,EAAQ,EACZ,MAAM,IAAI,UAAW,2FAA4F,EAGlH,GADAE,EAAOpB,EAAOmB,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWd,EAAQ,sEAAuEa,CAAM,CAAE,EAG7G,OAAO,IAAIC,EAAM,CAAE,CACpB,CAEA,GAAKF,EAAQ,EACZ,MAAM,IAAI,UAAW,2FAA4F,EAMlH,GAHAA,GAAS,EAGJnB,EAAY,UAAWmB,CAAM,CAAE,EAEnC,GAAKnB,EAAY,UAAWmB,EAAM,CAAE,CAAE,GAMrC,GALAN,EAAU,UAAWM,CAAM,EAC3BA,GAAS,EACTP,EAAO,UAAWO,CAAM,EAGnBA,IAAU,EACd,MAAM,IAAI,UAAW,2FAA4F,OAIlHP,EAAO,UAAWO,CAAM,UAIhBA,GAAS,GAIlB,GAHAN,EAAU,UAAWM,CAAM,EAC3BA,GAAS,EACTP,EAAO,UAAWO,CAAM,EACnB,CAACnB,EAAYY,CAAK,EACtB,MAAM,IAAI,UAAWL,EAAQ,uEAAwEK,CAAK,CAAE,MAK7G,OAAM,IAAI,UAAW,2FAA4F,EAWlH,GARAO,GAAS,EACJA,GAAS,GAAKxB,EAAU,UAAWwB,CAAM,CAAE,GAC/CC,EAAQ,UAAWD,CAAM,EACzBA,GAAS,GAETC,EAAQX,EAETY,EAAOpB,EAAOmB,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWd,EAAQ,sEAAuEa,CAAM,CAAE,EAG7G,GAAKA,IAAU,UAAY,CAE1B,GADAG,EAAM,UAAW,CAAE,EACdJ,IAAU,EAAI,CAMlB,GALKvB,EAAsB2B,CAAI,EAC9BD,EAAMC,EACK1B,EAAc0B,CAAI,IAC7BD,EAAMC,EAAI,QAEND,IAAQ,OACZ,OAAOnB,EAAamB,EAAKV,EAAMC,CAAQ,EAExC,GAAKf,EAAeyB,CAAI,EACvB,MAAM,IAAI,MAAO,mFAAoF,EAEtG,GAAKxB,EAAUwB,CAAI,EAAI,CACtB,GAAKf,IAAwB,GAC5B,MAAM,IAAI,UAAWD,EAAQ,sIAAuIgB,CAAI,CAAE,EAE3K,GAAK,CAACvB,EAAYuB,EAAKlB,CAAgB,CAAE,EACxC,MAAM,IAAI,UAAWE,EAAQ,wGAAyGgB,CAAI,CAAE,EAG7I,GADAA,EAAMA,EAAKlB,CAAgB,EAAE,EACxB,CAACL,EAAYuB,EAAI,IAAK,EAC1B,MAAM,IAAI,UAAWhB,EAAQ,wGAAyGgB,CAAI,CAAE,EAE7I,OAAOb,EAAqBa,EAAKX,EAAMC,CAAQ,CAChD,CACA,MAAM,IAAI,UAAWN,EAAQ,wGAAyGgB,CAAI,CAAE,CAC7I,SAAYzB,EAAeyB,CAAI,EAC9B,MAAM,IAAI,MAAO,mFAAoF,EAEtG,MAAM,IAAI,UAAWhB,EAAQ,wGAAyGgB,CAAI,CAAE,CAC7I,CACA,GAAKJ,IAAU,EAEd,GADAI,EAAM,UAAW,CAAE,EACd1B,EAAc0B,CAAI,EACtBT,EAAM,IAAIO,EAAME,EAAI,MAAO,UAChBzB,EAAeyB,CAAI,EAC9BT,EAAM,IAAIO,EAAME,CAAI,UACT3B,EAAsB2B,CAAI,EACrCT,EAAM,IAAIO,EAAME,CAAI,UACTxB,EAAUwB,CAAI,EAAI,CAC7B,GAAKf,IAAwB,GAC5B,MAAM,IAAI,UAAWD,EAAQ,sIAAuIgB,CAAI,CAAE,EAE3K,GAAK,CAACvB,EAAYuB,EAAKlB,CAAgB,CAAE,EACxC,MAAM,IAAI,UAAWE,EAAQ,wGAAyGgB,CAAI,CAAE,EAG7I,GADAA,EAAMA,EAAKlB,CAAgB,EAAE,EACxB,CAACL,EAAYuB,EAAI,IAAK,EAC1B,MAAM,IAAI,UAAWhB,EAAQ,wGAAyGgB,CAAI,CAAE,EAE7IT,EAAM,IAAIO,EAAMf,EAAYiB,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,EAEpCX,EAASY,EAAI,OAAQA,EAAK,EAAGU,CAAS,GAGjCV,EAYP,SAASU,EAAUC,EAAOC,EAAO,CAChC,OAAOd,EAAK,KAAMC,EAASa,CAAK,CACjC,CACD,CAKAhC,EAAO,QAAUwB,IClOjB,IAAIS,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isString", "isNonNegativeInteger", "isCollection", "isArrayBuffer", "isObject", "isFunction", "ctors", "gfillBy", "filledArray", "hasIteratorSymbolSupport", "ITERATOR_SYMBOL", "iterLength", "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 deleted file mode 100644 index 5a68984..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,174 +0,0 @@ - -{{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) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr = {{alias}}() - - > arr = {{alias}}( 'float32' ) - - - -{{alias}}( length[, dtype], clbk[, thisArg] ) - Returns a filled array according to a provided callback function and having - a specified length. - - Parameters - ---------- - length: integer - Array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > function clbk() { return 1.0; }; - > var arr = {{alias}}( 5, clbk ) - [ 1.0, 1.0, 1.0, 1.0, 1.0 ] - > arr = {{alias}}( 5, 'int32', clbk ) - [ 1, 1, 1, 1, 1 ] - - -{{alias}}( array[, dtype], clbk[, thisArg] ) - Creates a filled array from another array (or array-like object) according - to a provided callback function. - - Parameters - ---------- - array: ArrayLikeObject - Array from which to generate another array. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias}}( [ 0.5, 0.5, 0.5 ], {{alias:@stdlib/utils/constant-function}}( 2.0 ) ) - [ 2.0, 2.0, 2.0 ] - > var arr2 = {{alias}}( arr1, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( iterable[, dtype], clbk[, thisArg] ) - Creates a filled array from an iterable according to a provided callback - function. - - Parameters - ---------- - iterable: Iterable - Iterable from which to generate an array. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias:@stdlib/iter/constant}}( 3.0, {'iter': 3} ); - > var arr2 = {{alias}}( arr1, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( buffer[, byteOffset[, length]][, dtype], clbk[, thisArg] ) - Returns a filled typed array view of an ArrayBuffer according to a provided - callback function. - - The 'generic' array data type is *not* supported. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( buf, 0, 4, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0, 1.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 394ac49..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,606 +0,0 @@ -/* -* @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. -*/ - -/// - -import { IterableIterator } from '@stdlib/types/iter'; -import filledarrayBy = require( './index' ); - - -/** -* Returns an iterator protocol-compliant object. -* -* @returns iterator protocol-compliant object -*/ -function iterator(): IterableIterator { - const obj: IterableIterator = { - [Symbol.iterator]: iterator, - 'next': next - }; - return obj; -} - -/** -* Implements the iterator protocol `next` method. -* -* @returns iterator protocol-compliant object -*/ -function next(): any { - return { - 'value': 1.0, - 'done': false - }; -} - -/** -* Callback function. -* -* @param i - current array index -* @returns return value -*/ -function clbk( i: number ): number { - return i; -} - - -// TESTS // - -// The function returns an array or typed array... -{ - filledarrayBy(); // $ExpectType ArrayOrTypedArray - filledarrayBy( 'float32' ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( 10, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( 10, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( 10, 'int32', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( 10, 'int32', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const x = new Float64Array( 10 ); - filledarrayBy( x, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( x, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( x, 'uint8', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( x, 'uint8', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const y = [ 2.0, 2.0, 2.0 ]; - filledarrayBy( y, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( y, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( y, 'float64', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( y, 'float64', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const it = iterator(); - filledarrayBy( it, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( it, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( it, 'uint8c', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( it, 'uint8c', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const buf = new ArrayBuffer( 32 ); - filledarrayBy( buf, clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 'uint32', clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 'uint32', clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 8, clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 8, clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 8, 'uint16', clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 8, 'uint16', clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 8, 2, clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 8, 2, clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 8, 2, 'int16', clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 8, 2, 'int16', clbk, {} ); // $ExpectType RealOrComplexTypedArray -} - -// The compiler throws an error if a callback function argument is not a function... -{ - filledarrayBy( 'float64', '5' ); // $ExpectError - filledarrayBy( 'float64', 1.0 ); // $ExpectError - filledarrayBy( 'float64', false ); // $ExpectError - filledarrayBy( 'float64', true ); // $ExpectError - filledarrayBy( 'float64', null ); // $ExpectError - filledarrayBy( 'float64', undefined ); // $ExpectError - filledarrayBy( 'float64', [] ); // $ExpectError - filledarrayBy( 'float64', {} ); // $ExpectError - - filledarrayBy( 'float64', '5', {} ); // $ExpectError - filledarrayBy( 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( 'float64', false, {} ); // $ExpectError - filledarrayBy( 'float64', true, {} ); // $ExpectError - filledarrayBy( 'float64', null, {} ); // $ExpectError - filledarrayBy( 'float64', undefined, {} ); // $ExpectError - filledarrayBy( 'float64', [], {} ); // $ExpectError - filledarrayBy( 'float64', {}, {} ); // $ExpectError - - filledarrayBy( 10, '5' ); // $ExpectError - filledarrayBy( 10, 1.0 ); // $ExpectError - filledarrayBy( 10, false ); // $ExpectError - filledarrayBy( 10, true ); // $ExpectError - filledarrayBy( 10, null ); // $ExpectError - filledarrayBy( 10, undefined ); // $ExpectError - filledarrayBy( 10, [] ); // $ExpectError - filledarrayBy( 10, {} ); // $ExpectError - - filledarrayBy( 10, '5', {} ); // $ExpectError - filledarrayBy( 10, 1.0, {} ); // $ExpectError - filledarrayBy( 10, false, {} ); // $ExpectError - filledarrayBy( 10, true, {} ); // $ExpectError - filledarrayBy( 10, null, {} ); // $ExpectError - filledarrayBy( 10, undefined, {} ); // $ExpectError - filledarrayBy( 10, [], {} ); // $ExpectError - filledarrayBy( 10, {}, {} ); // $ExpectError - - filledarrayBy( 10, 'float64', '5' ); // $ExpectError - filledarrayBy( 10, 'float64', 1.0 ); // $ExpectError - filledarrayBy( 10, 'float64', false ); // $ExpectError - filledarrayBy( 10, 'float64', true ); // $ExpectError - filledarrayBy( 10, 'float64', null ); // $ExpectError - filledarrayBy( 10, 'float64', undefined ); // $ExpectError - filledarrayBy( 10, 'float64', [] ); // $ExpectError - filledarrayBy( 10, 'float64', {} ); // $ExpectError - - filledarrayBy( 10, 'float64', '5', {} ); // $ExpectError - filledarrayBy( 10, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( 10, 'float64', false, {} ); // $ExpectError - filledarrayBy( 10, 'float64', true, {} ); // $ExpectError - filledarrayBy( 10, 'float64', null, {} ); // $ExpectError - filledarrayBy( 10, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( 10, 'float64', [], {} ); // $ExpectError - filledarrayBy( 10, 'float64', {}, {} ); // $ExpectError - - const x = new Float64Array( 10 ); - filledarrayBy( x, '5' ); // $ExpectError - filledarrayBy( x, 1.0 ); // $ExpectError - filledarrayBy( x, false ); // $ExpectError - filledarrayBy( x, true ); // $ExpectError - filledarrayBy( x, null ); // $ExpectError - filledarrayBy( x, undefined ); // $ExpectError - filledarrayBy( x, [] ); // $ExpectError - filledarrayBy( x, {} ); // $ExpectError - - filledarrayBy( x, '5', {} ); // $ExpectError - filledarrayBy( x, 1.0, {} ); // $ExpectError - filledarrayBy( x, false, {} ); // $ExpectError - filledarrayBy( x, true, {} ); // $ExpectError - filledarrayBy( x, null, {} ); // $ExpectError - filledarrayBy( x, undefined, {} ); // $ExpectError - filledarrayBy( x, [], {} ); // $ExpectError - filledarrayBy( x, {}, {} ); // $ExpectError - - filledarrayBy( x, 'float64', '5' ); // $ExpectError - filledarrayBy( x, 'float64', 1.0 ); // $ExpectError - filledarrayBy( x, 'float64', false ); // $ExpectError - filledarrayBy( x, 'float64', true ); // $ExpectError - filledarrayBy( x, 'float64', null ); // $ExpectError - filledarrayBy( x, 'float64', undefined ); // $ExpectError - filledarrayBy( x, 'float64', [] ); // $ExpectError - filledarrayBy( x, 'float64', {} ); // $ExpectError - - filledarrayBy( x, 'float64', '5', {} ); // $ExpectError - filledarrayBy( x, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( x, 'float64', false, {} ); // $ExpectError - filledarrayBy( x, 'float64', true, {} ); // $ExpectError - filledarrayBy( x, 'float64', null, {} ); // $ExpectError - filledarrayBy( x, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( x, 'float64', [], {} ); // $ExpectError - filledarrayBy( x, 'float64', {}, {} ); // $ExpectError - - const y = [ 2.0, 2.0, 2.0 ]; - filledarrayBy( y, '5' ); // $ExpectError - filledarrayBy( y, 1.0 ); // $ExpectError - filledarrayBy( y, false ); // $ExpectError - filledarrayBy( y, true ); // $ExpectError - filledarrayBy( y, null ); // $ExpectError - filledarrayBy( y, undefined ); // $ExpectError - filledarrayBy( y, [] ); // $ExpectError - filledarrayBy( y, {} ); // $ExpectError - - filledarrayBy( y, '5', {} ); // $ExpectError - filledarrayBy( y, 1.0, {} ); // $ExpectError - filledarrayBy( y, false, {} ); // $ExpectError - filledarrayBy( y, true, {} ); // $ExpectError - filledarrayBy( y, null, {} ); // $ExpectError - filledarrayBy( y, undefined, {} ); // $ExpectError - filledarrayBy( y, [], {} ); // $ExpectError - filledarrayBy( y, {}, {} ); // $ExpectError - - filledarrayBy( y, 'float64', '5' ); // $ExpectError - filledarrayBy( y, 'float64', 1.0 ); // $ExpectError - filledarrayBy( y, 'float64', false ); // $ExpectError - filledarrayBy( y, 'float64', true ); // $ExpectError - filledarrayBy( y, 'float64', null ); // $ExpectError - filledarrayBy( y, 'float64', undefined ); // $ExpectError - filledarrayBy( y, 'float64', [] ); // $ExpectError - filledarrayBy( y, 'float64', {} ); // $ExpectError - - filledarrayBy( y, 'float64', '5', {} ); // $ExpectError - filledarrayBy( y, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( y, 'float64', false, {} ); // $ExpectError - filledarrayBy( y, 'float64', true, {} ); // $ExpectError - filledarrayBy( y, 'float64', null, {} ); // $ExpectError - filledarrayBy( y, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( y, 'float64', [], {} ); // $ExpectError - filledarrayBy( y, 'float64', {}, {} ); // $ExpectError - - const it = iterator(); - filledarrayBy( it, '5' ); // $ExpectError - filledarrayBy( it, 1.0 ); // $ExpectError - filledarrayBy( it, false ); // $ExpectError - filledarrayBy( it, true ); // $ExpectError - filledarrayBy( it, null ); // $ExpectError - filledarrayBy( it, undefined ); // $ExpectError - filledarrayBy( it, [] ); // $ExpectError - filledarrayBy( it, {} ); // $ExpectError - - filledarrayBy( it, '5', {} ); // $ExpectError - filledarrayBy( it, 1.0, {} ); // $ExpectError - filledarrayBy( it, false, {} ); // $ExpectError - filledarrayBy( it, true, {} ); // $ExpectError - filledarrayBy( it, null, {} ); // $ExpectError - filledarrayBy( it, undefined, {} ); // $ExpectError - filledarrayBy( it, [], {} ); // $ExpectError - filledarrayBy( it, {}, {} ); // $ExpectError - - filledarrayBy( it, 'float64', '5' ); // $ExpectError - filledarrayBy( it, 'float64', 1.0 ); // $ExpectError - filledarrayBy( it, 'float64', false ); // $ExpectError - filledarrayBy( it, 'float64', true ); // $ExpectError - filledarrayBy( it, 'float64', null ); // $ExpectError - filledarrayBy( it, 'float64', undefined ); // $ExpectError - filledarrayBy( it, 'float64', [] ); // $ExpectError - filledarrayBy( it, 'float64', {} ); // $ExpectError - - filledarrayBy( it, 'float64', '5', {} ); // $ExpectError - filledarrayBy( it, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( it, 'float64', false, {} ); // $ExpectError - filledarrayBy( it, 'float64', true, {} ); // $ExpectError - filledarrayBy( it, 'float64', null, {} ); // $ExpectError - filledarrayBy( it, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( it, 'float64', [], {} ); // $ExpectError - filledarrayBy( it, 'float64', {}, {} ); // $ExpectError - - const buf = new ArrayBuffer( 32 ); - filledarrayBy( buf, '5' ); // $ExpectError - filledarrayBy( buf, 1.0 ); // $ExpectError - filledarrayBy( buf, false ); // $ExpectError - filledarrayBy( buf, true ); // $ExpectError - filledarrayBy( buf, null ); // $ExpectError - filledarrayBy( buf, undefined ); // $ExpectError - filledarrayBy( buf, [] ); // $ExpectError - filledarrayBy( buf, {} ); // $ExpectError - - filledarrayBy( buf, '5', {} ); // $ExpectError - filledarrayBy( buf, 1.0, {} ); // $ExpectError - filledarrayBy( buf, false, {} ); // $ExpectError - filledarrayBy( buf, true, {} ); // $ExpectError - filledarrayBy( buf, null, {} ); // $ExpectError - filledarrayBy( buf, undefined, {} ); // $ExpectError - filledarrayBy( buf, [], {} ); // $ExpectError - filledarrayBy( buf, {}, {} ); // $ExpectError - - filledarrayBy( buf, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 'float64', false ); // $ExpectError - filledarrayBy( buf, 'float64', true ); // $ExpectError - filledarrayBy( buf, 'float64', null ); // $ExpectError - filledarrayBy( buf, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 'float64', {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5' ); // $ExpectError - filledarrayBy( buf, 8, 1.0 ); // $ExpectError - filledarrayBy( buf, 8, false ); // $ExpectError - filledarrayBy( buf, 8, true ); // $ExpectError - filledarrayBy( buf, 8, null ); // $ExpectError - filledarrayBy( buf, 8, undefined ); // $ExpectError - filledarrayBy( buf, 8, [] ); // $ExpectError - filledarrayBy( buf, 8, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, false, {} ); // $ExpectError - filledarrayBy( buf, 8, true, {} ); // $ExpectError - filledarrayBy( buf, 8, null, {} ); // $ExpectError - filledarrayBy( buf, 8, undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, [], {} ); // $ExpectError - filledarrayBy( buf, 8, {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 8, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 'float64', false ); // $ExpectError - filledarrayBy( buf, 8, 'float64', true ); // $ExpectError - filledarrayBy( buf, 8, 'float64', null ); // $ExpectError - filledarrayBy( buf, 8, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 8, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 8, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 8, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, '5' ); // $ExpectError - filledarrayBy( buf, 8, 2, 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 2, false ); // $ExpectError - filledarrayBy( buf, 8, 2, true ); // $ExpectError - filledarrayBy( buf, 8, 2, null ); // $ExpectError - filledarrayBy( buf, 8, 2, undefined ); // $ExpectError - filledarrayBy( buf, 8, 2, [] ); // $ExpectError - filledarrayBy( buf, 8, 2, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, false, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, true, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, null, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, [], {} ); // $ExpectError - filledarrayBy( buf, 8, 2, {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', false ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', true ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', null ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', {}, {} ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid length, typed array, array-like object, `ArrayBuffer`, or iterable argument... -{ - filledarrayBy( false, clbk ); // $ExpectError - filledarrayBy( true, clbk ); // $ExpectError - filledarrayBy( null, clbk ); // $ExpectError - filledarrayBy( {}, clbk ); // $ExpectError - - filledarrayBy( false, clbk, {} ); // $ExpectError - filledarrayBy( true, clbk, {} ); // $ExpectError - filledarrayBy( null, clbk, {} ); // $ExpectError - filledarrayBy( {}, clbk, {} ); // $ExpectError - - filledarrayBy( false, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 'float64', clbk ); // $ExpectError - - filledarrayBy( false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, clbk ); // $ExpectError - filledarrayBy( 1.0, 8, clbk ); // $ExpectError - filledarrayBy( false, 8, clbk ); // $ExpectError - filledarrayBy( true, 8, clbk ); // $ExpectError - filledarrayBy( null, 8, clbk ); // $ExpectError - filledarrayBy( undefined, 8, clbk ); // $ExpectError - filledarrayBy( [], 8, clbk ); // $ExpectError - filledarrayBy( {}, 8, clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, clbk ); // $ExpectError - - filledarrayBy( '5', 8, clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, clbk, {} ); // $ExpectError - filledarrayBy( false, 8, clbk, {} ); // $ExpectError - filledarrayBy( true, 8, clbk, {} ); // $ExpectError - filledarrayBy( null, 8, clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, clbk, {} ); // $ExpectError - filledarrayBy( [], 8, clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 'float64', clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( false, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( [], 8, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 'float64', clbk ); // $ExpectError - - filledarrayBy( '5', 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 2, clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 2, clbk ); // $ExpectError - filledarrayBy( false, 8, 2, clbk ); // $ExpectError - filledarrayBy( true, 8, 2, clbk ); // $ExpectError - filledarrayBy( null, 8, 2, clbk ); // $ExpectError - filledarrayBy( undefined, 8, 2, clbk ); // $ExpectError - filledarrayBy( [], 8, 2, clbk ); // $ExpectError - filledarrayBy( {}, 8, 2, clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, clbk ); // $ExpectError - - filledarrayBy( '5', 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( false, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( [], 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, 'float64', clbk ); // $ExpectError - - filledarrayBy( '5', 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a byte offset argument which is not a number... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, false, clbk ); // $ExpectError - filledarrayBy( buf, true, clbk ); // $ExpectError - filledarrayBy( buf, null, clbk ); // $ExpectError - filledarrayBy( buf, [], clbk ); // $ExpectError - filledarrayBy( buf, {}, clbk ); // $ExpectError - - filledarrayBy( buf, false, clbk, {} ); // $ExpectError - filledarrayBy( buf, true, clbk, {} ); // $ExpectError - filledarrayBy( buf, null, clbk, {} ); // $ExpectError - filledarrayBy( buf, [], clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, clbk, {} ); // $ExpectError - - filledarrayBy( buf, '5', 'float64', clbk ); // $ExpectError - filledarrayBy( buf, false, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, true, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, null, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, [], 'float64', clbk ); // $ExpectError - filledarrayBy( buf, {}, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, '5', 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( buf, false, 2, clbk ); // $ExpectError - filledarrayBy( buf, true, 2, clbk ); // $ExpectError - filledarrayBy( buf, null, 2, clbk ); // $ExpectError - filledarrayBy( buf, [], 2, clbk ); // $ExpectError - filledarrayBy( buf, {}, 2, clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, clbk ); // $ExpectError - - filledarrayBy( buf, false, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, clbk, {} ); // $ExpectError - - filledarrayBy( buf, '5', 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, false, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, true, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, null, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, undefined, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, [], 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, {}, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, '5', 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, false, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, undefined, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a view length argument which is not a number... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, 8, false, clbk ); // $ExpectError - filledarrayBy( buf, 8, true, clbk ); // $ExpectError - filledarrayBy( buf, 8, null, clbk ); // $ExpectError - filledarrayBy( buf, 8, [], clbk ); // $ExpectError - filledarrayBy( buf, 8, {}, clbk ); // $ExpectError - - filledarrayBy( buf, 8, false, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, true, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, null, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, [], clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, {}, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, clbk, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5', 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, false, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, true, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, null, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, [], 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, {}, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, 8, '5', 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, [], 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, {}, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided too many arguments... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, 8, 2, 'float64', 1, clbk, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 997a381..0000000 --- a/examples/index.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ).factory; -var dtypes = require( '@stdlib/array-typed-real-dtypes' ); -var filledarrayBy = require( './../lib' ); - -// Create a pseudorandom number generator: -var rand = discreteUniform( 0, 100 ); - -// Get a list of array data types: -var dt = dtypes(); - -// Generate filled arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = filledarrayBy( 10, dt[ i ], rand ); - console.log( arr ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index b1fd829..e1b94a1 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, RealOrComplexTypedArray, DataType } from '@stdlib/types/array'; import { IterableIterator } from '@stdlib/types/iter'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..d809fe1 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.1.1-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.1.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.1.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.1.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.1.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-ctors@v0.1.0-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill-by@v0.1.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled-by@v0.1.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.1.1-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.1.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@v0.1.1-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";var y=d();function v(r,e,t){var i,a;for(i=[],a=-1;!r.next().done;)a+=1,i.push(e.call(t,a));return i}function h(r,e,t){var i;for(i=0;i1)throw new TypeError("invalid arguments. Must provide a length, typed array, array-like object, or an iterable.");if(null===(b=s(f)))throw new TypeError(u("invalid argument. Must provide a recognized data type. Value: `%s`.",f));return new b(0)}if(g<2)throw new TypeError("invalid arguments. Must provide a length, typed array, array-like object, or an iterable.");if(n(arguments[g-=1]))if(n(arguments[g-1])){if(d=arguments[g],j=arguments[g-=1],0===g)throw new TypeError("invalid arguments. Must provide a length, typed array, array-like object, or an iterable.")}else j=arguments[g];else{if(!(g>=2))throw new TypeError("invalid arguments. Must provide a length, typed array, array-like object, or an iterable.");if(d=arguments[g],!n(j=arguments[g-=1]))throw new TypeError(u("invalid argument. Callback argument must be a function. Value: `%s`.",j))}if((g-=1)>=0&&r(arguments[g])?(f=arguments[g],g-=1):f="float64",null===(b=s(f)))throw new TypeError(u("invalid argument. Must provide a recognized data type. Value: `%s`.",f));if("generic"===f){if(E=arguments[0],0===g){if(e(E)?w=E:t(E)&&(w=E.length),void 0!==w)return l(w,j,d);if(i(E))throw new Error("invalid arguments. Creating a generic array from an ArrayBuffer is not supported.");if(a(E)){if(!1===y)throw new TypeError(u("invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.",E));if(!n(E[p]))throw new TypeError(u("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",E));if(E=E[p](),!n(E.next))throw new TypeError(u("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",E));return v(E,j,d)}throw new TypeError(u("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",E))}if(i(E))throw new Error("invalid arguments. Creating a generic array from an ArrayBuffer is not supported.");throw new TypeError(u("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",E))}if(0===g)if(t(E=arguments[0]))c=new b(E.length);else if(i(E))c=new b(E);else if(e(E))c=new b(E);else{if(!a(E))throw new TypeError(u("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",E));if(!1===y)throw new TypeError(u("invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.",E));if(!n(E[p]))throw new TypeError(u("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",E));if(E=E[p](),!n(E.next))throw new TypeError(u("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",E));c=new b(m(E))}else c=1===g?new b(arguments[0],arguments[1]):new b(arguments[0],arguments[1],arguments[2]);return c.length>0&&(/^complex/.test(f)?h(c,j,d):o(c.length,c,1,x)),c;function x(r,e){return j.call(d,e)}}export{g as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..045cd6e --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.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\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport isCollection from '@stdlib/assert-is-collection';\nimport isArrayBuffer from '@stdlib/assert-is-arraybuffer';\nimport isObject from '@stdlib/assert-is-object';\nimport isFunction from '@stdlib/assert-is-function';\nimport ctors from '@stdlib/array-ctors';\nimport gfillBy from '@stdlib/blas-ext-base-gfill-by';\nimport filledArray from '@stdlib/array-base-filled-by';\nimport hasIteratorSymbolSupport from '@stdlib/assert-has-iterator-symbol-support';\nimport ITERATOR_SYMBOL from '@stdlib/symbol-iterator';\nimport iterLength from '@stdlib/iter-length';\nimport format from '@stdlib/string-format';\n\n\n// VARIABLES //\n\nvar HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport();\nvar DEFAULT_DTYPE = 'float64';\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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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\nexport default filledarrayBy;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","filledArrayIterator","it","clbk","thisArg","arr","i","next","done","push","call","filledAccessors","length","set","filledarrayBy","nargs","dtype","ctor","len","arg","arguments","ctors","isString","TypeError","format","isFunction","isNonNegativeInteger","isCollection","filledArray","isArrayBuffer","Error","isObject","ITERATOR_SYMBOL","iterLength","test","gfillBy","callback","value","aidx"],"mappings":";;muCAuCA,IAAIA,EAAsBC,IAe1B,SAASC,EAAqBC,EAAIC,EAAMC,GACvC,IAAIC,EACAC,EAKJ,IAFAD,EAAM,GACNC,GAAK,GAEAJ,EAAGK,OACAC,MAGPF,GAAK,EACLD,EAAII,KAAMN,EAAKO,KAAMN,EAASE,IAE/B,OAAOD,CACR,CAWA,SAASM,EAAiBN,EAAKF,EAAMC,GACpC,IAAIE,EACJ,IAAMA,EAAI,EAAGA,EAAID,EAAIO,OAAQN,IAC5BD,EAAIQ,IAAKV,EAAKO,KAAMN,EAASE,GAAKA,GAEnC,OAAOD,CACR,CA4JA,SAASS,IACR,IAAIV,EACAW,EACAC,EACAb,EACAc,EACAZ,EACAa,EACAC,EAKJ,GAAe,KAHfJ,EAAQK,UAAUR,QAKjB,OAAO,IADPK,EAAOI,EAzNW,YA0ND,GAIlB,GAAKC,EADLN,EAAQI,UAAW,IACM,CAExB,GAAKL,EAAQ,EACZ,MAAM,IAAIQ,UAAW,6FAGtB,GAAc,QADdN,EAAOI,EAAOL,IAEb,MAAM,IAAIO,UAAWC,EAAQ,sEAAuER,IAGrG,OAAO,IAAIC,EAAM,EACjB,CAED,GAAKF,EAAQ,EACZ,MAAM,IAAIQ,UAAW,6FAMtB,GAAKE,EAAYL,UAHjBL,GAAS,IAKR,GAAKU,EAAYL,UAAWL,EAAM,KAMjC,GALAX,EAAUgB,UAAWL,GAErBZ,EAAOiB,UADPL,GAAS,GAIM,IAAVA,EACJ,MAAM,IAAIQ,UAAW,kGAItBpB,EAAOiB,UAAWL,OAIf,MAAKA,GAAS,GAUlB,MAAM,IAAIQ,UAAW,6FANrB,GAHAnB,EAAUgB,UAAWL,IAGfU,EADNtB,EAAOiB,UADPL,GAAS,IAGR,MAAM,IAAIQ,UAAWC,EAAQ,uEAAwErB,GAMtG,CAUD,IARAY,GAAS,IACK,GAAKO,EAAUF,UAAWL,KACvCC,EAAQI,UAAWL,GACnBA,GAAS,GAETC,EArRkB,UAwRL,QADdC,EAAOI,EAAOL,IAEb,MAAM,IAAIO,UAAWC,EAAQ,sEAAuER,IAGrG,GAAe,YAAVA,EAAsB,CAE1B,GADAG,EAAMC,UAAW,GACF,IAAVL,EAAc,CAMlB,GALKW,EAAsBP,GAC1BD,EAAMC,EACKQ,EAAcR,KACzBD,EAAMC,EAAIP,aAEE,IAARM,EACJ,OAAOU,EAAaV,EAAKf,EAAMC,GAEhC,GAAKyB,EAAeV,GACnB,MAAM,IAAIW,MAAO,qFAElB,GAAKC,EAAUZ,GAAQ,CACtB,IAA6B,IAAxBpB,EACJ,MAAM,IAAIwB,UAAWC,EAAQ,sIAAuIL,IAErK,IAAMM,EAAYN,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,wGAAyGL,IAGvI,GADAA,EAAMA,EAAKa,MACLP,EAAYN,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,wGAAyGL,IAEvI,OAAOlB,EAAqBkB,EAAKhB,EAAMC,EACvC,CACD,MAAM,IAAImB,UAAWC,EAAQ,wGAAyGL,GACzI,CAAS,GAAKU,EAAeV,GAC1B,MAAM,IAAIW,MAAO,qFAElB,MAAM,IAAIP,UAAWC,EAAQ,wGAAyGL,GACtI,CACD,GAAe,IAAVJ,EAEJ,GAAKY,EADLR,EAAMC,UAAW,IAEhBf,EAAM,IAAIY,EAAME,EAAIP,aACd,GAAKiB,EAAeV,GAC1Bd,EAAM,IAAIY,EAAME,QACV,GAAKO,EAAsBP,GACjCd,EAAM,IAAIY,EAAME,OACV,KAAKY,EAAUZ,GAarB,MAAM,IAAII,UAAWC,EAAQ,wGAAyGL,IAZtI,IAA6B,IAAxBpB,EACJ,MAAM,IAAIwB,UAAWC,EAAQ,sIAAuIL,IAErK,IAAMM,EAAYN,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,wGAAyGL,IAGvI,GADAA,EAAMA,EAAKa,MACLP,EAAYN,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,wGAAyGL,IAEvId,EAAM,IAAIY,EAAMgB,EAAYd,GAG5B,MAEDd,EADqB,IAAVU,EACL,IAAIE,EAAMG,UAAU,GAAIA,UAAU,IAElC,IAAIH,EAAMG,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKf,EAAIO,OAAS,IACZ,WAAWsB,KAAMlB,GACrBL,EAAiBN,EAAKF,EAAMC,GAE5B+B,EAAS9B,EAAIO,OAAQP,EAAK,EAAG+B,IAGxB/B,EAYP,SAAS+B,EAAUC,EAAOC,GACzB,OAAOnC,EAAKO,KAAMN,EAASkC,EAC3B,CACF"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d115cf0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,192 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -/** -* Create a filled array according to a provided callback function. -* -* @module @stdlib/array-filled-by -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* var arr = filledarrayBy(); -* // returns -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'generic', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( [ 0.5, 0.5 ], clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1; -* } -* -* var arr = filledarrayBy( [ 5, -3 ], 'int32', clbk ); -* // returns [ 1, 1 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk1() { -* return 10; -* } -* -* function clbk2() { -* return 1.0; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, clbk2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk1() { -* return 1.0; -* } -* -* function clbk2() { -* return 2; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, 'uint32', clbk2 ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 'float32', clbk ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, clbk ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, 'int32', clbk ); -* // returns [ 1, 1 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index d27b055..0000000 --- a/lib/main.js +++ /dev/null @@ -1,413 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var isCollection = require( '@stdlib/assert-is-collection' ); -var isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isObject = require( '@stdlib/assert-is-object' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var ctors = require( '@stdlib/array-ctors' ); -var gfillBy = require( '@stdlib/blas-ext-base-gfill-by' ); -var filledArray = require( '@stdlib/array-base-filled-by' ); -var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var iterLength = require( '@stdlib/iter-length' ); -var format = require( '@stdlib/string-format' ); - - -// VARIABLES // - -var HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport(); -var DEFAULT_DTYPE = 'float64'; - - -// FUNCTIONS // - -/** -* Creates a filled "generic" array from an iterator. -* -* @private -* @param {Iterable} it - iterator -* @param {Callback} clbk - callback function -* @param {*} thisArg - callback function execution context -* @returns {Array} filled array -*/ -function filledArrayIterator( it, clbk, thisArg ) { - var arr; - var i; - var v; - - arr = []; - i = -1; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - i += 1; - arr.push( clbk.call( thisArg, i ) ); - } - return arr; -} - -/** -* Fills an array exposing accessors for getting and setting array elements. -* -* @private -* @param {Collection} arr - input array -* @param {Callback} clbk - callback function -* @param {*} thisArg - callback function execution context -* @returns {Collection} input array -*/ -function filledAccessors( arr, clbk, thisArg ) { - var i; - for ( i = 0; i < arr.length; i++ ) { - arr.set( clbk.call( thisArg, i ), i ); - } - return arr; -} - - -// MAIN // - -/** -* Creates a filled array according to a provided callback function. -* -* @param {(NonNegativeInteger|TypedArray|ArrayLikeObject|ArrayBuffer|Iterable)} [arg] - a length, typed array, array-like object, buffer, or iterable -* @param {NonNegativeInteger} [byteOffset=0] - byte offset -* @param {NonNegativeInteger} [length] - view length -* @param {string} [dtype="float64"] - data type -* @param {Callback} [clbk] - callback to invoke -* @param {*} [thisArg] - callback execution context -* @throws {TypeError} must provide a recognized data type -* @throws {TypeError} must provide a length, typed array, array-like object, buffer, or iterable -* @throws {TypeError} callback argument must be a function. -* @throws {Error} creating a generic array from an `ArrayBuffer` is not supported -* @returns {(TypedArray|Array)} array or typed array -* -* @example -* var arr = filledarrayBy(); -* // returns -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'generic', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( [ 0.5, 0.5 ], clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1; -* } -* -* var arr = filledarrayBy( [ 5, -3 ], 'int32', clbk ); -* // returns [ 1, 1 ] -* -* @example -* function clbk1() { -* return 10; -* } -* -* function clbk2() { -* return 1.0; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, clbk2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk1() { -* return 1.0; -* } -* -* function clbk2() { -* return 2; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, 'uint32', clbk2 ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 'float32', clbk ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, clbk ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, 'int32', clbk ); -* // returns [ 1, 1 ] -*/ -function filledarrayBy() { - var thisArg; - var nargs; - var dtype; - var clbk; - var ctor; - var arr; - var len; - var arg; - - nargs = arguments.length; - - // If we weren't provided any arguments, return an empty array... - if ( nargs === 0 ) { - ctor = ctors( DEFAULT_DTYPE ); - return new ctor( 0 ); - } - // Check if we were provided a dtype as the first argument... - dtype = arguments[ 0 ]; - if ( isString( dtype ) ) { - // Invoking this function with arguments `f( dtype, clbk[, thisArg] )` is not allowed (otherwise, we'd need to also allow `f( clbk[, thisArg] )`)... - if ( nargs > 1 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( 'invalid argument. Must provide a recognized data type. Value: `%s`.', dtype ) ); - } - // Return an empty array having the specified dtype: - return new ctor( 0 ); - } - // For all other supported invocations, we need at least two arguments... - if ( nargs < 2 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); - } - // At this point, we need to do some argument juggling... - nargs -= 1; // henceforth, the number of available arguments is `nargs+1` - - // Determine whether the last argument is a callback or "this" context... - if ( isFunction( arguments[ nargs ] ) ) { - // 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... - if ( isFunction( arguments[ nargs-1 ] ) ) { - thisArg = arguments[ nargs ]; - nargs -= 1; - clbk = arguments[ nargs ]; - - // Check if we were provided only a callback and a "this" context.. - if ( nargs === 0 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); - } - } else { - // "this" context is left undefined... - clbk = arguments[ nargs ]; - } - } - // 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... - else if ( nargs >= 2 ) { - thisArg = arguments[ nargs ]; - nargs -= 1; - clbk = arguments[ nargs ]; - if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); - } - } - // If were were only provided 2 arguments and the last argument was not a function, we've been provided an insufficient number of arguments... - else { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); - } - // Now that we've processed the callback arguments, let's continue working backward to see if we've been provided a `dtype` argument... - nargs -= 1; - if ( nargs >= 0 && isString( arguments[ nargs ] ) ) { - dtype = arguments[ nargs ]; - nargs -= 1; - } else { - dtype = DEFAULT_DTYPE; - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( 'invalid argument. Must provide a recognized data type. Value: `%s`.', dtype ) ); - } - // At this point, we've resolved the output array data type, and now we can actually create the output array... - if ( dtype === 'generic' ) { - arg = arguments[ 0 ]; - if ( nargs === 0 ) { - if ( isNonNegativeInteger( arg ) ) { - len = arg; - } else if ( isCollection( arg ) ) { - len = arg.length; - } - if ( len !== void 0 ) { - return filledArray( len, clbk, thisArg ); - } - if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); - } - if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); - } - return filledArrayIterator( arg, clbk, thisArg ); - } - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); - } else if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); - } - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); - } - if ( nargs === 0 ) { // length || array-like || ArrayBuffer || iterable - arg = arguments[ 0 ]; - if ( isCollection( arg ) ) { - arr = new ctor( arg.length ); - } else if ( isArrayBuffer( arg ) ) { - arr = new ctor( arg ); - } else if ( isNonNegativeInteger( arg ) ) { - arr = new ctor( arg ); - } else if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); - } - arr = new ctor( iterLength( arg ) ); - } else { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); - } - } else if ( nargs === 1 ) { - arr = new ctor( arguments[0], arguments[1] ); // (ArrayBuffer, byteOffset) - } else { - arr = new ctor( arguments[0], arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset, length) - } - if ( arr.length > 0 ) { - if ( /^complex/.test( dtype ) ) { - filledAccessors( arr, clbk, thisArg ); - } else { - gfillBy( arr.length, arr, 1, callback ); - } - } - return arr; - - /** - * Callback which wraps a provided callback and is invoked for each array element. - * - * @private - * @param {*} value - element value - * @param {NonNegativeInteger} aidx - array index - * @param {NonNegativeInteger} sidx - strided index - * @param {Collection} array - input array/collection - * @returns {*} callback return value - */ - function callback( value, aidx ) { - return clbk.call( thisArg, aidx ); - } -} - - -// EXPORTS // - -module.exports = filledarrayBy; diff --git a/package.json b/package.json index d799e6b..67155f1 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Create a filled array according to a provided callback function.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,69 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-filled-by": "^0.1.0", - "@stdlib/array-ctors": "^0.1.0", - "@stdlib/assert-has-iterator-symbol-support": "^0.1.1", - "@stdlib/assert-is-arraybuffer": "^0.1.1", - "@stdlib/assert-is-collection": "^0.1.0", - "@stdlib/assert-is-function": "^0.1.1", - "@stdlib/assert-is-nonnegative-integer": "^0.1.0", - "@stdlib/assert-is-object": "^0.1.1", - "@stdlib/assert-is-string": "^0.1.1", - "@stdlib/blas-ext-base-gfill-by": "^0.1.0", - "@stdlib/iter-length": "^0.1.1", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1", - "@stdlib/symbol-iterator": "^0.1.1", - "@stdlib/types": "^0.2.0" - }, - "devDependencies": { - "@stdlib/array-buffer": "^0.1.0", - "@stdlib/array-complex128": "^0.1.0", - "@stdlib/array-complex64": "^0.1.0", - "@stdlib/array-float32": "^0.1.1", - "@stdlib/array-float64": "^0.1.1", - "@stdlib/array-int16": "^0.1.1", - "@stdlib/array-int32": "^0.1.1", - "@stdlib/array-int8": "^0.1.1", - "@stdlib/array-typed-real-dtypes": "^0.1.1", - "@stdlib/array-uint16": "^0.1.1", - "@stdlib/array-uint32": "^0.1.1", - "@stdlib/array-uint8": "^0.1.1", - "@stdlib/array-uint8c": "^0.1.1", - "@stdlib/assert-instance-of": "^0.1.1", - "@stdlib/assert-is-array": "^0.1.1", - "@stdlib/assert-is-typed-array": "^0.1.0", - "@stdlib/assert-is-typed-array-like": "^0.1.0", - "@stdlib/complex-float32": "^0.1.1", - "@stdlib/complex-float64": "^0.1.1", - "@stdlib/iter-constant": "^0.1.0", - "@stdlib/math-base-special-pow": "^0.1.0", - "@stdlib/random-base-discrete-uniform": "^0.1.0", - "@stdlib/strided-base-reinterpret-complex128": "^0.1.1", - "@stdlib/strided-base-reinterpret-complex64": "^0.1.1", - "@stdlib/utils-constant-function": "^0.1.1", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.1.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..0c64349 --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index b55aa4a..0000000 --- a/test/test.js +++ /dev/null @@ -1,4248 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 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. -*/ - -/* eslint-disable max-len */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -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 ArrayBuffer = require( '@stdlib/array-buffer' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var iterConstant = require( '@stdlib/iter-constant' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var filledarrayBy = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': !hasIteratorSymbolSupport() -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof filledarrayBy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if only provided callback arguments', function test( t ) { - t.throws( clbk1, TypeError, 'throws an error' ); - t.throws( clbk2, TypeError, 'throws an error' ); - t.throws( clbk3, TypeError, 'throws an error' ); - t.end(); - - function clbk1() { - filledarrayBy( constantFunction( 1.0 ) ); - } - - function clbk2() { - filledarrayBy( constantFunction( 1.0 ), {} ); - } - - function clbk3() { - filledarrayBy( constantFunction( 1.0 ), constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (only argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (typed array; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (array-like object)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (array-like object; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 8 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 8 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, 1, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (iterator)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( iterConstant( 1.0 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (iterator; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( iterConstant( 1.0 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if only provided data type and callback arguments', function test( t ) { - t.throws( clbk1, TypeError, 'throws an error' ); - t.throws( clbk2, TypeError, 'throws an error' ); - t.throws( clbk3, TypeError, 'throws an error' ); - t.end(); - - function clbk1() { - filledarrayBy( 'float64', constantFunction( 1.0 ) ); - } - - function clbk2() { - filledarrayBy( 'float64', constantFunction( 1.0 ), {} ); - } - - function clbk3() { - filledarrayBy( 'float64', constantFunction( 1.0 ), constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (array-like object)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (array-like object; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, 1, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, 1, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (no iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (no iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (non-function iterator symbol property)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (non-function iterator symbol property; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (`next` property is not a function)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ) ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (`next` property is not a function; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ), {} ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (no iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (no iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (non-function iterator symbol property)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (non-function iterator symbol property; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (`next` property is not a function)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ) ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (`next` property is not a function; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ), {} ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 1, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 1, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function returns a filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - arr = filledarrayBy(); - - t.strictEqual( instanceOf( arr, Float64Array ), 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=float64)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - arr = filledarrayBy( 'float64' ); - - t.strictEqual( instanceOf( arr, Float64Array ), 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=float32)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( 0 ); - arr = filledarrayBy( 'float32' ); - - t.strictEqual( instanceOf( arr, Float32Array ), 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; - - expected = new Complex128Array( 0 ); - arr = filledarrayBy( 'complex128' ); - - t.strictEqual( instanceOf( arr, Complex128Array ), 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=complex64)', function test( t ) { - var expected; - var arr; - - expected = new Complex64Array( 0 ); - arr = filledarrayBy( 'complex64' ); - - t.strictEqual( instanceOf( arr, Complex64Array ), 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=int32)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( 0 ); - arr = filledarrayBy( 'int32' ); - - t.strictEqual( instanceOf( arr, Int32Array ), 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=uint32)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( 0 ); - arr = filledarrayBy( 'uint32' ); - - t.strictEqual( instanceOf( arr, Uint32Array ), 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=int16)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( 0 ); - arr = filledarrayBy( 'int16' ); - - t.strictEqual( instanceOf( arr, Int16Array ), 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=uint16)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( 0 ); - arr = filledarrayBy( 'uint16' ); - - t.strictEqual( instanceOf( arr, Uint16Array ), 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=int8)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( 0 ); - arr = filledarrayBy( 'int8' ); - - t.strictEqual( instanceOf( arr, Int8Array ), 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=uint8)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( 0 ); - arr = filledarrayBy( 'uint8' ); - - t.strictEqual( instanceOf( arr, Uint8Array ), 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=uint8c)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( 0 ); - arr = filledarrayBy( 'uint8c' ); - - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), 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=generic)', function test( t ) { - var expected; - var arr; - - expected = []; - arr = filledarrayBy( 'generic' ); - - t.strictEqual( instanceOf( arr, Array ), 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 (default, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, length=0)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array(); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 0, clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, clbk, ctx ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (default, length; thisArg=function)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, clbk, context ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this(); // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } - - function context() { - ctx.count += 1; - } -}); - -tape( 'the function returns a filled array (dtype=float64, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, 'float64', clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, length; thisArg=function)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, 'float64', clbk, context ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this(); // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } - - function context() { - ctx.count += 1; - } -}); - -tape( 'the function returns a filled array (dtype=float32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, 'float32', clbk ); - - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex128, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = filledarrayBy( 5, 'complex128', clbk ); - - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = filledarrayBy( 5, 'complex64', clbk ); - - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int32Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int32', clbk ); - - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint32Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint32', clbk ); - - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int16Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int16', clbk ); - - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint16', clbk ); - - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int8Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int8', clbk ); - - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint8', clbk ); - - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint8c', clbk ); - - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = [ 1, 1, 1, 1, 1 ]; - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'generic', clbk ); - - t.strictEqual( instanceOf( arr, Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex128, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = [ 1.0, 2.0 ]; - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = [ 1.0, 2.0 ]; - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int32', clbk ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, typed array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, typed array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex128, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = new Float64Array( [ 1.0, 2.0 ] ); - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = new Float64Array( [ 1.0, 2.0 ] ); - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (default, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex128, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer, byteoffset; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer, byteoffset; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, 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; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 48 ); - out = filledarrayBy( buf, 16, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 24 ); - out = filledarrayBy( buf, 8, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int32', clbk ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint8c', clbk ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, 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; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 64 ); - out = filledarrayBy( buf, 16, 2, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset, length)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 1, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 1, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled array (default, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, iterator; thisArg)', opts, function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - ctx = { - 'count': 0 - }; - indices = []; - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, iterator; thisArg)', opts, function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - ctx = { - 'count': 0 - }; - indices = []; - out = filledarrayBy( arr, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex128, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = iterConstant( new Complex128( 3.0, 3.0 ), { - 'iter': 2 - }); - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = iterConstant( new Complex64( 3.0, 3.0 ), { - 'iter': 2 - }); - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); From 04d0c7f3960594994ef36720a721ae18e8135e1e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 16 Jan 2024 08:38:17 +0000 Subject: [PATCH 038/117] Transform error messages --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index dafc8d1..77f78c8 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "@stdlib/assert-is-string": "^0.1.1", "@stdlib/blas-ext-base-gfill-by": "^0.1.0", "@stdlib/iter-length": "^0.1.1", - "@stdlib/string-format": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1", "@stdlib/symbol-iterator": "^0.1.1", "@stdlib/types": "^0.2.0" }, From 2fec284156e4c34f0a2e0bfe2e58becff941c268 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 16 Jan 2024 08:39:11 +0000 Subject: [PATCH 039/117] Remove files --- index.d.ts | 426 ---- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6608 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index e1b94a1..0000000 --- a/index.d.ts +++ /dev/null @@ -1,426 +0,0 @@ -/* -* @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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, RealOrComplexTypedArray, DataType } from '@stdlib/types/array'; -import { IterableIterator } from '@stdlib/types/iter'; - -/** -* Array or typed array. -*/ -type ArrayOrTypedArray = Array | RealOrComplexTypedArray; - -/** -* Nullary callback function. -* -* @returns fill value -*/ -type Nullary = () => any; - -/** -* Unary callback function. -* -* @param i - current array index -* @returns fill value -*/ -type Unary = ( i: number ) => any; - -/** -* Callback function. -* -* @param i - current array index -* @returns fill value -*/ -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 -* -* @example -* var arr = filledarrayBy(); -* // returns -* -* @example -* var arr = filledarrayBy( 'float32' ); -* // returns -*/ -declare function filledarrayBy( dtype?: DataType ): ArrayOrTypedArray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Creates a filled array according to a provided callback function and having a specified `length`. -* -* @param length - array length -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* -* var arr = filledarrayBy( 5, constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( length: number, clbk: Callback, thisArg?: any ): ArrayOrTypedArray; - -/** -* 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 -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* -* var arr = filledarrayBy( 5, 'float64', constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( length: number, dtype: DataType, clbk: Callback, thisArg?: any ): ArrayOrTypedArray; - -/** -* Creates a filled array from another `array` according to a provided callback function. -* -* @param array - typed array or array-like object -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* -* 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; - -/** -* 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 -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* -* 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; - -/** -* Creates a filled array from an iterable according to a callback function. -* -* @param iterable - iterable -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var iterConstant = require( '@stdlib/iter-constant' ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarrayBy( it, constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( iterable: IterableIterator, callback: Callback, thisArg?: any ): ArrayOrTypedArray; - -/** -* 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 -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var iterConstant = require( '@stdlib/iter-constant' ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* 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; - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; - -/** -* 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. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; - -/** -* 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. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; - -/** -* 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. -* -* @param buffer - `ArrayBuffer` -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; - - -// EXPORTS // - -export = filledarrayBy; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index d809fe1..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.1.1-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.1.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.1.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.1.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.1.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-ctors@v0.1.0-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill-by@v0.1.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled-by@v0.1.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.1.1-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.1.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@v0.1.1-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";var y=d();function v(r,e,t){var i,a;for(i=[],a=-1;!r.next().done;)a+=1,i.push(e.call(t,a));return i}function h(r,e,t){var i;for(i=0;i1)throw new TypeError("invalid arguments. Must provide a length, typed array, array-like object, or an iterable.");if(null===(b=s(f)))throw new TypeError(u("invalid argument. Must provide a recognized data type. Value: `%s`.",f));return new b(0)}if(g<2)throw new TypeError("invalid arguments. Must provide a length, typed array, array-like object, or an iterable.");if(n(arguments[g-=1]))if(n(arguments[g-1])){if(d=arguments[g],j=arguments[g-=1],0===g)throw new TypeError("invalid arguments. Must provide a length, typed array, array-like object, or an iterable.")}else j=arguments[g];else{if(!(g>=2))throw new TypeError("invalid arguments. Must provide a length, typed array, array-like object, or an iterable.");if(d=arguments[g],!n(j=arguments[g-=1]))throw new TypeError(u("invalid argument. Callback argument must be a function. Value: `%s`.",j))}if((g-=1)>=0&&r(arguments[g])?(f=arguments[g],g-=1):f="float64",null===(b=s(f)))throw new TypeError(u("invalid argument. Must provide a recognized data type. Value: `%s`.",f));if("generic"===f){if(E=arguments[0],0===g){if(e(E)?w=E:t(E)&&(w=E.length),void 0!==w)return l(w,j,d);if(i(E))throw new Error("invalid arguments. Creating a generic array from an ArrayBuffer is not supported.");if(a(E)){if(!1===y)throw new TypeError(u("invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.",E));if(!n(E[p]))throw new TypeError(u("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",E));if(E=E[p](),!n(E.next))throw new TypeError(u("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",E));return v(E,j,d)}throw new TypeError(u("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",E))}if(i(E))throw new Error("invalid arguments. Creating a generic array from an ArrayBuffer is not supported.");throw new TypeError(u("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",E))}if(0===g)if(t(E=arguments[0]))c=new b(E.length);else if(i(E))c=new b(E);else if(e(E))c=new b(E);else{if(!a(E))throw new TypeError(u("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",E));if(!1===y)throw new TypeError(u("invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.",E));if(!n(E[p]))throw new TypeError(u("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",E));if(E=E[p](),!n(E.next))throw new TypeError(u("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",E));c=new b(m(E))}else c=1===g?new b(arguments[0],arguments[1]):new b(arguments[0],arguments[1],arguments[2]);return c.length>0&&(/^complex/.test(f)?h(c,j,d):o(c.length,c,1,x)),c;function x(r,e){return j.call(d,e)}}export{g as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 045cd6e..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.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\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport isCollection from '@stdlib/assert-is-collection';\nimport isArrayBuffer from '@stdlib/assert-is-arraybuffer';\nimport isObject from '@stdlib/assert-is-object';\nimport isFunction from '@stdlib/assert-is-function';\nimport ctors from '@stdlib/array-ctors';\nimport gfillBy from '@stdlib/blas-ext-base-gfill-by';\nimport filledArray from '@stdlib/array-base-filled-by';\nimport hasIteratorSymbolSupport from '@stdlib/assert-has-iterator-symbol-support';\nimport ITERATOR_SYMBOL from '@stdlib/symbol-iterator';\nimport iterLength from '@stdlib/iter-length';\nimport format from '@stdlib/string-format';\n\n\n// VARIABLES //\n\nvar HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport();\nvar DEFAULT_DTYPE = 'float64';\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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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\nexport default filledarrayBy;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","filledArrayIterator","it","clbk","thisArg","arr","i","next","done","push","call","filledAccessors","length","set","filledarrayBy","nargs","dtype","ctor","len","arg","arguments","ctors","isString","TypeError","format","isFunction","isNonNegativeInteger","isCollection","filledArray","isArrayBuffer","Error","isObject","ITERATOR_SYMBOL","iterLength","test","gfillBy","callback","value","aidx"],"mappings":";;muCAuCA,IAAIA,EAAsBC,IAe1B,SAASC,EAAqBC,EAAIC,EAAMC,GACvC,IAAIC,EACAC,EAKJ,IAFAD,EAAM,GACNC,GAAK,GAEAJ,EAAGK,OACAC,MAGPF,GAAK,EACLD,EAAII,KAAMN,EAAKO,KAAMN,EAASE,IAE/B,OAAOD,CACR,CAWA,SAASM,EAAiBN,EAAKF,EAAMC,GACpC,IAAIE,EACJ,IAAMA,EAAI,EAAGA,EAAID,EAAIO,OAAQN,IAC5BD,EAAIQ,IAAKV,EAAKO,KAAMN,EAASE,GAAKA,GAEnC,OAAOD,CACR,CA4JA,SAASS,IACR,IAAIV,EACAW,EACAC,EACAb,EACAc,EACAZ,EACAa,EACAC,EAKJ,GAAe,KAHfJ,EAAQK,UAAUR,QAKjB,OAAO,IADPK,EAAOI,EAzNW,YA0ND,GAIlB,GAAKC,EADLN,EAAQI,UAAW,IACM,CAExB,GAAKL,EAAQ,EACZ,MAAM,IAAIQ,UAAW,6FAGtB,GAAc,QADdN,EAAOI,EAAOL,IAEb,MAAM,IAAIO,UAAWC,EAAQ,sEAAuER,IAGrG,OAAO,IAAIC,EAAM,EACjB,CAED,GAAKF,EAAQ,EACZ,MAAM,IAAIQ,UAAW,6FAMtB,GAAKE,EAAYL,UAHjBL,GAAS,IAKR,GAAKU,EAAYL,UAAWL,EAAM,KAMjC,GALAX,EAAUgB,UAAWL,GAErBZ,EAAOiB,UADPL,GAAS,GAIM,IAAVA,EACJ,MAAM,IAAIQ,UAAW,kGAItBpB,EAAOiB,UAAWL,OAIf,MAAKA,GAAS,GAUlB,MAAM,IAAIQ,UAAW,6FANrB,GAHAnB,EAAUgB,UAAWL,IAGfU,EADNtB,EAAOiB,UADPL,GAAS,IAGR,MAAM,IAAIQ,UAAWC,EAAQ,uEAAwErB,GAMtG,CAUD,IARAY,GAAS,IACK,GAAKO,EAAUF,UAAWL,KACvCC,EAAQI,UAAWL,GACnBA,GAAS,GAETC,EArRkB,UAwRL,QADdC,EAAOI,EAAOL,IAEb,MAAM,IAAIO,UAAWC,EAAQ,sEAAuER,IAGrG,GAAe,YAAVA,EAAsB,CAE1B,GADAG,EAAMC,UAAW,GACF,IAAVL,EAAc,CAMlB,GALKW,EAAsBP,GAC1BD,EAAMC,EACKQ,EAAcR,KACzBD,EAAMC,EAAIP,aAEE,IAARM,EACJ,OAAOU,EAAaV,EAAKf,EAAMC,GAEhC,GAAKyB,EAAeV,GACnB,MAAM,IAAIW,MAAO,qFAElB,GAAKC,EAAUZ,GAAQ,CACtB,IAA6B,IAAxBpB,EACJ,MAAM,IAAIwB,UAAWC,EAAQ,sIAAuIL,IAErK,IAAMM,EAAYN,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,wGAAyGL,IAGvI,GADAA,EAAMA,EAAKa,MACLP,EAAYN,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,wGAAyGL,IAEvI,OAAOlB,EAAqBkB,EAAKhB,EAAMC,EACvC,CACD,MAAM,IAAImB,UAAWC,EAAQ,wGAAyGL,GACzI,CAAS,GAAKU,EAAeV,GAC1B,MAAM,IAAIW,MAAO,qFAElB,MAAM,IAAIP,UAAWC,EAAQ,wGAAyGL,GACtI,CACD,GAAe,IAAVJ,EAEJ,GAAKY,EADLR,EAAMC,UAAW,IAEhBf,EAAM,IAAIY,EAAME,EAAIP,aACd,GAAKiB,EAAeV,GAC1Bd,EAAM,IAAIY,EAAME,QACV,GAAKO,EAAsBP,GACjCd,EAAM,IAAIY,EAAME,OACV,KAAKY,EAAUZ,GAarB,MAAM,IAAII,UAAWC,EAAQ,wGAAyGL,IAZtI,IAA6B,IAAxBpB,EACJ,MAAM,IAAIwB,UAAWC,EAAQ,sIAAuIL,IAErK,IAAMM,EAAYN,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,wGAAyGL,IAGvI,GADAA,EAAMA,EAAKa,MACLP,EAAYN,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,wGAAyGL,IAEvId,EAAM,IAAIY,EAAMgB,EAAYd,GAG5B,MAEDd,EADqB,IAAVU,EACL,IAAIE,EAAMG,UAAU,GAAIA,UAAU,IAElC,IAAIH,EAAMG,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKf,EAAIO,OAAS,IACZ,WAAWsB,KAAMlB,GACrBL,EAAiBN,EAAKF,EAAMC,GAE5B+B,EAAS9B,EAAIO,OAAQP,EAAK,EAAG+B,IAGxB/B,EAYP,SAAS+B,EAAUC,EAAOC,GACzB,OAAOnC,EAAKO,KAAMN,EAASkC,EAC3B,CACF"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 0c64349..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From bdc0903a2b64ffba226d90e872c6f95b0f3a5213 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 16 Jan 2024 08:39:34 +0000 Subject: [PATCH 040/117] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 255 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 228 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.js | 319 -- benchmark/benchmark.length.complex128.js | 98 - benchmark/benchmark.length.complex64.js | 98 - benchmark/benchmark.length.float32.js | 97 - benchmark/benchmark.length.float64.js | 97 - benchmark/benchmark.length.generic.js | 97 - benchmark/benchmark.length.int16.js | 97 - benchmark/benchmark.length.int32.js | 97 - benchmark/benchmark.length.int8.js | 97 - benchmark/benchmark.length.uint16.js | 97 - benchmark/benchmark.length.uint32.js | 97 - benchmark/benchmark.length.uint8.js | 97 - benchmark/benchmark.length.uint8c.js | 97 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 174 - docs/types/test.ts | 606 -- examples/index.js | 37 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 192 - lib/main.js | 414 -- package.json | 91 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 4248 -------------- 54 files changed, 6204 insertions(+), 10541 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.length.complex128.js delete mode 100644 benchmark/benchmark.length.complex64.js delete mode 100644 benchmark/benchmark.length.float32.js delete mode 100644 benchmark/benchmark.length.float64.js delete mode 100644 benchmark/benchmark.length.generic.js delete mode 100644 benchmark/benchmark.length.int16.js delete mode 100644 benchmark/benchmark.length.int32.js delete mode 100644 benchmark/benchmark.length.int8.js delete mode 100644 benchmark/benchmark.length.uint16.js delete mode 100644 benchmark/benchmark.length.uint32.js delete mode 100644 benchmark/benchmark.length.uint8.js delete mode 100644 benchmark/benchmark.length.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 8be0b82..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 30656c4..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index 3acd3a9..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA corresponding to v0.11.0 - uses: styfle/cancel-workflow-action@b173b6ec0100793626c2d9e6b90435061f4fc3e5 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index f988046..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index c92f5c4..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index a80a1ae..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '42 6 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index e1e3539..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -291,7 +284,7 @@ for ( i = 0; i < dt.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -359,9 +352,9 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/filled]: https://github.com/stdlib-js/array-filled +[@stdlib/array/filled]: https://github.com/stdlib-js/array-filled/tree/esm -[@stdlib/array/typed]: https://github.com/stdlib-js/array-typed +[@stdlib/array/typed]: https://github.com/stdlib-js/array-typed/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 67ba493..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,319 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); -var isArray = require( '@stdlib/assert-is-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var pkg = require( './../package.json' ).name; -var filledarrayBy = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 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=float64', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'float64', 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=float32', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'float32', 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; - var i; - - clbk = constantFunction( new Complex128( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'complex128', 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=complex64', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( new Complex64( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'complex64', 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=int32', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int32', 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=uint32', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint32', 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=int16', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int16', 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=uint16', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint16', 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=int8', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int8', 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=uint8', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint8', 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=uint8c', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint8c', 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=generic', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'generic', clbk ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.length.complex128.js b/benchmark/benchmark.length.complex128.js deleted file mode 100644 index 27f6c66..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 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 Complex128 = require( '@stdlib/complex-float64' ); -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( new Complex128( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'complex128', 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=complex128,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.complex64.js b/benchmark/benchmark.length.complex64.js deleted file mode 100644 index c094ae9..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 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 Complex64 = require( '@stdlib/complex-float32' ); -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( new Complex64( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'complex64', 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=complex64,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.float32.js b/benchmark/benchmark.length.float32.js deleted file mode 100644 index d2b2ba7..0000000 --- a/benchmark/benchmark.length.float32.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'float32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=float32,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.float64.js b/benchmark/benchmark.length.float64.js deleted file mode 100644 index 65064e3..0000000 --- a/benchmark/benchmark.length.float64.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'float64', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=float64,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.generic.js b/benchmark/benchmark.length.generic.js deleted file mode 100644 index eb87dfa..0000000 --- a/benchmark/benchmark.length.generic.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isArray = require( '@stdlib/assert-is-array' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'generic', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isArray( 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=generic,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int16.js b/benchmark/benchmark.length.int16.js deleted file mode 100644 index 914ff7c..0000000 --- a/benchmark/benchmark.length.int16.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int16', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=int16,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int32.js b/benchmark/benchmark.length.int32.js deleted file mode 100644 index cc0f678..0000000 --- a/benchmark/benchmark.length.int32.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=int32,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int8.js b/benchmark/benchmark.length.int8.js deleted file mode 100644 index 77553b0..0000000 --- a/benchmark/benchmark.length.int8.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int8', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=int8,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint16.js b/benchmark/benchmark.length.uint16.js deleted file mode 100644 index c68efdd..0000000 --- a/benchmark/benchmark.length.uint16.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint16', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint16,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint32.js b/benchmark/benchmark.length.uint32.js deleted file mode 100644 index 27c1742..0000000 --- a/benchmark/benchmark.length.uint32.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint32,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint8.js b/benchmark/benchmark.length.uint8.js deleted file mode 100644 index 2a26be4..0000000 --- a/benchmark/benchmark.length.uint8.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint8', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint8,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint8c.js b/benchmark/benchmark.length.uint8c.js deleted file mode 100644 index dd6e8c2..0000000 --- a/benchmark/benchmark.length.uint8c.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint8c', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint8c,len='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 799f532..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by" -%% click B href "https://github.com/stdlib-js/array-filled-by/tree/main" -%% click C href "https://github.com/stdlib-js/array-filled-by/tree/production" -%% click D href "https://github.com/stdlib-js/array-filled-by/tree/esm" -%% click E href "https://github.com/stdlib-js/array-filled-by/tree/deno" -%% click F href "https://github.com/stdlib-js/array-filled-by/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by -[production-url]: https://github.com/stdlib-js/array-filled-by/tree/production -[deno-url]: https://github.com/stdlib-js/array-filled-by/tree/deno -[umd-url]: https://github.com/stdlib-js/array-filled-by/tree/umd -[esm-url]: https://github.com/stdlib-js/array-filled-by/tree/esm \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 188fc9b..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import filledarrayBy from '../docs/types/index'; -export = filledarrayBy; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 468e99c..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"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 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 00888a2..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "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,EAAQ,UAAU,OAGbA,IAAU,EACd,OAAAE,EAAOrB,EAAOS,CAAc,EACrB,IAAIY,EAAM,CAAE,EAIpB,GADAD,EAAQ,UAAW,CAAE,EAChB1B,EAAU0B,CAAM,EAAI,CAExB,GAAKD,EAAQ,EACZ,MAAM,IAAI,UAAW,2FAA4F,EAGlH,GADAE,EAAOrB,EAAOoB,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWd,EAAQ,sEAAuEa,CAAM,CAAE,EAG7G,OAAO,IAAIC,EAAM,CAAE,CACpB,CAEA,GAAKF,EAAQ,EACZ,MAAM,IAAI,UAAW,2FAA4F,EAMlH,GAHAA,GAAS,EAGJpB,EAAY,UAAWoB,CAAM,CAAE,EAEnC,GAAKpB,EAAY,UAAWoB,EAAM,CAAE,CAAE,GAMrC,GALAN,EAAU,UAAWM,CAAM,EAC3BA,GAAS,EACTP,EAAO,UAAWO,CAAM,EAGnBA,IAAU,EACd,MAAM,IAAI,UAAW,2FAA4F,OAIlHP,EAAO,UAAWO,CAAM,UAIhBA,GAAS,GAIlB,GAHAN,EAAU,UAAWM,CAAM,EAC3BA,GAAS,EACTP,EAAO,UAAWO,CAAM,EACnB,CAACpB,EAAYa,CAAK,EACtB,MAAM,IAAI,UAAWL,EAAQ,uEAAwEK,CAAK,CAAE,MAK7G,OAAM,IAAI,UAAW,2FAA4F,EAWlH,GARAO,GAAS,EACJA,GAAS,GAAKzB,EAAU,UAAWyB,CAAM,CAAE,GAC/CC,EAAQ,UAAWD,CAAM,EACzBA,GAAS,GAETC,EAAQX,EAETY,EAAOrB,EAAOoB,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWd,EAAQ,sEAAuEa,CAAM,CAAE,EAG7G,GAAKA,IAAU,UAAY,CAE1B,GADAG,EAAM,UAAW,CAAE,EACdJ,IAAU,EAAI,CAMlB,GALKxB,EAAsB4B,CAAI,EAC9BD,EAAMC,EACK3B,EAAc2B,CAAI,IAC7BD,EAAMC,EAAI,QAEND,IAAQ,OACZ,OAAOpB,EAAaoB,EAAKV,EAAMC,CAAQ,EAExC,GAAKhB,EAAe0B,CAAI,EACvB,MAAM,IAAI,MAAO,mFAAoF,EAEtG,GAAKzB,EAAUyB,CAAI,EAAI,CACtB,GAAKf,IAAwB,GAC5B,MAAM,IAAI,UAAWD,EAAQ,sIAAuIgB,CAAI,CAAE,EAE3K,GAAK,CAACxB,EAAYwB,EAAKnB,CAAgB,CAAE,EACxC,MAAM,IAAI,UAAWG,EAAQ,wGAAyGgB,CAAI,CAAE,EAG7I,GADAA,EAAMA,EAAKnB,CAAgB,EAAE,EACxB,CAACL,EAAYwB,EAAI,IAAK,EAC1B,MAAM,IAAI,UAAWhB,EAAQ,wGAAyGgB,CAAI,CAAE,EAE7I,OAAOb,EAAqBa,EAAKX,EAAMC,CAAQ,CAChD,CACA,MAAM,IAAI,UAAWN,EAAQ,wGAAyGgB,CAAI,CAAE,CAC7I,SAAY1B,EAAe0B,CAAI,EAC9B,MAAM,IAAI,MAAO,mFAAoF,EAEtG,MAAM,IAAI,UAAWhB,EAAQ,wGAAyGgB,CAAI,CAAE,CAC7I,CACA,GAAKJ,IAAU,EAEd,GADAI,EAAM,UAAW,CAAE,EACd3B,EAAc2B,CAAI,EACtBT,EAAM,IAAIO,EAAME,EAAI,MAAO,UAChB1B,EAAe0B,CAAI,EAC9BT,EAAM,IAAIO,EAAME,CAAI,UACT5B,EAAsB4B,CAAI,EACrCT,EAAM,IAAIO,EAAME,CAAI,UACTzB,EAAUyB,CAAI,EAAI,CAC7B,GAAKf,IAAwB,GAC5B,MAAM,IAAI,UAAWD,EAAQ,sIAAuIgB,CAAI,CAAE,EAE3K,GAAK,CAACxB,EAAYwB,EAAKnB,CAAgB,CAAE,EACxC,MAAM,IAAI,UAAWG,EAAQ,wGAAyGgB,CAAI,CAAE,EAG7I,GADAA,EAAMA,EAAKnB,CAAgB,EAAE,EACxB,CAACL,EAAYwB,EAAI,IAAK,EAC1B,MAAM,IAAI,UAAWhB,EAAQ,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"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 5a68984..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,174 +0,0 @@ - -{{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) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr = {{alias}}() - - > arr = {{alias}}( 'float32' ) - - - -{{alias}}( length[, dtype], clbk[, thisArg] ) - Returns a filled array according to a provided callback function and having - a specified length. - - Parameters - ---------- - length: integer - Array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > function clbk() { return 1.0; }; - > var arr = {{alias}}( 5, clbk ) - [ 1.0, 1.0, 1.0, 1.0, 1.0 ] - > arr = {{alias}}( 5, 'int32', clbk ) - [ 1, 1, 1, 1, 1 ] - - -{{alias}}( array[, dtype], clbk[, thisArg] ) - Creates a filled array from another array (or array-like object) according - to a provided callback function. - - Parameters - ---------- - array: ArrayLikeObject - Array from which to generate another array. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias}}( [ 0.5, 0.5, 0.5 ], {{alias:@stdlib/utils/constant-function}}( 2.0 ) ) - [ 2.0, 2.0, 2.0 ] - > var arr2 = {{alias}}( arr1, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( iterable[, dtype], clbk[, thisArg] ) - Creates a filled array from an iterable according to a provided callback - function. - - Parameters - ---------- - iterable: Iterable - Iterable from which to generate an array. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias:@stdlib/iter/constant}}( 3.0, {'iter': 3} ); - > var arr2 = {{alias}}( arr1, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( buffer[, byteOffset[, length]][, dtype], clbk[, thisArg] ) - Returns a filled typed array view of an ArrayBuffer according to a provided - callback function. - - The 'generic' array data type is *not* supported. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( buf, 0, 4, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0, 1.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 394ac49..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,606 +0,0 @@ -/* -* @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. -*/ - -/// - -import { IterableIterator } from '@stdlib/types/iter'; -import filledarrayBy = require( './index' ); - - -/** -* Returns an iterator protocol-compliant object. -* -* @returns iterator protocol-compliant object -*/ -function iterator(): IterableIterator { - const obj: IterableIterator = { - [Symbol.iterator]: iterator, - 'next': next - }; - return obj; -} - -/** -* Implements the iterator protocol `next` method. -* -* @returns iterator protocol-compliant object -*/ -function next(): any { - return { - 'value': 1.0, - 'done': false - }; -} - -/** -* Callback function. -* -* @param i - current array index -* @returns return value -*/ -function clbk( i: number ): number { - return i; -} - - -// TESTS // - -// The function returns an array or typed array... -{ - filledarrayBy(); // $ExpectType ArrayOrTypedArray - filledarrayBy( 'float32' ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( 10, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( 10, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( 10, 'int32', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( 10, 'int32', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const x = new Float64Array( 10 ); - filledarrayBy( x, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( x, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( x, 'uint8', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( x, 'uint8', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const y = [ 2.0, 2.0, 2.0 ]; - filledarrayBy( y, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( y, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( y, 'float64', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( y, 'float64', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const it = iterator(); - filledarrayBy( it, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( it, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( it, 'uint8c', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( it, 'uint8c', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const buf = new ArrayBuffer( 32 ); - filledarrayBy( buf, clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 'uint32', clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 'uint32', clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 8, clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 8, clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 8, 'uint16', clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 8, 'uint16', clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 8, 2, clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 8, 2, clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 8, 2, 'int16', clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 8, 2, 'int16', clbk, {} ); // $ExpectType RealOrComplexTypedArray -} - -// The compiler throws an error if a callback function argument is not a function... -{ - filledarrayBy( 'float64', '5' ); // $ExpectError - filledarrayBy( 'float64', 1.0 ); // $ExpectError - filledarrayBy( 'float64', false ); // $ExpectError - filledarrayBy( 'float64', true ); // $ExpectError - filledarrayBy( 'float64', null ); // $ExpectError - filledarrayBy( 'float64', undefined ); // $ExpectError - filledarrayBy( 'float64', [] ); // $ExpectError - filledarrayBy( 'float64', {} ); // $ExpectError - - filledarrayBy( 'float64', '5', {} ); // $ExpectError - filledarrayBy( 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( 'float64', false, {} ); // $ExpectError - filledarrayBy( 'float64', true, {} ); // $ExpectError - filledarrayBy( 'float64', null, {} ); // $ExpectError - filledarrayBy( 'float64', undefined, {} ); // $ExpectError - filledarrayBy( 'float64', [], {} ); // $ExpectError - filledarrayBy( 'float64', {}, {} ); // $ExpectError - - filledarrayBy( 10, '5' ); // $ExpectError - filledarrayBy( 10, 1.0 ); // $ExpectError - filledarrayBy( 10, false ); // $ExpectError - filledarrayBy( 10, true ); // $ExpectError - filledarrayBy( 10, null ); // $ExpectError - filledarrayBy( 10, undefined ); // $ExpectError - filledarrayBy( 10, [] ); // $ExpectError - filledarrayBy( 10, {} ); // $ExpectError - - filledarrayBy( 10, '5', {} ); // $ExpectError - filledarrayBy( 10, 1.0, {} ); // $ExpectError - filledarrayBy( 10, false, {} ); // $ExpectError - filledarrayBy( 10, true, {} ); // $ExpectError - filledarrayBy( 10, null, {} ); // $ExpectError - filledarrayBy( 10, undefined, {} ); // $ExpectError - filledarrayBy( 10, [], {} ); // $ExpectError - filledarrayBy( 10, {}, {} ); // $ExpectError - - filledarrayBy( 10, 'float64', '5' ); // $ExpectError - filledarrayBy( 10, 'float64', 1.0 ); // $ExpectError - filledarrayBy( 10, 'float64', false ); // $ExpectError - filledarrayBy( 10, 'float64', true ); // $ExpectError - filledarrayBy( 10, 'float64', null ); // $ExpectError - filledarrayBy( 10, 'float64', undefined ); // $ExpectError - filledarrayBy( 10, 'float64', [] ); // $ExpectError - filledarrayBy( 10, 'float64', {} ); // $ExpectError - - filledarrayBy( 10, 'float64', '5', {} ); // $ExpectError - filledarrayBy( 10, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( 10, 'float64', false, {} ); // $ExpectError - filledarrayBy( 10, 'float64', true, {} ); // $ExpectError - filledarrayBy( 10, 'float64', null, {} ); // $ExpectError - filledarrayBy( 10, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( 10, 'float64', [], {} ); // $ExpectError - filledarrayBy( 10, 'float64', {}, {} ); // $ExpectError - - const x = new Float64Array( 10 ); - filledarrayBy( x, '5' ); // $ExpectError - filledarrayBy( x, 1.0 ); // $ExpectError - filledarrayBy( x, false ); // $ExpectError - filledarrayBy( x, true ); // $ExpectError - filledarrayBy( x, null ); // $ExpectError - filledarrayBy( x, undefined ); // $ExpectError - filledarrayBy( x, [] ); // $ExpectError - filledarrayBy( x, {} ); // $ExpectError - - filledarrayBy( x, '5', {} ); // $ExpectError - filledarrayBy( x, 1.0, {} ); // $ExpectError - filledarrayBy( x, false, {} ); // $ExpectError - filledarrayBy( x, true, {} ); // $ExpectError - filledarrayBy( x, null, {} ); // $ExpectError - filledarrayBy( x, undefined, {} ); // $ExpectError - filledarrayBy( x, [], {} ); // $ExpectError - filledarrayBy( x, {}, {} ); // $ExpectError - - filledarrayBy( x, 'float64', '5' ); // $ExpectError - filledarrayBy( x, 'float64', 1.0 ); // $ExpectError - filledarrayBy( x, 'float64', false ); // $ExpectError - filledarrayBy( x, 'float64', true ); // $ExpectError - filledarrayBy( x, 'float64', null ); // $ExpectError - filledarrayBy( x, 'float64', undefined ); // $ExpectError - filledarrayBy( x, 'float64', [] ); // $ExpectError - filledarrayBy( x, 'float64', {} ); // $ExpectError - - filledarrayBy( x, 'float64', '5', {} ); // $ExpectError - filledarrayBy( x, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( x, 'float64', false, {} ); // $ExpectError - filledarrayBy( x, 'float64', true, {} ); // $ExpectError - filledarrayBy( x, 'float64', null, {} ); // $ExpectError - filledarrayBy( x, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( x, 'float64', [], {} ); // $ExpectError - filledarrayBy( x, 'float64', {}, {} ); // $ExpectError - - const y = [ 2.0, 2.0, 2.0 ]; - filledarrayBy( y, '5' ); // $ExpectError - filledarrayBy( y, 1.0 ); // $ExpectError - filledarrayBy( y, false ); // $ExpectError - filledarrayBy( y, true ); // $ExpectError - filledarrayBy( y, null ); // $ExpectError - filledarrayBy( y, undefined ); // $ExpectError - filledarrayBy( y, [] ); // $ExpectError - filledarrayBy( y, {} ); // $ExpectError - - filledarrayBy( y, '5', {} ); // $ExpectError - filledarrayBy( y, 1.0, {} ); // $ExpectError - filledarrayBy( y, false, {} ); // $ExpectError - filledarrayBy( y, true, {} ); // $ExpectError - filledarrayBy( y, null, {} ); // $ExpectError - filledarrayBy( y, undefined, {} ); // $ExpectError - filledarrayBy( y, [], {} ); // $ExpectError - filledarrayBy( y, {}, {} ); // $ExpectError - - filledarrayBy( y, 'float64', '5' ); // $ExpectError - filledarrayBy( y, 'float64', 1.0 ); // $ExpectError - filledarrayBy( y, 'float64', false ); // $ExpectError - filledarrayBy( y, 'float64', true ); // $ExpectError - filledarrayBy( y, 'float64', null ); // $ExpectError - filledarrayBy( y, 'float64', undefined ); // $ExpectError - filledarrayBy( y, 'float64', [] ); // $ExpectError - filledarrayBy( y, 'float64', {} ); // $ExpectError - - filledarrayBy( y, 'float64', '5', {} ); // $ExpectError - filledarrayBy( y, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( y, 'float64', false, {} ); // $ExpectError - filledarrayBy( y, 'float64', true, {} ); // $ExpectError - filledarrayBy( y, 'float64', null, {} ); // $ExpectError - filledarrayBy( y, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( y, 'float64', [], {} ); // $ExpectError - filledarrayBy( y, 'float64', {}, {} ); // $ExpectError - - const it = iterator(); - filledarrayBy( it, '5' ); // $ExpectError - filledarrayBy( it, 1.0 ); // $ExpectError - filledarrayBy( it, false ); // $ExpectError - filledarrayBy( it, true ); // $ExpectError - filledarrayBy( it, null ); // $ExpectError - filledarrayBy( it, undefined ); // $ExpectError - filledarrayBy( it, [] ); // $ExpectError - filledarrayBy( it, {} ); // $ExpectError - - filledarrayBy( it, '5', {} ); // $ExpectError - filledarrayBy( it, 1.0, {} ); // $ExpectError - filledarrayBy( it, false, {} ); // $ExpectError - filledarrayBy( it, true, {} ); // $ExpectError - filledarrayBy( it, null, {} ); // $ExpectError - filledarrayBy( it, undefined, {} ); // $ExpectError - filledarrayBy( it, [], {} ); // $ExpectError - filledarrayBy( it, {}, {} ); // $ExpectError - - filledarrayBy( it, 'float64', '5' ); // $ExpectError - filledarrayBy( it, 'float64', 1.0 ); // $ExpectError - filledarrayBy( it, 'float64', false ); // $ExpectError - filledarrayBy( it, 'float64', true ); // $ExpectError - filledarrayBy( it, 'float64', null ); // $ExpectError - filledarrayBy( it, 'float64', undefined ); // $ExpectError - filledarrayBy( it, 'float64', [] ); // $ExpectError - filledarrayBy( it, 'float64', {} ); // $ExpectError - - filledarrayBy( it, 'float64', '5', {} ); // $ExpectError - filledarrayBy( it, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( it, 'float64', false, {} ); // $ExpectError - filledarrayBy( it, 'float64', true, {} ); // $ExpectError - filledarrayBy( it, 'float64', null, {} ); // $ExpectError - filledarrayBy( it, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( it, 'float64', [], {} ); // $ExpectError - filledarrayBy( it, 'float64', {}, {} ); // $ExpectError - - const buf = new ArrayBuffer( 32 ); - filledarrayBy( buf, '5' ); // $ExpectError - filledarrayBy( buf, 1.0 ); // $ExpectError - filledarrayBy( buf, false ); // $ExpectError - filledarrayBy( buf, true ); // $ExpectError - filledarrayBy( buf, null ); // $ExpectError - filledarrayBy( buf, undefined ); // $ExpectError - filledarrayBy( buf, [] ); // $ExpectError - filledarrayBy( buf, {} ); // $ExpectError - - filledarrayBy( buf, '5', {} ); // $ExpectError - filledarrayBy( buf, 1.0, {} ); // $ExpectError - filledarrayBy( buf, false, {} ); // $ExpectError - filledarrayBy( buf, true, {} ); // $ExpectError - filledarrayBy( buf, null, {} ); // $ExpectError - filledarrayBy( buf, undefined, {} ); // $ExpectError - filledarrayBy( buf, [], {} ); // $ExpectError - filledarrayBy( buf, {}, {} ); // $ExpectError - - filledarrayBy( buf, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 'float64', false ); // $ExpectError - filledarrayBy( buf, 'float64', true ); // $ExpectError - filledarrayBy( buf, 'float64', null ); // $ExpectError - filledarrayBy( buf, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 'float64', {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5' ); // $ExpectError - filledarrayBy( buf, 8, 1.0 ); // $ExpectError - filledarrayBy( buf, 8, false ); // $ExpectError - filledarrayBy( buf, 8, true ); // $ExpectError - filledarrayBy( buf, 8, null ); // $ExpectError - filledarrayBy( buf, 8, undefined ); // $ExpectError - filledarrayBy( buf, 8, [] ); // $ExpectError - filledarrayBy( buf, 8, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, false, {} ); // $ExpectError - filledarrayBy( buf, 8, true, {} ); // $ExpectError - filledarrayBy( buf, 8, null, {} ); // $ExpectError - filledarrayBy( buf, 8, undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, [], {} ); // $ExpectError - filledarrayBy( buf, 8, {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 8, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 'float64', false ); // $ExpectError - filledarrayBy( buf, 8, 'float64', true ); // $ExpectError - filledarrayBy( buf, 8, 'float64', null ); // $ExpectError - filledarrayBy( buf, 8, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 8, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 8, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 8, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, '5' ); // $ExpectError - filledarrayBy( buf, 8, 2, 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 2, false ); // $ExpectError - filledarrayBy( buf, 8, 2, true ); // $ExpectError - filledarrayBy( buf, 8, 2, null ); // $ExpectError - filledarrayBy( buf, 8, 2, undefined ); // $ExpectError - filledarrayBy( buf, 8, 2, [] ); // $ExpectError - filledarrayBy( buf, 8, 2, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, false, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, true, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, null, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, [], {} ); // $ExpectError - filledarrayBy( buf, 8, 2, {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', false ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', true ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', null ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', {}, {} ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid length, typed array, array-like object, `ArrayBuffer`, or iterable argument... -{ - filledarrayBy( false, clbk ); // $ExpectError - filledarrayBy( true, clbk ); // $ExpectError - filledarrayBy( null, clbk ); // $ExpectError - filledarrayBy( {}, clbk ); // $ExpectError - - filledarrayBy( false, clbk, {} ); // $ExpectError - filledarrayBy( true, clbk, {} ); // $ExpectError - filledarrayBy( null, clbk, {} ); // $ExpectError - filledarrayBy( {}, clbk, {} ); // $ExpectError - - filledarrayBy( false, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 'float64', clbk ); // $ExpectError - - filledarrayBy( false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, clbk ); // $ExpectError - filledarrayBy( 1.0, 8, clbk ); // $ExpectError - filledarrayBy( false, 8, clbk ); // $ExpectError - filledarrayBy( true, 8, clbk ); // $ExpectError - filledarrayBy( null, 8, clbk ); // $ExpectError - filledarrayBy( undefined, 8, clbk ); // $ExpectError - filledarrayBy( [], 8, clbk ); // $ExpectError - filledarrayBy( {}, 8, clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, clbk ); // $ExpectError - - filledarrayBy( '5', 8, clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, clbk, {} ); // $ExpectError - filledarrayBy( false, 8, clbk, {} ); // $ExpectError - filledarrayBy( true, 8, clbk, {} ); // $ExpectError - filledarrayBy( null, 8, clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, clbk, {} ); // $ExpectError - filledarrayBy( [], 8, clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 'float64', clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( false, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( [], 8, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 'float64', clbk ); // $ExpectError - - filledarrayBy( '5', 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 2, clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 2, clbk ); // $ExpectError - filledarrayBy( false, 8, 2, clbk ); // $ExpectError - filledarrayBy( true, 8, 2, clbk ); // $ExpectError - filledarrayBy( null, 8, 2, clbk ); // $ExpectError - filledarrayBy( undefined, 8, 2, clbk ); // $ExpectError - filledarrayBy( [], 8, 2, clbk ); // $ExpectError - filledarrayBy( {}, 8, 2, clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, clbk ); // $ExpectError - - filledarrayBy( '5', 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( false, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( [], 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, 'float64', clbk ); // $ExpectError - - filledarrayBy( '5', 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a byte offset argument which is not a number... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, false, clbk ); // $ExpectError - filledarrayBy( buf, true, clbk ); // $ExpectError - filledarrayBy( buf, null, clbk ); // $ExpectError - filledarrayBy( buf, [], clbk ); // $ExpectError - filledarrayBy( buf, {}, clbk ); // $ExpectError - - filledarrayBy( buf, false, clbk, {} ); // $ExpectError - filledarrayBy( buf, true, clbk, {} ); // $ExpectError - filledarrayBy( buf, null, clbk, {} ); // $ExpectError - filledarrayBy( buf, [], clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, clbk, {} ); // $ExpectError - - filledarrayBy( buf, '5', 'float64', clbk ); // $ExpectError - filledarrayBy( buf, false, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, true, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, null, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, [], 'float64', clbk ); // $ExpectError - filledarrayBy( buf, {}, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, '5', 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( buf, false, 2, clbk ); // $ExpectError - filledarrayBy( buf, true, 2, clbk ); // $ExpectError - filledarrayBy( buf, null, 2, clbk ); // $ExpectError - filledarrayBy( buf, [], 2, clbk ); // $ExpectError - filledarrayBy( buf, {}, 2, clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, clbk ); // $ExpectError - - filledarrayBy( buf, false, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, clbk, {} ); // $ExpectError - - filledarrayBy( buf, '5', 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, false, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, true, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, null, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, undefined, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, [], 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, {}, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, '5', 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, false, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, undefined, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a view length argument which is not a number... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, 8, false, clbk ); // $ExpectError - filledarrayBy( buf, 8, true, clbk ); // $ExpectError - filledarrayBy( buf, 8, null, clbk ); // $ExpectError - filledarrayBy( buf, 8, [], clbk ); // $ExpectError - filledarrayBy( buf, 8, {}, clbk ); // $ExpectError - - filledarrayBy( buf, 8, false, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, true, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, null, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, [], clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, {}, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, clbk, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5', 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, false, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, true, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, null, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, [], 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, {}, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, 8, '5', 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, [], 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, {}, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided too many arguments... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, 8, 2, 'float64', 1, clbk, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 997a381..0000000 --- a/examples/index.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ).factory; -var dtypes = require( '@stdlib/array-typed-real-dtypes' ); -var filledarrayBy = require( './../lib' ); - -// Create a pseudorandom number generator: -var rand = discreteUniform( 0, 100 ); - -// Get a list of array data types: -var dt = dtypes(); - -// Generate filled arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = filledarrayBy( 10, dt[ i ], rand ); - console.log( arr ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index b1fd829..e1b94a1 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, RealOrComplexTypedArray, DataType } from '@stdlib/types/array'; import { IterableIterator } from '@stdlib/types/iter'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..cb5eca4 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.1.1-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.1.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.1.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.1.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.1.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-ctors@v0.1.0-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill-by@v0.1.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled-by@v0.1.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.1.1-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.1.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@v0.1.1-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.1.0-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";var v=d(),h=u.get("dtypes.default");function g(r,e,t){var i,a;for(i=[],a=-1;!r.next().done;)a+=1,i.push(e.call(t,a));return i}function f(r,e,t){var i;for(i=0;i1)throw new TypeError("invalid arguments. Must provide a length, typed array, array-like object, or an iterable.");if(null===(c=s(j)))throw new TypeError(y("invalid argument. Must provide a recognized data type. Value: `%s`.",j));return new c(0)}if(u<2)throw new TypeError("invalid arguments. Must provide a length, typed array, array-like object, or an iterable.");if(n(arguments[u-=1]))if(n(arguments[u-1])){if(d=arguments[u],b=arguments[u-=1],0===u)throw new TypeError("invalid arguments. Must provide a length, typed array, array-like object, or an iterable.")}else b=arguments[u];else{if(!(u>=2))throw new TypeError("invalid arguments. Must provide a length, typed array, array-like object, or an iterable.");if(d=arguments[u],!n(b=arguments[u-=1]))throw new TypeError(y("invalid argument. Callback argument must be a function. Value: `%s`.",b))}if((u-=1)>=0&&r(arguments[u])?(j=arguments[u],u-=1):j=h,null===(c=s(j)))throw new TypeError(y("invalid argument. Must provide a recognized data type. Value: `%s`.",j));if("generic"===j){if(E=arguments[0],0===u){if(e(E)?x=E:t(E)&&(x=E.length),void 0!==x)return l(x,b,d);if(i(E))throw new Error("invalid arguments. Creating a generic array from an ArrayBuffer is not supported.");if(a(E)){if(!1===v)throw new TypeError(y("invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.",E));if(!n(E[p]))throw new TypeError(y("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",E));if(E=E[p](),!n(E.next))throw new TypeError(y("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",E));return g(E,b,d)}throw new TypeError(y("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",E))}if(i(E))throw new Error("invalid arguments. Creating a generic array from an ArrayBuffer is not supported.");throw new TypeError(y("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",E))}if(0===u)if(t(E=arguments[0]))w=new c(E.length);else if(i(E))w=new c(E);else if(e(E))w=new c(E);else{if(!a(E))throw new TypeError(y("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",E));if(!1===v)throw new TypeError(y("invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.",E));if(!n(E[p]))throw new TypeError(y("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",E));if(E=E[p](),!n(E.next))throw new TypeError(y("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",E));w=new c(m(E))}else w=1===u?new c(arguments[0],arguments[1]):new c(arguments[0],arguments[1],arguments[2]);return w.length>0&&(/^complex/.test(j)?f(w,b,d):o(w.length,w,1,k)),w;function k(r,e){return b.call(d,e)}}export{j as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..35f9b7f --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.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\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport isCollection from '@stdlib/assert-is-collection';\nimport isArrayBuffer from '@stdlib/assert-is-arraybuffer';\nimport isObject from '@stdlib/assert-is-object';\nimport isFunction from '@stdlib/assert-is-function';\nimport ctors from '@stdlib/array-ctors';\nimport gfillBy from '@stdlib/blas-ext-base-gfill-by';\nimport filledArray from '@stdlib/array-base-filled-by';\nimport hasIteratorSymbolSupport from '@stdlib/assert-has-iterator-symbol-support';\nimport ITERATOR_SYMBOL from '@stdlib/symbol-iterator';\nimport iterLength from '@stdlib/iter-length';\nimport defaults from '@stdlib/array-defaults';\nimport format from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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\nexport default filledarrayBy;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","DEFAULT_DTYPE","defaults","get","filledArrayIterator","it","clbk","thisArg","arr","i","next","done","push","call","filledAccessors","length","set","filledarrayBy","nargs","dtype","ctor","len","arg","arguments","ctors","isString","TypeError","format","isFunction","isNonNegativeInteger","isCollection","filledArray","isArrayBuffer","Error","isObject","ITERATOR_SYMBOL","iterLength","test","gfillBy","callback","value","aidx"],"mappings":";;4zCAwCA,IAAIA,EAAsBC,IACtBC,EAAgBC,EAASC,IAAK,kBAclC,SAASC,EAAqBC,EAAIC,EAAMC,GACvC,IAAIC,EACAC,EAKJ,IAFAD,EAAM,GACNC,GAAK,GAEAJ,EAAGK,OACAC,MAGPF,GAAK,EACLD,EAAII,KAAMN,EAAKO,KAAMN,EAASE,IAE/B,OAAOD,CACR,CAWA,SAASM,EAAiBN,EAAKF,EAAMC,GACpC,IAAIE,EACJ,IAAMA,EAAI,EAAGA,EAAID,EAAIO,OAAQN,IAC5BD,EAAIQ,IAAKV,EAAKO,KAAMN,EAASE,GAAKA,GAEnC,OAAOD,CACR,CA4JA,SAASS,IACR,IAAIV,EACAW,EACAC,EACAb,EACAc,EACAZ,EACAa,EACAC,EAKJ,GAAe,KAHfJ,EAAQK,UAAUR,QAKjB,OAAO,IADPK,EAAOI,EAAOvB,IACG,GAIlB,GAAKwB,EADLN,EAAQI,UAAW,IACM,CAExB,GAAKL,EAAQ,EACZ,MAAM,IAAIQ,UAAW,6FAGtB,GAAc,QADdN,EAAOI,EAAOL,IAEb,MAAM,IAAIO,UAAWC,EAAQ,sEAAuER,IAGrG,OAAO,IAAIC,EAAM,EACjB,CAED,GAAKF,EAAQ,EACZ,MAAM,IAAIQ,UAAW,6FAMtB,GAAKE,EAAYL,UAHjBL,GAAS,IAKR,GAAKU,EAAYL,UAAWL,EAAM,KAMjC,GALAX,EAAUgB,UAAWL,GAErBZ,EAAOiB,UADPL,GAAS,GAIM,IAAVA,EACJ,MAAM,IAAIQ,UAAW,kGAItBpB,EAAOiB,UAAWL,OAIf,MAAKA,GAAS,GAUlB,MAAM,IAAIQ,UAAW,6FANrB,GAHAnB,EAAUgB,UAAWL,IAGfU,EADNtB,EAAOiB,UADPL,GAAS,IAGR,MAAM,IAAIQ,UAAWC,EAAQ,uEAAwErB,GAMtG,CAUD,IARAY,GAAS,IACK,GAAKO,EAAUF,UAAWL,KACvCC,EAAQI,UAAWL,GACnBA,GAAS,GAETC,EAAQlB,EAGK,QADdmB,EAAOI,EAAOL,IAEb,MAAM,IAAIO,UAAWC,EAAQ,sEAAuER,IAGrG,GAAe,YAAVA,EAAsB,CAE1B,GADAG,EAAMC,UAAW,GACF,IAAVL,EAAc,CAMlB,GALKW,EAAsBP,GAC1BD,EAAMC,EACKQ,EAAcR,KACzBD,EAAMC,EAAIP,aAEE,IAARM,EACJ,OAAOU,EAAaV,EAAKf,EAAMC,GAEhC,GAAKyB,EAAeV,GACnB,MAAM,IAAIW,MAAO,qFAElB,GAAKC,EAAUZ,GAAQ,CACtB,IAA6B,IAAxBvB,EACJ,MAAM,IAAI2B,UAAWC,EAAQ,sIAAuIL,IAErK,IAAMM,EAAYN,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,wGAAyGL,IAGvI,GADAA,EAAMA,EAAKa,MACLP,EAAYN,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,wGAAyGL,IAEvI,OAAOlB,EAAqBkB,EAAKhB,EAAMC,EACvC,CACD,MAAM,IAAImB,UAAWC,EAAQ,wGAAyGL,GACzI,CAAS,GAAKU,EAAeV,GAC1B,MAAM,IAAIW,MAAO,qFAElB,MAAM,IAAIP,UAAWC,EAAQ,wGAAyGL,GACtI,CACD,GAAe,IAAVJ,EAEJ,GAAKY,EADLR,EAAMC,UAAW,IAEhBf,EAAM,IAAIY,EAAME,EAAIP,aACd,GAAKiB,EAAeV,GAC1Bd,EAAM,IAAIY,EAAME,QACV,GAAKO,EAAsBP,GACjCd,EAAM,IAAIY,EAAME,OACV,KAAKY,EAAUZ,GAarB,MAAM,IAAII,UAAWC,EAAQ,wGAAyGL,IAZtI,IAA6B,IAAxBvB,EACJ,MAAM,IAAI2B,UAAWC,EAAQ,sIAAuIL,IAErK,IAAMM,EAAYN,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,wGAAyGL,IAGvI,GADAA,EAAMA,EAAKa,MACLP,EAAYN,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,wGAAyGL,IAEvId,EAAM,IAAIY,EAAMgB,EAAYd,GAG5B,MAEDd,EADqB,IAAVU,EACL,IAAIE,EAAMG,UAAU,GAAIA,UAAU,IAElC,IAAIH,EAAMG,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKf,EAAIO,OAAS,IACZ,WAAWsB,KAAMlB,GACrBL,EAAiBN,EAAKF,EAAMC,GAE5B+B,EAAS9B,EAAIO,OAAQP,EAAK,EAAG+B,IAGxB/B,EAYP,SAAS+B,EAAUC,EAAOC,GACzB,OAAOnC,EAAKO,KAAMN,EAASkC,EAC3B,CACF"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d115cf0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,192 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -/** -* Create a filled array according to a provided callback function. -* -* @module @stdlib/array-filled-by -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* var arr = filledarrayBy(); -* // returns -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'generic', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( [ 0.5, 0.5 ], clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1; -* } -* -* var arr = filledarrayBy( [ 5, -3 ], 'int32', clbk ); -* // returns [ 1, 1 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk1() { -* return 10; -* } -* -* function clbk2() { -* return 1.0; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, clbk2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk1() { -* return 1.0; -* } -* -* function clbk2() { -* return 2; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, 'uint32', clbk2 ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 'float32', clbk ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, clbk ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, 'int32', clbk ); -* // returns [ 1, 1 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 0f134bb..0000000 --- a/lib/main.js +++ /dev/null @@ -1,414 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var isCollection = require( '@stdlib/assert-is-collection' ); -var isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isObject = require( '@stdlib/assert-is-object' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var ctors = require( '@stdlib/array-ctors' ); -var gfillBy = require( '@stdlib/blas-ext-base-gfill-by' ); -var filledArray = require( '@stdlib/array-base-filled-by' ); -var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var iterLength = require( '@stdlib/iter-length' ); -var defaults = require( '@stdlib/array-defaults' ); -var format = require( '@stdlib/string-format' ); - - -// VARIABLES // - -var HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport(); -var DEFAULT_DTYPE = defaults.get( 'dtypes.default' ); - - -// FUNCTIONS // - -/** -* Creates a filled "generic" array from an iterator. -* -* @private -* @param {Iterable} it - iterator -* @param {Callback} clbk - callback function -* @param {*} thisArg - callback function execution context -* @returns {Array} filled array -*/ -function filledArrayIterator( it, clbk, thisArg ) { - var arr; - var i; - var v; - - arr = []; - i = -1; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - i += 1; - arr.push( clbk.call( thisArg, i ) ); - } - return arr; -} - -/** -* Fills an array exposing accessors for getting and setting array elements. -* -* @private -* @param {Collection} arr - input array -* @param {Callback} clbk - callback function -* @param {*} thisArg - callback function execution context -* @returns {Collection} input array -*/ -function filledAccessors( arr, clbk, thisArg ) { - var i; - for ( i = 0; i < arr.length; i++ ) { - arr.set( clbk.call( thisArg, i ), i ); - } - return arr; -} - - -// MAIN // - -/** -* Creates a filled array according to a provided callback function. -* -* @param {(NonNegativeInteger|TypedArray|ArrayLikeObject|ArrayBuffer|Iterable)} [arg] - a length, typed array, array-like object, buffer, or iterable -* @param {NonNegativeInteger} [byteOffset=0] - byte offset -* @param {NonNegativeInteger} [length] - view length -* @param {string} [dtype="float64"] - data type -* @param {Callback} [clbk] - callback to invoke -* @param {*} [thisArg] - callback execution context -* @throws {TypeError} must provide a recognized data type -* @throws {TypeError} must provide a length, typed array, array-like object, buffer, or iterable -* @throws {TypeError} callback argument must be a function. -* @throws {Error} creating a generic array from an `ArrayBuffer` is not supported -* @returns {(TypedArray|Array)} array or typed array -* -* @example -* var arr = filledarrayBy(); -* // returns -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'generic', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( [ 0.5, 0.5 ], clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1; -* } -* -* var arr = filledarrayBy( [ 5, -3 ], 'int32', clbk ); -* // returns [ 1, 1 ] -* -* @example -* function clbk1() { -* return 10; -* } -* -* function clbk2() { -* return 1.0; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, clbk2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk1() { -* return 1.0; -* } -* -* function clbk2() { -* return 2; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, 'uint32', clbk2 ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 'float32', clbk ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, clbk ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, 'int32', clbk ); -* // returns [ 1, 1 ] -*/ -function filledarrayBy() { - var thisArg; - var nargs; - var dtype; - var clbk; - var ctor; - var arr; - var len; - var arg; - - nargs = arguments.length; - - // If we weren't provided any arguments, return an empty array... - if ( nargs === 0 ) { - ctor = ctors( DEFAULT_DTYPE ); - return new ctor( 0 ); - } - // Check if we were provided a dtype as the first argument... - dtype = arguments[ 0 ]; - if ( isString( dtype ) ) { - // Invoking this function with arguments `f( dtype, clbk[, thisArg] )` is not allowed (otherwise, we'd need to also allow `f( clbk[, thisArg] )`)... - if ( nargs > 1 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( 'invalid argument. Must provide a recognized data type. Value: `%s`.', dtype ) ); - } - // Return an empty array having the specified dtype: - return new ctor( 0 ); - } - // For all other supported invocations, we need at least two arguments... - if ( nargs < 2 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); - } - // At this point, we need to do some argument juggling... - nargs -= 1; // henceforth, the number of available arguments is `nargs+1` - - // Determine whether the last argument is a callback or "this" context... - if ( isFunction( arguments[ nargs ] ) ) { - // 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... - if ( isFunction( arguments[ nargs-1 ] ) ) { - thisArg = arguments[ nargs ]; - nargs -= 1; - clbk = arguments[ nargs ]; - - // Check if we were provided only a callback and a "this" context.. - if ( nargs === 0 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); - } - } else { - // "this" context is left undefined... - clbk = arguments[ nargs ]; - } - } - // 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... - else if ( nargs >= 2 ) { - thisArg = arguments[ nargs ]; - nargs -= 1; - clbk = arguments[ nargs ]; - if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); - } - } - // If were were only provided 2 arguments and the last argument was not a function, we've been provided an insufficient number of arguments... - else { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); - } - // Now that we've processed the callback arguments, let's continue working backward to see if we've been provided a `dtype` argument... - nargs -= 1; - if ( nargs >= 0 && isString( arguments[ nargs ] ) ) { - dtype = arguments[ nargs ]; - nargs -= 1; - } else { - dtype = DEFAULT_DTYPE; - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( 'invalid argument. Must provide a recognized data type. Value: `%s`.', dtype ) ); - } - // At this point, we've resolved the output array data type, and now we can actually create the output array... - if ( dtype === 'generic' ) { - arg = arguments[ 0 ]; - if ( nargs === 0 ) { - if ( isNonNegativeInteger( arg ) ) { - len = arg; - } else if ( isCollection( arg ) ) { - len = arg.length; - } - if ( len !== void 0 ) { - return filledArray( len, clbk, thisArg ); - } - if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); - } - if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); - } - return filledArrayIterator( arg, clbk, thisArg ); - } - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); - } else if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); - } - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); - } - if ( nargs === 0 ) { // length || array-like || ArrayBuffer || iterable - arg = arguments[ 0 ]; - if ( isCollection( arg ) ) { - arr = new ctor( arg.length ); - } else if ( isArrayBuffer( arg ) ) { - arr = new ctor( arg ); - } else if ( isNonNegativeInteger( arg ) ) { - arr = new ctor( arg ); - } else if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); - } - arr = new ctor( iterLength( arg ) ); - } else { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); - } - } else if ( nargs === 1 ) { - arr = new ctor( arguments[0], arguments[1] ); // (ArrayBuffer, byteOffset) - } else { - arr = new ctor( arguments[0], arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset, length) - } - if ( arr.length > 0 ) { - if ( /^complex/.test( dtype ) ) { - filledAccessors( arr, clbk, thisArg ); - } else { - gfillBy( arr.length, arr, 1, callback ); - } - } - return arr; - - /** - * Callback which wraps a provided callback and is invoked for each array element. - * - * @private - * @param {*} value - element value - * @param {NonNegativeInteger} aidx - array index - * @param {NonNegativeInteger} sidx - strided index - * @param {Collection} array - input array/collection - * @returns {*} callback return value - */ - function callback( value, aidx ) { - return clbk.call( thisArg, aidx ); - } -} - - -// EXPORTS // - -module.exports = filledarrayBy; diff --git a/package.json b/package.json index 77f78c8..67155f1 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Create a filled array according to a provided callback function.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,70 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-filled-by": "^0.1.0", - "@stdlib/array-ctors": "^0.1.0", - "@stdlib/array-defaults": "^0.1.0", - "@stdlib/assert-has-iterator-symbol-support": "^0.1.1", - "@stdlib/assert-is-arraybuffer": "^0.1.1", - "@stdlib/assert-is-collection": "^0.1.0", - "@stdlib/assert-is-function": "^0.1.1", - "@stdlib/assert-is-nonnegative-integer": "^0.1.0", - "@stdlib/assert-is-object": "^0.1.1", - "@stdlib/assert-is-string": "^0.1.1", - "@stdlib/blas-ext-base-gfill-by": "^0.1.0", - "@stdlib/iter-length": "^0.1.1", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1", - "@stdlib/symbol-iterator": "^0.1.1", - "@stdlib/types": "^0.2.0" - }, - "devDependencies": { - "@stdlib/array-buffer": "^0.1.0", - "@stdlib/array-complex128": "^0.1.0", - "@stdlib/array-complex64": "^0.1.0", - "@stdlib/array-float32": "^0.1.1", - "@stdlib/array-float64": "^0.1.1", - "@stdlib/array-int16": "^0.1.1", - "@stdlib/array-int32": "^0.1.1", - "@stdlib/array-int8": "^0.1.1", - "@stdlib/array-typed-real-dtypes": "^0.1.1", - "@stdlib/array-uint16": "^0.1.1", - "@stdlib/array-uint32": "^0.1.1", - "@stdlib/array-uint8": "^0.1.1", - "@stdlib/array-uint8c": "^0.1.1", - "@stdlib/assert-instance-of": "^0.1.1", - "@stdlib/assert-is-array": "^0.1.1", - "@stdlib/assert-is-typed-array": "^0.1.0", - "@stdlib/assert-is-typed-array-like": "^0.1.0", - "@stdlib/complex-float32": "^0.1.1", - "@stdlib/complex-float64": "^0.1.1", - "@stdlib/iter-constant": "^0.1.0", - "@stdlib/math-base-special-pow": "^0.1.0", - "@stdlib/random-base-discrete-uniform": "^0.1.0", - "@stdlib/strided-base-reinterpret-complex128": "^0.1.1", - "@stdlib/strided-base-reinterpret-complex64": "^0.1.1", - "@stdlib/utils-constant-function": "^0.1.1", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.1.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..376b877 --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index b55aa4a..0000000 --- a/test/test.js +++ /dev/null @@ -1,4248 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 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. -*/ - -/* eslint-disable max-len */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -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 ArrayBuffer = require( '@stdlib/array-buffer' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var iterConstant = require( '@stdlib/iter-constant' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var filledarrayBy = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': !hasIteratorSymbolSupport() -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof filledarrayBy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if only provided callback arguments', function test( t ) { - t.throws( clbk1, TypeError, 'throws an error' ); - t.throws( clbk2, TypeError, 'throws an error' ); - t.throws( clbk3, TypeError, 'throws an error' ); - t.end(); - - function clbk1() { - filledarrayBy( constantFunction( 1.0 ) ); - } - - function clbk2() { - filledarrayBy( constantFunction( 1.0 ), {} ); - } - - function clbk3() { - filledarrayBy( constantFunction( 1.0 ), constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (only argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (typed array; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (array-like object)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (array-like object; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 8 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 8 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, 1, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (iterator)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( iterConstant( 1.0 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (iterator; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( iterConstant( 1.0 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if only provided data type and callback arguments', function test( t ) { - t.throws( clbk1, TypeError, 'throws an error' ); - t.throws( clbk2, TypeError, 'throws an error' ); - t.throws( clbk3, TypeError, 'throws an error' ); - t.end(); - - function clbk1() { - filledarrayBy( 'float64', constantFunction( 1.0 ) ); - } - - function clbk2() { - filledarrayBy( 'float64', constantFunction( 1.0 ), {} ); - } - - function clbk3() { - filledarrayBy( 'float64', constantFunction( 1.0 ), constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (array-like object)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (array-like object; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, 1, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, 1, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (no iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (no iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (non-function iterator symbol property)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (non-function iterator symbol property; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (`next` property is not a function)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ) ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (`next` property is not a function; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ), {} ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (no iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (no iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (non-function iterator symbol property)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (non-function iterator symbol property; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (`next` property is not a function)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ) ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (`next` property is not a function; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ), {} ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 1, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 1, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function returns a filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - arr = filledarrayBy(); - - t.strictEqual( instanceOf( arr, Float64Array ), 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=float64)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - arr = filledarrayBy( 'float64' ); - - t.strictEqual( instanceOf( arr, Float64Array ), 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=float32)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( 0 ); - arr = filledarrayBy( 'float32' ); - - t.strictEqual( instanceOf( arr, Float32Array ), 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; - - expected = new Complex128Array( 0 ); - arr = filledarrayBy( 'complex128' ); - - t.strictEqual( instanceOf( arr, Complex128Array ), 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=complex64)', function test( t ) { - var expected; - var arr; - - expected = new Complex64Array( 0 ); - arr = filledarrayBy( 'complex64' ); - - t.strictEqual( instanceOf( arr, Complex64Array ), 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=int32)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( 0 ); - arr = filledarrayBy( 'int32' ); - - t.strictEqual( instanceOf( arr, Int32Array ), 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=uint32)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( 0 ); - arr = filledarrayBy( 'uint32' ); - - t.strictEqual( instanceOf( arr, Uint32Array ), 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=int16)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( 0 ); - arr = filledarrayBy( 'int16' ); - - t.strictEqual( instanceOf( arr, Int16Array ), 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=uint16)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( 0 ); - arr = filledarrayBy( 'uint16' ); - - t.strictEqual( instanceOf( arr, Uint16Array ), 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=int8)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( 0 ); - arr = filledarrayBy( 'int8' ); - - t.strictEqual( instanceOf( arr, Int8Array ), 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=uint8)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( 0 ); - arr = filledarrayBy( 'uint8' ); - - t.strictEqual( instanceOf( arr, Uint8Array ), 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=uint8c)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( 0 ); - arr = filledarrayBy( 'uint8c' ); - - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), 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=generic)', function test( t ) { - var expected; - var arr; - - expected = []; - arr = filledarrayBy( 'generic' ); - - t.strictEqual( instanceOf( arr, Array ), 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 (default, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, length=0)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array(); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 0, clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, clbk, ctx ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (default, length; thisArg=function)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, clbk, context ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this(); // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } - - function context() { - ctx.count += 1; - } -}); - -tape( 'the function returns a filled array (dtype=float64, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, 'float64', clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, length; thisArg=function)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, 'float64', clbk, context ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this(); // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } - - function context() { - ctx.count += 1; - } -}); - -tape( 'the function returns a filled array (dtype=float32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, 'float32', clbk ); - - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex128, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = filledarrayBy( 5, 'complex128', clbk ); - - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = filledarrayBy( 5, 'complex64', clbk ); - - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int32Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int32', clbk ); - - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint32Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint32', clbk ); - - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int16Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int16', clbk ); - - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint16', clbk ); - - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int8Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int8', clbk ); - - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint8', clbk ); - - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint8c', clbk ); - - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = [ 1, 1, 1, 1, 1 ]; - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'generic', clbk ); - - t.strictEqual( instanceOf( arr, Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex128, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = [ 1.0, 2.0 ]; - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = [ 1.0, 2.0 ]; - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int32', clbk ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, typed array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, typed array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex128, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = new Float64Array( [ 1.0, 2.0 ] ); - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = new Float64Array( [ 1.0, 2.0 ] ); - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (default, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex128, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer, byteoffset; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer, byteoffset; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, 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; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 48 ); - out = filledarrayBy( buf, 16, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 24 ); - out = filledarrayBy( buf, 8, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int32', clbk ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint8c', clbk ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, 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; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 64 ); - out = filledarrayBy( buf, 16, 2, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset, length)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 1, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 1, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled array (default, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, iterator; thisArg)', opts, function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - ctx = { - 'count': 0 - }; - indices = []; - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, iterator; thisArg)', opts, function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - ctx = { - 'count': 0 - }; - indices = []; - out = filledarrayBy( arr, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex128, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = iterConstant( new Complex128( 3.0, 3.0 ), { - 'iter': 2 - }); - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = iterConstant( new Complex64( 3.0, 3.0 ), { - 'iter': 2 - }); - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); From 889d425779ca458eaa825894e7ab448a1c089e9b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 15 Feb 2024 01:29:03 +0000 Subject: [PATCH 041/117] Transform error messages --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d009fb9..e26c31a 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "@stdlib/assert-is-string": "^0.2.0", "@stdlib/blas-ext-base-gfill-by": "^0.2.0", "@stdlib/iter-length": "^0.2.0", - "@stdlib/string-format": "^0.2.0", + "@stdlib/error-tools-fmtprodmsg": "^0.2.0", "@stdlib/symbol-iterator": "^0.2.0", "@stdlib/types": "^0.3.1" }, From 4b817c67ea16e2c342c0cbfe32566de1388b4268 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 15 Feb 2024 04:54:43 +0000 Subject: [PATCH 042/117] Remove files --- index.d.ts | 426 ---- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6608 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index e1b94a1..0000000 --- a/index.d.ts +++ /dev/null @@ -1,426 +0,0 @@ -/* -* @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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, RealOrComplexTypedArray, DataType } from '@stdlib/types/array'; -import { IterableIterator } from '@stdlib/types/iter'; - -/** -* Array or typed array. -*/ -type ArrayOrTypedArray = Array | RealOrComplexTypedArray; - -/** -* Nullary callback function. -* -* @returns fill value -*/ -type Nullary = () => any; - -/** -* Unary callback function. -* -* @param i - current array index -* @returns fill value -*/ -type Unary = ( i: number ) => any; - -/** -* Callback function. -* -* @param i - current array index -* @returns fill value -*/ -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 -* -* @example -* var arr = filledarrayBy(); -* // returns -* -* @example -* var arr = filledarrayBy( 'float32' ); -* // returns -*/ -declare function filledarrayBy( dtype?: DataType ): ArrayOrTypedArray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Creates a filled array according to a provided callback function and having a specified `length`. -* -* @param length - array length -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* -* var arr = filledarrayBy( 5, constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( length: number, clbk: Callback, thisArg?: any ): ArrayOrTypedArray; - -/** -* 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 -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* -* var arr = filledarrayBy( 5, 'float64', constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( length: number, dtype: DataType, clbk: Callback, thisArg?: any ): ArrayOrTypedArray; - -/** -* Creates a filled array from another `array` according to a provided callback function. -* -* @param array - typed array or array-like object -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* -* 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; - -/** -* 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 -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* -* 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; - -/** -* Creates a filled array from an iterable according to a callback function. -* -* @param iterable - iterable -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var iterConstant = require( '@stdlib/iter-constant' ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarrayBy( it, constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( iterable: IterableIterator, callback: Callback, thisArg?: any ): ArrayOrTypedArray; - -/** -* 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 -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var iterConstant = require( '@stdlib/iter-constant' ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* 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; - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; - -/** -* 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. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; - -/** -* 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. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; - -/** -* 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. -* -* @param buffer - `ArrayBuffer` -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; - - -// EXPORTS // - -export = filledarrayBy; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index cb5eca4..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.1.1-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.1.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.1.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.1.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.1.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-ctors@v0.1.0-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill-by@v0.1.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled-by@v0.1.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.1.1-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.1.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@v0.1.1-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.1.0-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";var v=d(),h=u.get("dtypes.default");function g(r,e,t){var i,a;for(i=[],a=-1;!r.next().done;)a+=1,i.push(e.call(t,a));return i}function f(r,e,t){var i;for(i=0;i1)throw new TypeError("invalid arguments. Must provide a length, typed array, array-like object, or an iterable.");if(null===(c=s(j)))throw new TypeError(y("invalid argument. Must provide a recognized data type. Value: `%s`.",j));return new c(0)}if(u<2)throw new TypeError("invalid arguments. Must provide a length, typed array, array-like object, or an iterable.");if(n(arguments[u-=1]))if(n(arguments[u-1])){if(d=arguments[u],b=arguments[u-=1],0===u)throw new TypeError("invalid arguments. Must provide a length, typed array, array-like object, or an iterable.")}else b=arguments[u];else{if(!(u>=2))throw new TypeError("invalid arguments. Must provide a length, typed array, array-like object, or an iterable.");if(d=arguments[u],!n(b=arguments[u-=1]))throw new TypeError(y("invalid argument. Callback argument must be a function. Value: `%s`.",b))}if((u-=1)>=0&&r(arguments[u])?(j=arguments[u],u-=1):j=h,null===(c=s(j)))throw new TypeError(y("invalid argument. Must provide a recognized data type. Value: `%s`.",j));if("generic"===j){if(E=arguments[0],0===u){if(e(E)?x=E:t(E)&&(x=E.length),void 0!==x)return l(x,b,d);if(i(E))throw new Error("invalid arguments. Creating a generic array from an ArrayBuffer is not supported.");if(a(E)){if(!1===v)throw new TypeError(y("invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.",E));if(!n(E[p]))throw new TypeError(y("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",E));if(E=E[p](),!n(E.next))throw new TypeError(y("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",E));return g(E,b,d)}throw new TypeError(y("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",E))}if(i(E))throw new Error("invalid arguments. Creating a generic array from an ArrayBuffer is not supported.");throw new TypeError(y("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",E))}if(0===u)if(t(E=arguments[0]))w=new c(E.length);else if(i(E))w=new c(E);else if(e(E))w=new c(E);else{if(!a(E))throw new TypeError(y("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",E));if(!1===v)throw new TypeError(y("invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.",E));if(!n(E[p]))throw new TypeError(y("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",E));if(E=E[p](),!n(E.next))throw new TypeError(y("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",E));w=new c(m(E))}else w=1===u?new c(arguments[0],arguments[1]):new c(arguments[0],arguments[1],arguments[2]);return w.length>0&&(/^complex/.test(j)?f(w,b,d):o(w.length,w,1,k)),w;function k(r,e){return b.call(d,e)}}export{j as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 35f9b7f..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.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\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport isCollection from '@stdlib/assert-is-collection';\nimport isArrayBuffer from '@stdlib/assert-is-arraybuffer';\nimport isObject from '@stdlib/assert-is-object';\nimport isFunction from '@stdlib/assert-is-function';\nimport ctors from '@stdlib/array-ctors';\nimport gfillBy from '@stdlib/blas-ext-base-gfill-by';\nimport filledArray from '@stdlib/array-base-filled-by';\nimport hasIteratorSymbolSupport from '@stdlib/assert-has-iterator-symbol-support';\nimport ITERATOR_SYMBOL from '@stdlib/symbol-iterator';\nimport iterLength from '@stdlib/iter-length';\nimport defaults from '@stdlib/array-defaults';\nimport format from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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\nexport default filledarrayBy;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","DEFAULT_DTYPE","defaults","get","filledArrayIterator","it","clbk","thisArg","arr","i","next","done","push","call","filledAccessors","length","set","filledarrayBy","nargs","dtype","ctor","len","arg","arguments","ctors","isString","TypeError","format","isFunction","isNonNegativeInteger","isCollection","filledArray","isArrayBuffer","Error","isObject","ITERATOR_SYMBOL","iterLength","test","gfillBy","callback","value","aidx"],"mappings":";;4zCAwCA,IAAIA,EAAsBC,IACtBC,EAAgBC,EAASC,IAAK,kBAclC,SAASC,EAAqBC,EAAIC,EAAMC,GACvC,IAAIC,EACAC,EAKJ,IAFAD,EAAM,GACNC,GAAK,GAEAJ,EAAGK,OACAC,MAGPF,GAAK,EACLD,EAAII,KAAMN,EAAKO,KAAMN,EAASE,IAE/B,OAAOD,CACR,CAWA,SAASM,EAAiBN,EAAKF,EAAMC,GACpC,IAAIE,EACJ,IAAMA,EAAI,EAAGA,EAAID,EAAIO,OAAQN,IAC5BD,EAAIQ,IAAKV,EAAKO,KAAMN,EAASE,GAAKA,GAEnC,OAAOD,CACR,CA4JA,SAASS,IACR,IAAIV,EACAW,EACAC,EACAb,EACAc,EACAZ,EACAa,EACAC,EAKJ,GAAe,KAHfJ,EAAQK,UAAUR,QAKjB,OAAO,IADPK,EAAOI,EAAOvB,IACG,GAIlB,GAAKwB,EADLN,EAAQI,UAAW,IACM,CAExB,GAAKL,EAAQ,EACZ,MAAM,IAAIQ,UAAW,6FAGtB,GAAc,QADdN,EAAOI,EAAOL,IAEb,MAAM,IAAIO,UAAWC,EAAQ,sEAAuER,IAGrG,OAAO,IAAIC,EAAM,EACjB,CAED,GAAKF,EAAQ,EACZ,MAAM,IAAIQ,UAAW,6FAMtB,GAAKE,EAAYL,UAHjBL,GAAS,IAKR,GAAKU,EAAYL,UAAWL,EAAM,KAMjC,GALAX,EAAUgB,UAAWL,GAErBZ,EAAOiB,UADPL,GAAS,GAIM,IAAVA,EACJ,MAAM,IAAIQ,UAAW,kGAItBpB,EAAOiB,UAAWL,OAIf,MAAKA,GAAS,GAUlB,MAAM,IAAIQ,UAAW,6FANrB,GAHAnB,EAAUgB,UAAWL,IAGfU,EADNtB,EAAOiB,UADPL,GAAS,IAGR,MAAM,IAAIQ,UAAWC,EAAQ,uEAAwErB,GAMtG,CAUD,IARAY,GAAS,IACK,GAAKO,EAAUF,UAAWL,KACvCC,EAAQI,UAAWL,GACnBA,GAAS,GAETC,EAAQlB,EAGK,QADdmB,EAAOI,EAAOL,IAEb,MAAM,IAAIO,UAAWC,EAAQ,sEAAuER,IAGrG,GAAe,YAAVA,EAAsB,CAE1B,GADAG,EAAMC,UAAW,GACF,IAAVL,EAAc,CAMlB,GALKW,EAAsBP,GAC1BD,EAAMC,EACKQ,EAAcR,KACzBD,EAAMC,EAAIP,aAEE,IAARM,EACJ,OAAOU,EAAaV,EAAKf,EAAMC,GAEhC,GAAKyB,EAAeV,GACnB,MAAM,IAAIW,MAAO,qFAElB,GAAKC,EAAUZ,GAAQ,CACtB,IAA6B,IAAxBvB,EACJ,MAAM,IAAI2B,UAAWC,EAAQ,sIAAuIL,IAErK,IAAMM,EAAYN,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,wGAAyGL,IAGvI,GADAA,EAAMA,EAAKa,MACLP,EAAYN,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,wGAAyGL,IAEvI,OAAOlB,EAAqBkB,EAAKhB,EAAMC,EACvC,CACD,MAAM,IAAImB,UAAWC,EAAQ,wGAAyGL,GACzI,CAAS,GAAKU,EAAeV,GAC1B,MAAM,IAAIW,MAAO,qFAElB,MAAM,IAAIP,UAAWC,EAAQ,wGAAyGL,GACtI,CACD,GAAe,IAAVJ,EAEJ,GAAKY,EADLR,EAAMC,UAAW,IAEhBf,EAAM,IAAIY,EAAME,EAAIP,aACd,GAAKiB,EAAeV,GAC1Bd,EAAM,IAAIY,EAAME,QACV,GAAKO,EAAsBP,GACjCd,EAAM,IAAIY,EAAME,OACV,KAAKY,EAAUZ,GAarB,MAAM,IAAII,UAAWC,EAAQ,wGAAyGL,IAZtI,IAA6B,IAAxBvB,EACJ,MAAM,IAAI2B,UAAWC,EAAQ,sIAAuIL,IAErK,IAAMM,EAAYN,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,wGAAyGL,IAGvI,GADAA,EAAMA,EAAKa,MACLP,EAAYN,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,wGAAyGL,IAEvId,EAAM,IAAIY,EAAMgB,EAAYd,GAG5B,MAEDd,EADqB,IAAVU,EACL,IAAIE,EAAMG,UAAU,GAAIA,UAAU,IAElC,IAAIH,EAAMG,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKf,EAAIO,OAAS,IACZ,WAAWsB,KAAMlB,GACrBL,EAAiBN,EAAKF,EAAMC,GAE5B+B,EAAS9B,EAAIO,OAAQP,EAAK,EAAG+B,IAGxB/B,EAYP,SAAS+B,EAAUC,EAAOC,GACzB,OAAOnC,EAAKO,KAAMN,EAASkC,EAC3B,CACF"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 376b877..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From ae71c729fba71d0a240ac26763d2502976eb8ddd Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 15 Feb 2024 04:56:00 +0000 Subject: [PATCH 043/117] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 255 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 132 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 228 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 47 +- SECURITY.md | 5 - benchmark/benchmark.js | 319 -- benchmark/benchmark.length.complex128.js | 98 - benchmark/benchmark.length.complex64.js | 98 - benchmark/benchmark.length.float32.js | 97 - benchmark/benchmark.length.float64.js | 97 - benchmark/benchmark.length.generic.js | 97 - benchmark/benchmark.length.int16.js | 97 - benchmark/benchmark.length.int32.js | 97 - benchmark/benchmark.length.int8.js | 97 - benchmark/benchmark.length.uint16.js | 97 - benchmark/benchmark.length.uint32.js | 97 - benchmark/benchmark.length.uint8.js | 97 - benchmark/benchmark.length.uint8c.js | 97 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 174 - docs/types/test.ts | 606 -- examples/index.js | 37 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 192 - lib/main.js | 414 -- package.json | 91 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 4248 -------------- 54 files changed, 6204 insertions(+), 10550 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.length.complex128.js delete mode 100644 benchmark/benchmark.length.complex64.js delete mode 100644 benchmark/benchmark.length.float32.js delete mode 100644 benchmark/benchmark.length.float64.js delete mode 100644 benchmark/benchmark.length.generic.js delete mode 100644 benchmark/benchmark.length.int16.js delete mode 100644 benchmark/benchmark.length.int32.js delete mode 100644 benchmark/benchmark.length.int8.js delete mode 100644 benchmark/benchmark.length.uint16.js delete mode 100644 benchmark/benchmark.length.uint32.js delete mode 100644 benchmark/benchmark.length.uint8.js delete mode 100644 benchmark/benchmark.length.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 8be0b82..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index f988046..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 82b4a10..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '42 6 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 9106b5d..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -293,7 +284,7 @@ for ( i = 0; i < dt.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -364,9 +355,9 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/filled]: https://github.com/stdlib-js/array-filled +[@stdlib/array/filled]: https://github.com/stdlib-js/array-filled/tree/esm -[@stdlib/array/typed]: https://github.com/stdlib-js/array-typed +[@stdlib/array/typed]: https://github.com/stdlib-js/array-typed/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 67ba493..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,319 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); -var isArray = require( '@stdlib/assert-is-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var pkg = require( './../package.json' ).name; -var filledarrayBy = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 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=float64', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'float64', 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=float32', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'float32', 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; - var i; - - clbk = constantFunction( new Complex128( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'complex128', 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=complex64', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( new Complex64( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'complex64', 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=int32', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int32', 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=uint32', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint32', 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=int16', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int16', 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=uint16', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint16', 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=int8', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int8', 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=uint8', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint8', 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=uint8c', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint8c', 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=generic', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'generic', clbk ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.length.complex128.js b/benchmark/benchmark.length.complex128.js deleted file mode 100644 index 27f6c66..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 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 Complex128 = require( '@stdlib/complex-float64' ); -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( new Complex128( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'complex128', 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=complex128,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.complex64.js b/benchmark/benchmark.length.complex64.js deleted file mode 100644 index c094ae9..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 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 Complex64 = require( '@stdlib/complex-float32' ); -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( new Complex64( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'complex64', 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=complex64,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.float32.js b/benchmark/benchmark.length.float32.js deleted file mode 100644 index d2b2ba7..0000000 --- a/benchmark/benchmark.length.float32.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'float32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=float32,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.float64.js b/benchmark/benchmark.length.float64.js deleted file mode 100644 index 65064e3..0000000 --- a/benchmark/benchmark.length.float64.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'float64', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=float64,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.generic.js b/benchmark/benchmark.length.generic.js deleted file mode 100644 index eb87dfa..0000000 --- a/benchmark/benchmark.length.generic.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isArray = require( '@stdlib/assert-is-array' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'generic', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isArray( 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=generic,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int16.js b/benchmark/benchmark.length.int16.js deleted file mode 100644 index 914ff7c..0000000 --- a/benchmark/benchmark.length.int16.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int16', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=int16,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int32.js b/benchmark/benchmark.length.int32.js deleted file mode 100644 index cc0f678..0000000 --- a/benchmark/benchmark.length.int32.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=int32,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int8.js b/benchmark/benchmark.length.int8.js deleted file mode 100644 index 77553b0..0000000 --- a/benchmark/benchmark.length.int8.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int8', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=int8,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint16.js b/benchmark/benchmark.length.uint16.js deleted file mode 100644 index c68efdd..0000000 --- a/benchmark/benchmark.length.uint16.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint16', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint16,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint32.js b/benchmark/benchmark.length.uint32.js deleted file mode 100644 index 27c1742..0000000 --- a/benchmark/benchmark.length.uint32.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint32,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint8.js b/benchmark/benchmark.length.uint8.js deleted file mode 100644 index 2a26be4..0000000 --- a/benchmark/benchmark.length.uint8.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint8', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint8,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint8c.js b/benchmark/benchmark.length.uint8c.js deleted file mode 100644 index dd6e8c2..0000000 --- a/benchmark/benchmark.length.uint8c.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint8c', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint8c,len='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index c138144..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by" -%% click B href "https://github.com/stdlib-js/array-filled-by/tree/main" -%% click C href "https://github.com/stdlib-js/array-filled-by/tree/production" -%% click D href "https://github.com/stdlib-js/array-filled-by/tree/esm" -%% click E href "https://github.com/stdlib-js/array-filled-by/tree/deno" -%% click F href "https://github.com/stdlib-js/array-filled-by/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by -[production-url]: https://github.com/stdlib-js/array-filled-by/tree/production -[deno-url]: https://github.com/stdlib-js/array-filled-by/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-filled-by/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-filled-by/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-filled-by/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-filled-by/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-filled-by/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 188fc9b..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import filledarrayBy from '../docs/types/index'; -export = filledarrayBy; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 468e99c..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"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 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 00888a2..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "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,EAAQ,UAAU,OAGbA,IAAU,EACd,OAAAE,EAAOrB,EAAOS,CAAc,EACrB,IAAIY,EAAM,CAAE,EAIpB,GADAD,EAAQ,UAAW,CAAE,EAChB1B,EAAU0B,CAAM,EAAI,CAExB,GAAKD,EAAQ,EACZ,MAAM,IAAI,UAAW,2FAA4F,EAGlH,GADAE,EAAOrB,EAAOoB,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWd,EAAQ,sEAAuEa,CAAM,CAAE,EAG7G,OAAO,IAAIC,EAAM,CAAE,CACpB,CAEA,GAAKF,EAAQ,EACZ,MAAM,IAAI,UAAW,2FAA4F,EAMlH,GAHAA,GAAS,EAGJpB,EAAY,UAAWoB,CAAM,CAAE,EAEnC,GAAKpB,EAAY,UAAWoB,EAAM,CAAE,CAAE,GAMrC,GALAN,EAAU,UAAWM,CAAM,EAC3BA,GAAS,EACTP,EAAO,UAAWO,CAAM,EAGnBA,IAAU,EACd,MAAM,IAAI,UAAW,2FAA4F,OAIlHP,EAAO,UAAWO,CAAM,UAIhBA,GAAS,GAIlB,GAHAN,EAAU,UAAWM,CAAM,EAC3BA,GAAS,EACTP,EAAO,UAAWO,CAAM,EACnB,CAACpB,EAAYa,CAAK,EACtB,MAAM,IAAI,UAAWL,EAAQ,uEAAwEK,CAAK,CAAE,MAK7G,OAAM,IAAI,UAAW,2FAA4F,EAWlH,GARAO,GAAS,EACJA,GAAS,GAAKzB,EAAU,UAAWyB,CAAM,CAAE,GAC/CC,EAAQ,UAAWD,CAAM,EACzBA,GAAS,GAETC,EAAQX,EAETY,EAAOrB,EAAOoB,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWd,EAAQ,sEAAuEa,CAAM,CAAE,EAG7G,GAAKA,IAAU,UAAY,CAE1B,GADAG,EAAM,UAAW,CAAE,EACdJ,IAAU,EAAI,CAMlB,GALKxB,EAAsB4B,CAAI,EAC9BD,EAAMC,EACK3B,EAAc2B,CAAI,IAC7BD,EAAMC,EAAI,QAEND,IAAQ,OACZ,OAAOpB,EAAaoB,EAAKV,EAAMC,CAAQ,EAExC,GAAKhB,EAAe0B,CAAI,EACvB,MAAM,IAAI,MAAO,mFAAoF,EAEtG,GAAKzB,EAAUyB,CAAI,EAAI,CACtB,GAAKf,IAAwB,GAC5B,MAAM,IAAI,UAAWD,EAAQ,sIAAuIgB,CAAI,CAAE,EAE3K,GAAK,CAACxB,EAAYwB,EAAKnB,CAAgB,CAAE,EACxC,MAAM,IAAI,UAAWG,EAAQ,wGAAyGgB,CAAI,CAAE,EAG7I,GADAA,EAAMA,EAAKnB,CAAgB,EAAE,EACxB,CAACL,EAAYwB,EAAI,IAAK,EAC1B,MAAM,IAAI,UAAWhB,EAAQ,wGAAyGgB,CAAI,CAAE,EAE7I,OAAOb,EAAqBa,EAAKX,EAAMC,CAAQ,CAChD,CACA,MAAM,IAAI,UAAWN,EAAQ,wGAAyGgB,CAAI,CAAE,CAC7I,SAAY1B,EAAe0B,CAAI,EAC9B,MAAM,IAAI,MAAO,mFAAoF,EAEtG,MAAM,IAAI,UAAWhB,EAAQ,wGAAyGgB,CAAI,CAAE,CAC7I,CACA,GAAKJ,IAAU,EAEd,GADAI,EAAM,UAAW,CAAE,EACd3B,EAAc2B,CAAI,EACtBT,EAAM,IAAIO,EAAME,EAAI,MAAO,UAChB1B,EAAe0B,CAAI,EAC9BT,EAAM,IAAIO,EAAME,CAAI,UACT5B,EAAsB4B,CAAI,EACrCT,EAAM,IAAIO,EAAME,CAAI,UACTzB,EAAUyB,CAAI,EAAI,CAC7B,GAAKf,IAAwB,GAC5B,MAAM,IAAI,UAAWD,EAAQ,sIAAuIgB,CAAI,CAAE,EAE3K,GAAK,CAACxB,EAAYwB,EAAKnB,CAAgB,CAAE,EACxC,MAAM,IAAI,UAAWG,EAAQ,wGAAyGgB,CAAI,CAAE,EAG7I,GADAA,EAAMA,EAAKnB,CAAgB,EAAE,EACxB,CAACL,EAAYwB,EAAI,IAAK,EAC1B,MAAM,IAAI,UAAWhB,EAAQ,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"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 5a68984..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,174 +0,0 @@ - -{{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) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr = {{alias}}() - - > arr = {{alias}}( 'float32' ) - - - -{{alias}}( length[, dtype], clbk[, thisArg] ) - Returns a filled array according to a provided callback function and having - a specified length. - - Parameters - ---------- - length: integer - Array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > function clbk() { return 1.0; }; - > var arr = {{alias}}( 5, clbk ) - [ 1.0, 1.0, 1.0, 1.0, 1.0 ] - > arr = {{alias}}( 5, 'int32', clbk ) - [ 1, 1, 1, 1, 1 ] - - -{{alias}}( array[, dtype], clbk[, thisArg] ) - Creates a filled array from another array (or array-like object) according - to a provided callback function. - - Parameters - ---------- - array: ArrayLikeObject - Array from which to generate another array. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias}}( [ 0.5, 0.5, 0.5 ], {{alias:@stdlib/utils/constant-function}}( 2.0 ) ) - [ 2.0, 2.0, 2.0 ] - > var arr2 = {{alias}}( arr1, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( iterable[, dtype], clbk[, thisArg] ) - Creates a filled array from an iterable according to a provided callback - function. - - Parameters - ---------- - iterable: Iterable - Iterable from which to generate an array. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias:@stdlib/iter/constant}}( 3.0, {'iter': 3} ); - > var arr2 = {{alias}}( arr1, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( buffer[, byteOffset[, length]][, dtype], clbk[, thisArg] ) - Returns a filled typed array view of an ArrayBuffer according to a provided - callback function. - - The 'generic' array data type is *not* supported. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( buf, 0, 4, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0, 1.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 394ac49..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,606 +0,0 @@ -/* -* @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. -*/ - -/// - -import { IterableIterator } from '@stdlib/types/iter'; -import filledarrayBy = require( './index' ); - - -/** -* Returns an iterator protocol-compliant object. -* -* @returns iterator protocol-compliant object -*/ -function iterator(): IterableIterator { - const obj: IterableIterator = { - [Symbol.iterator]: iterator, - 'next': next - }; - return obj; -} - -/** -* Implements the iterator protocol `next` method. -* -* @returns iterator protocol-compliant object -*/ -function next(): any { - return { - 'value': 1.0, - 'done': false - }; -} - -/** -* Callback function. -* -* @param i - current array index -* @returns return value -*/ -function clbk( i: number ): number { - return i; -} - - -// TESTS // - -// The function returns an array or typed array... -{ - filledarrayBy(); // $ExpectType ArrayOrTypedArray - filledarrayBy( 'float32' ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( 10, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( 10, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( 10, 'int32', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( 10, 'int32', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const x = new Float64Array( 10 ); - filledarrayBy( x, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( x, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( x, 'uint8', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( x, 'uint8', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const y = [ 2.0, 2.0, 2.0 ]; - filledarrayBy( y, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( y, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( y, 'float64', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( y, 'float64', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const it = iterator(); - filledarrayBy( it, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( it, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( it, 'uint8c', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( it, 'uint8c', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const buf = new ArrayBuffer( 32 ); - filledarrayBy( buf, clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 'uint32', clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 'uint32', clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 8, clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 8, clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 8, 'uint16', clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 8, 'uint16', clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 8, 2, clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 8, 2, clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 8, 2, 'int16', clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 8, 2, 'int16', clbk, {} ); // $ExpectType RealOrComplexTypedArray -} - -// The compiler throws an error if a callback function argument is not a function... -{ - filledarrayBy( 'float64', '5' ); // $ExpectError - filledarrayBy( 'float64', 1.0 ); // $ExpectError - filledarrayBy( 'float64', false ); // $ExpectError - filledarrayBy( 'float64', true ); // $ExpectError - filledarrayBy( 'float64', null ); // $ExpectError - filledarrayBy( 'float64', undefined ); // $ExpectError - filledarrayBy( 'float64', [] ); // $ExpectError - filledarrayBy( 'float64', {} ); // $ExpectError - - filledarrayBy( 'float64', '5', {} ); // $ExpectError - filledarrayBy( 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( 'float64', false, {} ); // $ExpectError - filledarrayBy( 'float64', true, {} ); // $ExpectError - filledarrayBy( 'float64', null, {} ); // $ExpectError - filledarrayBy( 'float64', undefined, {} ); // $ExpectError - filledarrayBy( 'float64', [], {} ); // $ExpectError - filledarrayBy( 'float64', {}, {} ); // $ExpectError - - filledarrayBy( 10, '5' ); // $ExpectError - filledarrayBy( 10, 1.0 ); // $ExpectError - filledarrayBy( 10, false ); // $ExpectError - filledarrayBy( 10, true ); // $ExpectError - filledarrayBy( 10, null ); // $ExpectError - filledarrayBy( 10, undefined ); // $ExpectError - filledarrayBy( 10, [] ); // $ExpectError - filledarrayBy( 10, {} ); // $ExpectError - - filledarrayBy( 10, '5', {} ); // $ExpectError - filledarrayBy( 10, 1.0, {} ); // $ExpectError - filledarrayBy( 10, false, {} ); // $ExpectError - filledarrayBy( 10, true, {} ); // $ExpectError - filledarrayBy( 10, null, {} ); // $ExpectError - filledarrayBy( 10, undefined, {} ); // $ExpectError - filledarrayBy( 10, [], {} ); // $ExpectError - filledarrayBy( 10, {}, {} ); // $ExpectError - - filledarrayBy( 10, 'float64', '5' ); // $ExpectError - filledarrayBy( 10, 'float64', 1.0 ); // $ExpectError - filledarrayBy( 10, 'float64', false ); // $ExpectError - filledarrayBy( 10, 'float64', true ); // $ExpectError - filledarrayBy( 10, 'float64', null ); // $ExpectError - filledarrayBy( 10, 'float64', undefined ); // $ExpectError - filledarrayBy( 10, 'float64', [] ); // $ExpectError - filledarrayBy( 10, 'float64', {} ); // $ExpectError - - filledarrayBy( 10, 'float64', '5', {} ); // $ExpectError - filledarrayBy( 10, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( 10, 'float64', false, {} ); // $ExpectError - filledarrayBy( 10, 'float64', true, {} ); // $ExpectError - filledarrayBy( 10, 'float64', null, {} ); // $ExpectError - filledarrayBy( 10, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( 10, 'float64', [], {} ); // $ExpectError - filledarrayBy( 10, 'float64', {}, {} ); // $ExpectError - - const x = new Float64Array( 10 ); - filledarrayBy( x, '5' ); // $ExpectError - filledarrayBy( x, 1.0 ); // $ExpectError - filledarrayBy( x, false ); // $ExpectError - filledarrayBy( x, true ); // $ExpectError - filledarrayBy( x, null ); // $ExpectError - filledarrayBy( x, undefined ); // $ExpectError - filledarrayBy( x, [] ); // $ExpectError - filledarrayBy( x, {} ); // $ExpectError - - filledarrayBy( x, '5', {} ); // $ExpectError - filledarrayBy( x, 1.0, {} ); // $ExpectError - filledarrayBy( x, false, {} ); // $ExpectError - filledarrayBy( x, true, {} ); // $ExpectError - filledarrayBy( x, null, {} ); // $ExpectError - filledarrayBy( x, undefined, {} ); // $ExpectError - filledarrayBy( x, [], {} ); // $ExpectError - filledarrayBy( x, {}, {} ); // $ExpectError - - filledarrayBy( x, 'float64', '5' ); // $ExpectError - filledarrayBy( x, 'float64', 1.0 ); // $ExpectError - filledarrayBy( x, 'float64', false ); // $ExpectError - filledarrayBy( x, 'float64', true ); // $ExpectError - filledarrayBy( x, 'float64', null ); // $ExpectError - filledarrayBy( x, 'float64', undefined ); // $ExpectError - filledarrayBy( x, 'float64', [] ); // $ExpectError - filledarrayBy( x, 'float64', {} ); // $ExpectError - - filledarrayBy( x, 'float64', '5', {} ); // $ExpectError - filledarrayBy( x, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( x, 'float64', false, {} ); // $ExpectError - filledarrayBy( x, 'float64', true, {} ); // $ExpectError - filledarrayBy( x, 'float64', null, {} ); // $ExpectError - filledarrayBy( x, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( x, 'float64', [], {} ); // $ExpectError - filledarrayBy( x, 'float64', {}, {} ); // $ExpectError - - const y = [ 2.0, 2.0, 2.0 ]; - filledarrayBy( y, '5' ); // $ExpectError - filledarrayBy( y, 1.0 ); // $ExpectError - filledarrayBy( y, false ); // $ExpectError - filledarrayBy( y, true ); // $ExpectError - filledarrayBy( y, null ); // $ExpectError - filledarrayBy( y, undefined ); // $ExpectError - filledarrayBy( y, [] ); // $ExpectError - filledarrayBy( y, {} ); // $ExpectError - - filledarrayBy( y, '5', {} ); // $ExpectError - filledarrayBy( y, 1.0, {} ); // $ExpectError - filledarrayBy( y, false, {} ); // $ExpectError - filledarrayBy( y, true, {} ); // $ExpectError - filledarrayBy( y, null, {} ); // $ExpectError - filledarrayBy( y, undefined, {} ); // $ExpectError - filledarrayBy( y, [], {} ); // $ExpectError - filledarrayBy( y, {}, {} ); // $ExpectError - - filledarrayBy( y, 'float64', '5' ); // $ExpectError - filledarrayBy( y, 'float64', 1.0 ); // $ExpectError - filledarrayBy( y, 'float64', false ); // $ExpectError - filledarrayBy( y, 'float64', true ); // $ExpectError - filledarrayBy( y, 'float64', null ); // $ExpectError - filledarrayBy( y, 'float64', undefined ); // $ExpectError - filledarrayBy( y, 'float64', [] ); // $ExpectError - filledarrayBy( y, 'float64', {} ); // $ExpectError - - filledarrayBy( y, 'float64', '5', {} ); // $ExpectError - filledarrayBy( y, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( y, 'float64', false, {} ); // $ExpectError - filledarrayBy( y, 'float64', true, {} ); // $ExpectError - filledarrayBy( y, 'float64', null, {} ); // $ExpectError - filledarrayBy( y, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( y, 'float64', [], {} ); // $ExpectError - filledarrayBy( y, 'float64', {}, {} ); // $ExpectError - - const it = iterator(); - filledarrayBy( it, '5' ); // $ExpectError - filledarrayBy( it, 1.0 ); // $ExpectError - filledarrayBy( it, false ); // $ExpectError - filledarrayBy( it, true ); // $ExpectError - filledarrayBy( it, null ); // $ExpectError - filledarrayBy( it, undefined ); // $ExpectError - filledarrayBy( it, [] ); // $ExpectError - filledarrayBy( it, {} ); // $ExpectError - - filledarrayBy( it, '5', {} ); // $ExpectError - filledarrayBy( it, 1.0, {} ); // $ExpectError - filledarrayBy( it, false, {} ); // $ExpectError - filledarrayBy( it, true, {} ); // $ExpectError - filledarrayBy( it, null, {} ); // $ExpectError - filledarrayBy( it, undefined, {} ); // $ExpectError - filledarrayBy( it, [], {} ); // $ExpectError - filledarrayBy( it, {}, {} ); // $ExpectError - - filledarrayBy( it, 'float64', '5' ); // $ExpectError - filledarrayBy( it, 'float64', 1.0 ); // $ExpectError - filledarrayBy( it, 'float64', false ); // $ExpectError - filledarrayBy( it, 'float64', true ); // $ExpectError - filledarrayBy( it, 'float64', null ); // $ExpectError - filledarrayBy( it, 'float64', undefined ); // $ExpectError - filledarrayBy( it, 'float64', [] ); // $ExpectError - filledarrayBy( it, 'float64', {} ); // $ExpectError - - filledarrayBy( it, 'float64', '5', {} ); // $ExpectError - filledarrayBy( it, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( it, 'float64', false, {} ); // $ExpectError - filledarrayBy( it, 'float64', true, {} ); // $ExpectError - filledarrayBy( it, 'float64', null, {} ); // $ExpectError - filledarrayBy( it, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( it, 'float64', [], {} ); // $ExpectError - filledarrayBy( it, 'float64', {}, {} ); // $ExpectError - - const buf = new ArrayBuffer( 32 ); - filledarrayBy( buf, '5' ); // $ExpectError - filledarrayBy( buf, 1.0 ); // $ExpectError - filledarrayBy( buf, false ); // $ExpectError - filledarrayBy( buf, true ); // $ExpectError - filledarrayBy( buf, null ); // $ExpectError - filledarrayBy( buf, undefined ); // $ExpectError - filledarrayBy( buf, [] ); // $ExpectError - filledarrayBy( buf, {} ); // $ExpectError - - filledarrayBy( buf, '5', {} ); // $ExpectError - filledarrayBy( buf, 1.0, {} ); // $ExpectError - filledarrayBy( buf, false, {} ); // $ExpectError - filledarrayBy( buf, true, {} ); // $ExpectError - filledarrayBy( buf, null, {} ); // $ExpectError - filledarrayBy( buf, undefined, {} ); // $ExpectError - filledarrayBy( buf, [], {} ); // $ExpectError - filledarrayBy( buf, {}, {} ); // $ExpectError - - filledarrayBy( buf, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 'float64', false ); // $ExpectError - filledarrayBy( buf, 'float64', true ); // $ExpectError - filledarrayBy( buf, 'float64', null ); // $ExpectError - filledarrayBy( buf, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 'float64', {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5' ); // $ExpectError - filledarrayBy( buf, 8, 1.0 ); // $ExpectError - filledarrayBy( buf, 8, false ); // $ExpectError - filledarrayBy( buf, 8, true ); // $ExpectError - filledarrayBy( buf, 8, null ); // $ExpectError - filledarrayBy( buf, 8, undefined ); // $ExpectError - filledarrayBy( buf, 8, [] ); // $ExpectError - filledarrayBy( buf, 8, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, false, {} ); // $ExpectError - filledarrayBy( buf, 8, true, {} ); // $ExpectError - filledarrayBy( buf, 8, null, {} ); // $ExpectError - filledarrayBy( buf, 8, undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, [], {} ); // $ExpectError - filledarrayBy( buf, 8, {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 8, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 'float64', false ); // $ExpectError - filledarrayBy( buf, 8, 'float64', true ); // $ExpectError - filledarrayBy( buf, 8, 'float64', null ); // $ExpectError - filledarrayBy( buf, 8, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 8, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 8, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 8, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, '5' ); // $ExpectError - filledarrayBy( buf, 8, 2, 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 2, false ); // $ExpectError - filledarrayBy( buf, 8, 2, true ); // $ExpectError - filledarrayBy( buf, 8, 2, null ); // $ExpectError - filledarrayBy( buf, 8, 2, undefined ); // $ExpectError - filledarrayBy( buf, 8, 2, [] ); // $ExpectError - filledarrayBy( buf, 8, 2, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, false, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, true, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, null, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, [], {} ); // $ExpectError - filledarrayBy( buf, 8, 2, {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', false ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', true ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', null ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', {}, {} ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid length, typed array, array-like object, `ArrayBuffer`, or iterable argument... -{ - filledarrayBy( false, clbk ); // $ExpectError - filledarrayBy( true, clbk ); // $ExpectError - filledarrayBy( null, clbk ); // $ExpectError - filledarrayBy( {}, clbk ); // $ExpectError - - filledarrayBy( false, clbk, {} ); // $ExpectError - filledarrayBy( true, clbk, {} ); // $ExpectError - filledarrayBy( null, clbk, {} ); // $ExpectError - filledarrayBy( {}, clbk, {} ); // $ExpectError - - filledarrayBy( false, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 'float64', clbk ); // $ExpectError - - filledarrayBy( false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, clbk ); // $ExpectError - filledarrayBy( 1.0, 8, clbk ); // $ExpectError - filledarrayBy( false, 8, clbk ); // $ExpectError - filledarrayBy( true, 8, clbk ); // $ExpectError - filledarrayBy( null, 8, clbk ); // $ExpectError - filledarrayBy( undefined, 8, clbk ); // $ExpectError - filledarrayBy( [], 8, clbk ); // $ExpectError - filledarrayBy( {}, 8, clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, clbk ); // $ExpectError - - filledarrayBy( '5', 8, clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, clbk, {} ); // $ExpectError - filledarrayBy( false, 8, clbk, {} ); // $ExpectError - filledarrayBy( true, 8, clbk, {} ); // $ExpectError - filledarrayBy( null, 8, clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, clbk, {} ); // $ExpectError - filledarrayBy( [], 8, clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 'float64', clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( false, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( [], 8, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 'float64', clbk ); // $ExpectError - - filledarrayBy( '5', 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 2, clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 2, clbk ); // $ExpectError - filledarrayBy( false, 8, 2, clbk ); // $ExpectError - filledarrayBy( true, 8, 2, clbk ); // $ExpectError - filledarrayBy( null, 8, 2, clbk ); // $ExpectError - filledarrayBy( undefined, 8, 2, clbk ); // $ExpectError - filledarrayBy( [], 8, 2, clbk ); // $ExpectError - filledarrayBy( {}, 8, 2, clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, clbk ); // $ExpectError - - filledarrayBy( '5', 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( false, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( [], 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, 'float64', clbk ); // $ExpectError - - filledarrayBy( '5', 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a byte offset argument which is not a number... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, false, clbk ); // $ExpectError - filledarrayBy( buf, true, clbk ); // $ExpectError - filledarrayBy( buf, null, clbk ); // $ExpectError - filledarrayBy( buf, [], clbk ); // $ExpectError - filledarrayBy( buf, {}, clbk ); // $ExpectError - - filledarrayBy( buf, false, clbk, {} ); // $ExpectError - filledarrayBy( buf, true, clbk, {} ); // $ExpectError - filledarrayBy( buf, null, clbk, {} ); // $ExpectError - filledarrayBy( buf, [], clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, clbk, {} ); // $ExpectError - - filledarrayBy( buf, '5', 'float64', clbk ); // $ExpectError - filledarrayBy( buf, false, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, true, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, null, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, [], 'float64', clbk ); // $ExpectError - filledarrayBy( buf, {}, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, '5', 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( buf, false, 2, clbk ); // $ExpectError - filledarrayBy( buf, true, 2, clbk ); // $ExpectError - filledarrayBy( buf, null, 2, clbk ); // $ExpectError - filledarrayBy( buf, [], 2, clbk ); // $ExpectError - filledarrayBy( buf, {}, 2, clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, clbk ); // $ExpectError - - filledarrayBy( buf, false, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, clbk, {} ); // $ExpectError - - filledarrayBy( buf, '5', 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, false, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, true, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, null, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, undefined, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, [], 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, {}, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, '5', 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, false, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, undefined, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a view length argument which is not a number... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, 8, false, clbk ); // $ExpectError - filledarrayBy( buf, 8, true, clbk ); // $ExpectError - filledarrayBy( buf, 8, null, clbk ); // $ExpectError - filledarrayBy( buf, 8, [], clbk ); // $ExpectError - filledarrayBy( buf, 8, {}, clbk ); // $ExpectError - - filledarrayBy( buf, 8, false, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, true, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, null, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, [], clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, {}, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, clbk, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5', 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, false, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, true, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, null, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, [], 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, {}, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, 8, '5', 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, [], 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, {}, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided too many arguments... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, 8, 2, 'float64', 1, clbk, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 997a381..0000000 --- a/examples/index.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ).factory; -var dtypes = require( '@stdlib/array-typed-real-dtypes' ); -var filledarrayBy = require( './../lib' ); - -// Create a pseudorandom number generator: -var rand = discreteUniform( 0, 100 ); - -// Get a list of array data types: -var dt = dtypes(); - -// Generate filled arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = filledarrayBy( 10, dt[ i ], rand ); - console.log( arr ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index b1fd829..e1b94a1 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, RealOrComplexTypedArray, DataType } from '@stdlib/types/array'; import { IterableIterator } from '@stdlib/types/iter'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..0689d5a --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.0-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.0-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-ctors@v0.1.0-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill-by@v0.1.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled-by@v0.2.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.2.0-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.0-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@v0.2.0-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.2.0-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";var v=d(),h=u.get("dtypes.default");function g(r,e,t){var i,a;for(i=[],a=-1;!r.next().done;)a+=1,i.push(e.call(t,a));return i}function f(r,e,t){var i;for(i=0;i1)throw new TypeError("invalid arguments. Must provide a length, typed array, array-like object, or an iterable.");if(null===(c=s(j)))throw new TypeError(y("invalid argument. Must provide a recognized data type. Value: `%s`.",j));return new c(0)}if(u<2)throw new TypeError("invalid arguments. Must provide a length, typed array, array-like object, or an iterable.");if(n(arguments[u-=1]))if(n(arguments[u-1])){if(d=arguments[u],b=arguments[u-=1],0===u)throw new TypeError("invalid arguments. Must provide a length, typed array, array-like object, or an iterable.")}else b=arguments[u];else{if(!(u>=2))throw new TypeError("invalid arguments. Must provide a length, typed array, array-like object, or an iterable.");if(d=arguments[u],!n(b=arguments[u-=1]))throw new TypeError(y("invalid argument. Callback argument must be a function. Value: `%s`.",b))}if((u-=1)>=0&&r(arguments[u])?(j=arguments[u],u-=1):j=h,null===(c=s(j)))throw new TypeError(y("invalid argument. Must provide a recognized data type. Value: `%s`.",j));if("generic"===j){if(E=arguments[0],0===u){if(e(E)?x=E:t(E)&&(x=E.length),void 0!==x)return l(x,b,d);if(i(E))throw new Error("invalid arguments. Creating a generic array from an ArrayBuffer is not supported.");if(a(E)){if(!1===v)throw new TypeError(y("invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.",E));if(!n(E[p]))throw new TypeError(y("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",E));if(E=E[p](),!n(E.next))throw new TypeError(y("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",E));return g(E,b,d)}throw new TypeError(y("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",E))}if(i(E))throw new Error("invalid arguments. Creating a generic array from an ArrayBuffer is not supported.");throw new TypeError(y("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",E))}if(0===u)if(t(E=arguments[0]))w=new c(E.length);else if(i(E))w=new c(E);else if(e(E))w=new c(E);else{if(!a(E))throw new TypeError(y("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",E));if(!1===v)throw new TypeError(y("invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.",E));if(!n(E[p]))throw new TypeError(y("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",E));if(E=E[p](),!n(E.next))throw new TypeError(y("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",E));w=new c(m(E))}else w=1===u?new c(arguments[0],arguments[1]):new c(arguments[0],arguments[1],arguments[2]);return w.length>0&&(/^complex/.test(j)?f(w,b,d):o(w.length,w,1,k)),w;function k(r,e){return b.call(d,e)}}export{j as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..35f9b7f --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.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\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport isCollection from '@stdlib/assert-is-collection';\nimport isArrayBuffer from '@stdlib/assert-is-arraybuffer';\nimport isObject from '@stdlib/assert-is-object';\nimport isFunction from '@stdlib/assert-is-function';\nimport ctors from '@stdlib/array-ctors';\nimport gfillBy from '@stdlib/blas-ext-base-gfill-by';\nimport filledArray from '@stdlib/array-base-filled-by';\nimport hasIteratorSymbolSupport from '@stdlib/assert-has-iterator-symbol-support';\nimport ITERATOR_SYMBOL from '@stdlib/symbol-iterator';\nimport iterLength from '@stdlib/iter-length';\nimport defaults from '@stdlib/array-defaults';\nimport format from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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\nexport default filledarrayBy;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","DEFAULT_DTYPE","defaults","get","filledArrayIterator","it","clbk","thisArg","arr","i","next","done","push","call","filledAccessors","length","set","filledarrayBy","nargs","dtype","ctor","len","arg","arguments","ctors","isString","TypeError","format","isFunction","isNonNegativeInteger","isCollection","filledArray","isArrayBuffer","Error","isObject","ITERATOR_SYMBOL","iterLength","test","gfillBy","callback","value","aidx"],"mappings":";;4zCAwCA,IAAIA,EAAsBC,IACtBC,EAAgBC,EAASC,IAAK,kBAclC,SAASC,EAAqBC,EAAIC,EAAMC,GACvC,IAAIC,EACAC,EAKJ,IAFAD,EAAM,GACNC,GAAK,GAEAJ,EAAGK,OACAC,MAGPF,GAAK,EACLD,EAAII,KAAMN,EAAKO,KAAMN,EAASE,IAE/B,OAAOD,CACR,CAWA,SAASM,EAAiBN,EAAKF,EAAMC,GACpC,IAAIE,EACJ,IAAMA,EAAI,EAAGA,EAAID,EAAIO,OAAQN,IAC5BD,EAAIQ,IAAKV,EAAKO,KAAMN,EAASE,GAAKA,GAEnC,OAAOD,CACR,CA4JA,SAASS,IACR,IAAIV,EACAW,EACAC,EACAb,EACAc,EACAZ,EACAa,EACAC,EAKJ,GAAe,KAHfJ,EAAQK,UAAUR,QAKjB,OAAO,IADPK,EAAOI,EAAOvB,IACG,GAIlB,GAAKwB,EADLN,EAAQI,UAAW,IACM,CAExB,GAAKL,EAAQ,EACZ,MAAM,IAAIQ,UAAW,6FAGtB,GAAc,QADdN,EAAOI,EAAOL,IAEb,MAAM,IAAIO,UAAWC,EAAQ,sEAAuER,IAGrG,OAAO,IAAIC,EAAM,EACjB,CAED,GAAKF,EAAQ,EACZ,MAAM,IAAIQ,UAAW,6FAMtB,GAAKE,EAAYL,UAHjBL,GAAS,IAKR,GAAKU,EAAYL,UAAWL,EAAM,KAMjC,GALAX,EAAUgB,UAAWL,GAErBZ,EAAOiB,UADPL,GAAS,GAIM,IAAVA,EACJ,MAAM,IAAIQ,UAAW,kGAItBpB,EAAOiB,UAAWL,OAIf,MAAKA,GAAS,GAUlB,MAAM,IAAIQ,UAAW,6FANrB,GAHAnB,EAAUgB,UAAWL,IAGfU,EADNtB,EAAOiB,UADPL,GAAS,IAGR,MAAM,IAAIQ,UAAWC,EAAQ,uEAAwErB,GAMtG,CAUD,IARAY,GAAS,IACK,GAAKO,EAAUF,UAAWL,KACvCC,EAAQI,UAAWL,GACnBA,GAAS,GAETC,EAAQlB,EAGK,QADdmB,EAAOI,EAAOL,IAEb,MAAM,IAAIO,UAAWC,EAAQ,sEAAuER,IAGrG,GAAe,YAAVA,EAAsB,CAE1B,GADAG,EAAMC,UAAW,GACF,IAAVL,EAAc,CAMlB,GALKW,EAAsBP,GAC1BD,EAAMC,EACKQ,EAAcR,KACzBD,EAAMC,EAAIP,aAEE,IAARM,EACJ,OAAOU,EAAaV,EAAKf,EAAMC,GAEhC,GAAKyB,EAAeV,GACnB,MAAM,IAAIW,MAAO,qFAElB,GAAKC,EAAUZ,GAAQ,CACtB,IAA6B,IAAxBvB,EACJ,MAAM,IAAI2B,UAAWC,EAAQ,sIAAuIL,IAErK,IAAMM,EAAYN,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,wGAAyGL,IAGvI,GADAA,EAAMA,EAAKa,MACLP,EAAYN,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,wGAAyGL,IAEvI,OAAOlB,EAAqBkB,EAAKhB,EAAMC,EACvC,CACD,MAAM,IAAImB,UAAWC,EAAQ,wGAAyGL,GACzI,CAAS,GAAKU,EAAeV,GAC1B,MAAM,IAAIW,MAAO,qFAElB,MAAM,IAAIP,UAAWC,EAAQ,wGAAyGL,GACtI,CACD,GAAe,IAAVJ,EAEJ,GAAKY,EADLR,EAAMC,UAAW,IAEhBf,EAAM,IAAIY,EAAME,EAAIP,aACd,GAAKiB,EAAeV,GAC1Bd,EAAM,IAAIY,EAAME,QACV,GAAKO,EAAsBP,GACjCd,EAAM,IAAIY,EAAME,OACV,KAAKY,EAAUZ,GAarB,MAAM,IAAII,UAAWC,EAAQ,wGAAyGL,IAZtI,IAA6B,IAAxBvB,EACJ,MAAM,IAAI2B,UAAWC,EAAQ,sIAAuIL,IAErK,IAAMM,EAAYN,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,wGAAyGL,IAGvI,GADAA,EAAMA,EAAKa,MACLP,EAAYN,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,wGAAyGL,IAEvId,EAAM,IAAIY,EAAMgB,EAAYd,GAG5B,MAEDd,EADqB,IAAVU,EACL,IAAIE,EAAMG,UAAU,GAAIA,UAAU,IAElC,IAAIH,EAAMG,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKf,EAAIO,OAAS,IACZ,WAAWsB,KAAMlB,GACrBL,EAAiBN,EAAKF,EAAMC,GAE5B+B,EAAS9B,EAAIO,OAAQP,EAAK,EAAG+B,IAGxB/B,EAYP,SAAS+B,EAAUC,EAAOC,GACzB,OAAOnC,EAAKO,KAAMN,EAASkC,EAC3B,CACF"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d115cf0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,192 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -/** -* Create a filled array according to a provided callback function. -* -* @module @stdlib/array-filled-by -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* var arr = filledarrayBy(); -* // returns -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'generic', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( [ 0.5, 0.5 ], clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1; -* } -* -* var arr = filledarrayBy( [ 5, -3 ], 'int32', clbk ); -* // returns [ 1, 1 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk1() { -* return 10; -* } -* -* function clbk2() { -* return 1.0; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, clbk2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk1() { -* return 1.0; -* } -* -* function clbk2() { -* return 2; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, 'uint32', clbk2 ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 'float32', clbk ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, clbk ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, 'int32', clbk ); -* // returns [ 1, 1 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 0f134bb..0000000 --- a/lib/main.js +++ /dev/null @@ -1,414 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var isCollection = require( '@stdlib/assert-is-collection' ); -var isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isObject = require( '@stdlib/assert-is-object' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var ctors = require( '@stdlib/array-ctors' ); -var gfillBy = require( '@stdlib/blas-ext-base-gfill-by' ); -var filledArray = require( '@stdlib/array-base-filled-by' ); -var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var iterLength = require( '@stdlib/iter-length' ); -var defaults = require( '@stdlib/array-defaults' ); -var format = require( '@stdlib/string-format' ); - - -// VARIABLES // - -var HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport(); -var DEFAULT_DTYPE = defaults.get( 'dtypes.default' ); - - -// FUNCTIONS // - -/** -* Creates a filled "generic" array from an iterator. -* -* @private -* @param {Iterable} it - iterator -* @param {Callback} clbk - callback function -* @param {*} thisArg - callback function execution context -* @returns {Array} filled array -*/ -function filledArrayIterator( it, clbk, thisArg ) { - var arr; - var i; - var v; - - arr = []; - i = -1; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - i += 1; - arr.push( clbk.call( thisArg, i ) ); - } - return arr; -} - -/** -* Fills an array exposing accessors for getting and setting array elements. -* -* @private -* @param {Collection} arr - input array -* @param {Callback} clbk - callback function -* @param {*} thisArg - callback function execution context -* @returns {Collection} input array -*/ -function filledAccessors( arr, clbk, thisArg ) { - var i; - for ( i = 0; i < arr.length; i++ ) { - arr.set( clbk.call( thisArg, i ), i ); - } - return arr; -} - - -// MAIN // - -/** -* Creates a filled array according to a provided callback function. -* -* @param {(NonNegativeInteger|TypedArray|ArrayLikeObject|ArrayBuffer|Iterable)} [arg] - a length, typed array, array-like object, buffer, or iterable -* @param {NonNegativeInteger} [byteOffset=0] - byte offset -* @param {NonNegativeInteger} [length] - view length -* @param {string} [dtype="float64"] - data type -* @param {Callback} [clbk] - callback to invoke -* @param {*} [thisArg] - callback execution context -* @throws {TypeError} must provide a recognized data type -* @throws {TypeError} must provide a length, typed array, array-like object, buffer, or iterable -* @throws {TypeError} callback argument must be a function. -* @throws {Error} creating a generic array from an `ArrayBuffer` is not supported -* @returns {(TypedArray|Array)} array or typed array -* -* @example -* var arr = filledarrayBy(); -* // returns -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'generic', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( [ 0.5, 0.5 ], clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1; -* } -* -* var arr = filledarrayBy( [ 5, -3 ], 'int32', clbk ); -* // returns [ 1, 1 ] -* -* @example -* function clbk1() { -* return 10; -* } -* -* function clbk2() { -* return 1.0; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, clbk2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk1() { -* return 1.0; -* } -* -* function clbk2() { -* return 2; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, 'uint32', clbk2 ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 'float32', clbk ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, clbk ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, 'int32', clbk ); -* // returns [ 1, 1 ] -*/ -function filledarrayBy() { - var thisArg; - var nargs; - var dtype; - var clbk; - var ctor; - var arr; - var len; - var arg; - - nargs = arguments.length; - - // If we weren't provided any arguments, return an empty array... - if ( nargs === 0 ) { - ctor = ctors( DEFAULT_DTYPE ); - return new ctor( 0 ); - } - // Check if we were provided a dtype as the first argument... - dtype = arguments[ 0 ]; - if ( isString( dtype ) ) { - // Invoking this function with arguments `f( dtype, clbk[, thisArg] )` is not allowed (otherwise, we'd need to also allow `f( clbk[, thisArg] )`)... - if ( nargs > 1 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( 'invalid argument. Must provide a recognized data type. Value: `%s`.', dtype ) ); - } - // Return an empty array having the specified dtype: - return new ctor( 0 ); - } - // For all other supported invocations, we need at least two arguments... - if ( nargs < 2 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); - } - // At this point, we need to do some argument juggling... - nargs -= 1; // henceforth, the number of available arguments is `nargs+1` - - // Determine whether the last argument is a callback or "this" context... - if ( isFunction( arguments[ nargs ] ) ) { - // 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... - if ( isFunction( arguments[ nargs-1 ] ) ) { - thisArg = arguments[ nargs ]; - nargs -= 1; - clbk = arguments[ nargs ]; - - // Check if we were provided only a callback and a "this" context.. - if ( nargs === 0 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); - } - } else { - // "this" context is left undefined... - clbk = arguments[ nargs ]; - } - } - // 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... - else if ( nargs >= 2 ) { - thisArg = arguments[ nargs ]; - nargs -= 1; - clbk = arguments[ nargs ]; - if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); - } - } - // If were were only provided 2 arguments and the last argument was not a function, we've been provided an insufficient number of arguments... - else { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); - } - // Now that we've processed the callback arguments, let's continue working backward to see if we've been provided a `dtype` argument... - nargs -= 1; - if ( nargs >= 0 && isString( arguments[ nargs ] ) ) { - dtype = arguments[ nargs ]; - nargs -= 1; - } else { - dtype = DEFAULT_DTYPE; - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( 'invalid argument. Must provide a recognized data type. Value: `%s`.', dtype ) ); - } - // At this point, we've resolved the output array data type, and now we can actually create the output array... - if ( dtype === 'generic' ) { - arg = arguments[ 0 ]; - if ( nargs === 0 ) { - if ( isNonNegativeInteger( arg ) ) { - len = arg; - } else if ( isCollection( arg ) ) { - len = arg.length; - } - if ( len !== void 0 ) { - return filledArray( len, clbk, thisArg ); - } - if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); - } - if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); - } - return filledArrayIterator( arg, clbk, thisArg ); - } - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); - } else if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); - } - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); - } - if ( nargs === 0 ) { // length || array-like || ArrayBuffer || iterable - arg = arguments[ 0 ]; - if ( isCollection( arg ) ) { - arr = new ctor( arg.length ); - } else if ( isArrayBuffer( arg ) ) { - arr = new ctor( arg ); - } else if ( isNonNegativeInteger( arg ) ) { - arr = new ctor( arg ); - } else if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); - } - arr = new ctor( iterLength( arg ) ); - } else { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); - } - } else if ( nargs === 1 ) { - arr = new ctor( arguments[0], arguments[1] ); // (ArrayBuffer, byteOffset) - } else { - arr = new ctor( arguments[0], arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset, length) - } - if ( arr.length > 0 ) { - if ( /^complex/.test( dtype ) ) { - filledAccessors( arr, clbk, thisArg ); - } else { - gfillBy( arr.length, arr, 1, callback ); - } - } - return arr; - - /** - * Callback which wraps a provided callback and is invoked for each array element. - * - * @private - * @param {*} value - element value - * @param {NonNegativeInteger} aidx - array index - * @param {NonNegativeInteger} sidx - strided index - * @param {Collection} array - input array/collection - * @returns {*} callback return value - */ - function callback( value, aidx ) { - return clbk.call( thisArg, aidx ); - } -} - - -// EXPORTS // - -module.exports = filledarrayBy; diff --git a/package.json b/package.json index e26c31a..f280264 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.0", "description": "Create a filled array according to a provided callback function.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,70 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-filled-by": "^0.2.0", - "@stdlib/array-ctors": "^0.2.0", - "@stdlib/array-defaults": "^0.2.0", - "@stdlib/assert-has-iterator-symbol-support": "^0.2.0", - "@stdlib/assert-is-arraybuffer": "^0.2.0", - "@stdlib/assert-is-collection": "^0.2.0", - "@stdlib/assert-is-function": "^0.2.0", - "@stdlib/assert-is-nonnegative-integer": "^0.2.0", - "@stdlib/assert-is-object": "^0.2.0", - "@stdlib/assert-is-string": "^0.2.0", - "@stdlib/blas-ext-base-gfill-by": "^0.2.0", - "@stdlib/iter-length": "^0.2.0", - "@stdlib/error-tools-fmtprodmsg": "^0.2.0", - "@stdlib/symbol-iterator": "^0.2.0", - "@stdlib/types": "^0.3.1" - }, - "devDependencies": { - "@stdlib/array-buffer": "^0.2.0", - "@stdlib/array-complex128": "^0.1.0", - "@stdlib/array-complex64": "^0.1.0", - "@stdlib/array-float32": "^0.2.0", - "@stdlib/array-float64": "^0.2.0", - "@stdlib/array-int16": "^0.2.0", - "@stdlib/array-int32": "^0.2.0", - "@stdlib/array-int8": "^0.2.0", - "@stdlib/array-typed-real-dtypes": "^0.2.0", - "@stdlib/array-uint16": "^0.2.0", - "@stdlib/array-uint32": "^0.2.0", - "@stdlib/array-uint8": "^0.2.0", - "@stdlib/array-uint8c": "^0.2.0", - "@stdlib/assert-instance-of": "^0.2.0", - "@stdlib/assert-is-array": "^0.2.0", - "@stdlib/assert-is-typed-array": "^0.2.0", - "@stdlib/assert-is-typed-array-like": "^0.2.0", - "@stdlib/complex-float32": "^0.2.0", - "@stdlib/complex-float64": "^0.2.0", - "@stdlib/iter-constant": "^0.2.0", - "@stdlib/math-base-special-pow": "^0.2.0", - "@stdlib/random-base-discrete-uniform": "^0.1.0", - "@stdlib/strided-base-reinterpret-complex128": "^0.2.0", - "@stdlib/strided-base-reinterpret-complex64": "^0.2.0", - "@stdlib/utils-constant-function": "^0.2.0", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.0" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..15f7417 --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index b55aa4a..0000000 --- a/test/test.js +++ /dev/null @@ -1,4248 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 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. -*/ - -/* eslint-disable max-len */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -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 ArrayBuffer = require( '@stdlib/array-buffer' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var iterConstant = require( '@stdlib/iter-constant' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var filledarrayBy = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': !hasIteratorSymbolSupport() -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof filledarrayBy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if only provided callback arguments', function test( t ) { - t.throws( clbk1, TypeError, 'throws an error' ); - t.throws( clbk2, TypeError, 'throws an error' ); - t.throws( clbk3, TypeError, 'throws an error' ); - t.end(); - - function clbk1() { - filledarrayBy( constantFunction( 1.0 ) ); - } - - function clbk2() { - filledarrayBy( constantFunction( 1.0 ), {} ); - } - - function clbk3() { - filledarrayBy( constantFunction( 1.0 ), constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (only argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (typed array; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (array-like object)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (array-like object; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 8 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 8 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, 1, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (iterator)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( iterConstant( 1.0 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (iterator; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( iterConstant( 1.0 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if only provided data type and callback arguments', function test( t ) { - t.throws( clbk1, TypeError, 'throws an error' ); - t.throws( clbk2, TypeError, 'throws an error' ); - t.throws( clbk3, TypeError, 'throws an error' ); - t.end(); - - function clbk1() { - filledarrayBy( 'float64', constantFunction( 1.0 ) ); - } - - function clbk2() { - filledarrayBy( 'float64', constantFunction( 1.0 ), {} ); - } - - function clbk3() { - filledarrayBy( 'float64', constantFunction( 1.0 ), constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (array-like object)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (array-like object; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, 1, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, 1, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (no iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (no iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (non-function iterator symbol property)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (non-function iterator symbol property; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (`next` property is not a function)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ) ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (`next` property is not a function; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ), {} ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (no iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (no iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (non-function iterator symbol property)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (non-function iterator symbol property; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (`next` property is not a function)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ) ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (`next` property is not a function; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ), {} ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 1, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 1, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function returns a filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - arr = filledarrayBy(); - - t.strictEqual( instanceOf( arr, Float64Array ), 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=float64)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - arr = filledarrayBy( 'float64' ); - - t.strictEqual( instanceOf( arr, Float64Array ), 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=float32)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( 0 ); - arr = filledarrayBy( 'float32' ); - - t.strictEqual( instanceOf( arr, Float32Array ), 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; - - expected = new Complex128Array( 0 ); - arr = filledarrayBy( 'complex128' ); - - t.strictEqual( instanceOf( arr, Complex128Array ), 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=complex64)', function test( t ) { - var expected; - var arr; - - expected = new Complex64Array( 0 ); - arr = filledarrayBy( 'complex64' ); - - t.strictEqual( instanceOf( arr, Complex64Array ), 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=int32)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( 0 ); - arr = filledarrayBy( 'int32' ); - - t.strictEqual( instanceOf( arr, Int32Array ), 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=uint32)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( 0 ); - arr = filledarrayBy( 'uint32' ); - - t.strictEqual( instanceOf( arr, Uint32Array ), 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=int16)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( 0 ); - arr = filledarrayBy( 'int16' ); - - t.strictEqual( instanceOf( arr, Int16Array ), 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=uint16)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( 0 ); - arr = filledarrayBy( 'uint16' ); - - t.strictEqual( instanceOf( arr, Uint16Array ), 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=int8)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( 0 ); - arr = filledarrayBy( 'int8' ); - - t.strictEqual( instanceOf( arr, Int8Array ), 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=uint8)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( 0 ); - arr = filledarrayBy( 'uint8' ); - - t.strictEqual( instanceOf( arr, Uint8Array ), 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=uint8c)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( 0 ); - arr = filledarrayBy( 'uint8c' ); - - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), 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=generic)', function test( t ) { - var expected; - var arr; - - expected = []; - arr = filledarrayBy( 'generic' ); - - t.strictEqual( instanceOf( arr, Array ), 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 (default, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, length=0)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array(); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 0, clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, clbk, ctx ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (default, length; thisArg=function)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, clbk, context ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this(); // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } - - function context() { - ctx.count += 1; - } -}); - -tape( 'the function returns a filled array (dtype=float64, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, 'float64', clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, length; thisArg=function)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, 'float64', clbk, context ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this(); // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } - - function context() { - ctx.count += 1; - } -}); - -tape( 'the function returns a filled array (dtype=float32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, 'float32', clbk ); - - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex128, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = filledarrayBy( 5, 'complex128', clbk ); - - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = filledarrayBy( 5, 'complex64', clbk ); - - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int32Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int32', clbk ); - - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint32Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint32', clbk ); - - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int16Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int16', clbk ); - - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint16', clbk ); - - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int8Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int8', clbk ); - - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint8', clbk ); - - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint8c', clbk ); - - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = [ 1, 1, 1, 1, 1 ]; - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'generic', clbk ); - - t.strictEqual( instanceOf( arr, Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex128, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = [ 1.0, 2.0 ]; - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = [ 1.0, 2.0 ]; - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int32', clbk ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, typed array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, typed array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex128, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = new Float64Array( [ 1.0, 2.0 ] ); - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = new Float64Array( [ 1.0, 2.0 ] ); - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (default, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex128, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer, byteoffset; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer, byteoffset; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, 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; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 48 ); - out = filledarrayBy( buf, 16, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 24 ); - out = filledarrayBy( buf, 8, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int32', clbk ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint8c', clbk ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, 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; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 64 ); - out = filledarrayBy( buf, 16, 2, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset, length)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 1, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 1, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled array (default, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, iterator; thisArg)', opts, function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - ctx = { - 'count': 0 - }; - indices = []; - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, iterator; thisArg)', opts, function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - ctx = { - 'count': 0 - }; - indices = []; - out = filledarrayBy( arr, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex128, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = iterConstant( new Complex128( 3.0, 3.0 ), { - 'iter': 2 - }); - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = iterConstant( new Complex64( 3.0, 3.0 ), { - 'iter': 2 - }); - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); From 1635d2d6cbac429dbaff8a38b0f890dfa3c6e30d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 15 Feb 2024 06:38:47 +0000 Subject: [PATCH 044/117] Update README.md for ESM bundle v0.2.0 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1a8b49c..a709c45 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import filledarrayBy from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-filled-by@esm/index.mjs'; +import filledarrayBy from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-filled-by@v0.2.0-esm/index.mjs'; ``` #### filledarrayBy( \[dtype] ) @@ -227,7 +227,7 @@ arr = filledarrayBy( buf, 10, 4, 'int16', clbk ); var discreteUniform = require( 'https://cdn.jsdelivr.net/gh/stdlib-js/random-base-discrete-uniform' ).factory; import dtypes from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-typed-real-dtypes@esm/index.mjs'; -import filledarrayBy from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-filled-by@esm/index.mjs'; +import filledarrayBy from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-filled-by@v0.2.0-esm/index.mjs'; // Create a pseudorandom number generator: var rand = discreteUniform( 0, 100 ); From d2ae8aef30bb49e0e11d2c47a81a38d9af79f845 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 15 Feb 2024 06:38:47 +0000 Subject: [PATCH 045/117] Auto-generated commit --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a709c45..46fb254 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,11 @@ limitations under the License. ## Usage +```javascript +import filledarrayBy from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-filled-by@esm/index.mjs'; +``` +The previous example will load the latest bundled code from the esm branch. Alternatively, you may load a specific version by loading the file from one of the [tagged bundles](https://github.com/stdlib-js/array-filled-by/tags). For example, + ```javascript import filledarrayBy from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-filled-by@v0.2.0-esm/index.mjs'; ``` @@ -227,7 +232,7 @@ arr = filledarrayBy( buf, 10, 4, 'int16', clbk ); var discreteUniform = require( 'https://cdn.jsdelivr.net/gh/stdlib-js/random-base-discrete-uniform' ).factory; import dtypes from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-typed-real-dtypes@esm/index.mjs'; -import filledarrayBy from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-filled-by@v0.2.0-esm/index.mjs'; +import filledarrayBy from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-filled-by@esm/index.mjs'; // Create a pseudorandom number generator: var rand = discreteUniform( 0, 100 ); From 5ed8afc8fe4fcfd392f2ad9756b17201256307f7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 25 Feb 2024 20:11:11 +0000 Subject: [PATCH 046/117] Transform error messages --- lib/main.js | 38 +++++++++++++++++++------------------- package.json | 2 +- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/lib/main.js b/lib/main.js index 0f134bb..06bc8b6 100644 --- a/lib/main.js +++ b/lib/main.js @@ -33,7 +33,7 @@ var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-supp var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); var iterLength = require( '@stdlib/iter-length' ); var defaults = require( '@stdlib/array-defaults' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -264,18 +264,18 @@ function filledarrayBy() { if ( isString( dtype ) ) { // Invoking this function with arguments `f( dtype, clbk[, thisArg] )` is not allowed (otherwise, we'd need to also allow `f( clbk[, thisArg] )`)... if ( nargs > 1 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format('00h05') ); } ctor = ctors( dtype ); if ( ctor === null ) { - throw new TypeError( format( 'invalid argument. Must provide a recognized data type. Value: `%s`.', dtype ) ); + throw new TypeError( format( '00h2Y', dtype ) ); } // Return an empty array having the specified dtype: return new ctor( 0 ); } // For all other supported invocations, we need at least two arguments... if ( nargs < 2 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format('00h05') ); } // At this point, we need to do some argument juggling... nargs -= 1; // henceforth, the number of available arguments is `nargs+1` @@ -290,7 +290,7 @@ function filledarrayBy() { // Check if we were provided only a callback and a "this" context.. if ( nargs === 0 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format('00h05') ); } } else { // "this" context is left undefined... @@ -303,12 +303,12 @@ function filledarrayBy() { nargs -= 1; clbk = arguments[ nargs ]; if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '00h2b', clbk ) ); } } // If were were only provided 2 arguments and the last argument was not a function, we've been provided an insufficient number of arguments... else { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format('00h05') ); } // Now that we've processed the callback arguments, let's continue working backward to see if we've been provided a `dtype` argument... nargs -= 1; @@ -320,7 +320,7 @@ function filledarrayBy() { } ctor = ctors( dtype ); if ( ctor === null ) { - throw new TypeError( format( 'invalid argument. Must provide a recognized data type. Value: `%s`.', dtype ) ); + throw new TypeError( format( '00h2Y', dtype ) ); } // At this point, we've resolved the output array data type, and now we can actually create the output array... if ( dtype === 'generic' ) { @@ -335,26 +335,26 @@ function filledarrayBy() { return filledArray( len, clbk, thisArg ); } if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format('00h04') ); } if ( isObject( arg ) ) { if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2Z', arg ) ); } if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } arg = arg[ ITERATOR_SYMBOL ](); if ( !isFunction( arg.next ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } return filledArrayIterator( arg, clbk, thisArg ); } - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } else if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format('00h04') ); } - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } if ( nargs === 0 ) { // length || array-like || ArrayBuffer || iterable arg = arguments[ 0 ]; @@ -366,18 +366,18 @@ function filledarrayBy() { arr = new ctor( arg ); } else if ( isObject( arg ) ) { if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2Z', arg ) ); } if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } arg = arg[ ITERATOR_SYMBOL ](); if ( !isFunction( arg.next ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } arr = new ctor( iterLength( arg ) ); } else { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } } else if ( nargs === 1 ) { arr = new ctor( arguments[0], arguments[1] ); // (ArrayBuffer, byteOffset) diff --git a/package.json b/package.json index 6942b7b..7d042f2 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "@stdlib/assert-is-string": "^0.2.1", "@stdlib/blas-ext-base-gfill-by": "^0.2.1", "@stdlib/iter-length": "^0.2.1", - "@stdlib/string-format": "^0.2.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1", "@stdlib/symbol-iterator": "^0.2.1", "@stdlib/types": "^0.3.2", "@stdlib/error-tools-fmtprodmsg": "^0.2.1" From f2a12a0fe3932fdce3b18a0134d01dc06138bfb5 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 25 Feb 2024 21:35:37 +0000 Subject: [PATCH 047/117] Remove files --- index.d.ts | 426 ---- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6608 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index e1b94a1..0000000 --- a/index.d.ts +++ /dev/null @@ -1,426 +0,0 @@ -/* -* @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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, RealOrComplexTypedArray, DataType } from '@stdlib/types/array'; -import { IterableIterator } from '@stdlib/types/iter'; - -/** -* Array or typed array. -*/ -type ArrayOrTypedArray = Array | RealOrComplexTypedArray; - -/** -* Nullary callback function. -* -* @returns fill value -*/ -type Nullary = () => any; - -/** -* Unary callback function. -* -* @param i - current array index -* @returns fill value -*/ -type Unary = ( i: number ) => any; - -/** -* Callback function. -* -* @param i - current array index -* @returns fill value -*/ -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 -* -* @example -* var arr = filledarrayBy(); -* // returns -* -* @example -* var arr = filledarrayBy( 'float32' ); -* // returns -*/ -declare function filledarrayBy( dtype?: DataType ): ArrayOrTypedArray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Creates a filled array according to a provided callback function and having a specified `length`. -* -* @param length - array length -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* -* var arr = filledarrayBy( 5, constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( length: number, clbk: Callback, thisArg?: any ): ArrayOrTypedArray; - -/** -* 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 -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* -* var arr = filledarrayBy( 5, 'float64', constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( length: number, dtype: DataType, clbk: Callback, thisArg?: any ): ArrayOrTypedArray; - -/** -* Creates a filled array from another `array` according to a provided callback function. -* -* @param array - typed array or array-like object -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* -* 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; - -/** -* 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 -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* -* 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; - -/** -* Creates a filled array from an iterable according to a callback function. -* -* @param iterable - iterable -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var iterConstant = require( '@stdlib/iter-constant' ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarrayBy( it, constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( iterable: IterableIterator, callback: Callback, thisArg?: any ): ArrayOrTypedArray; - -/** -* 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 -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var iterConstant = require( '@stdlib/iter-constant' ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* 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; - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; - -/** -* 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. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; - -/** -* 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. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; - -/** -* 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. -* -* @param buffer - `ArrayBuffer` -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; - - -// EXPORTS // - -export = filledarrayBy; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 0689d5a..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.0-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.0-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-ctors@v0.1.0-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill-by@v0.1.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled-by@v0.2.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.2.0-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.0-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@v0.2.0-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.2.0-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";var v=d(),h=u.get("dtypes.default");function g(r,e,t){var i,a;for(i=[],a=-1;!r.next().done;)a+=1,i.push(e.call(t,a));return i}function f(r,e,t){var i;for(i=0;i1)throw new TypeError("invalid arguments. Must provide a length, typed array, array-like object, or an iterable.");if(null===(c=s(j)))throw new TypeError(y("invalid argument. Must provide a recognized data type. Value: `%s`.",j));return new c(0)}if(u<2)throw new TypeError("invalid arguments. Must provide a length, typed array, array-like object, or an iterable.");if(n(arguments[u-=1]))if(n(arguments[u-1])){if(d=arguments[u],b=arguments[u-=1],0===u)throw new TypeError("invalid arguments. Must provide a length, typed array, array-like object, or an iterable.")}else b=arguments[u];else{if(!(u>=2))throw new TypeError("invalid arguments. Must provide a length, typed array, array-like object, or an iterable.");if(d=arguments[u],!n(b=arguments[u-=1]))throw new TypeError(y("invalid argument. Callback argument must be a function. Value: `%s`.",b))}if((u-=1)>=0&&r(arguments[u])?(j=arguments[u],u-=1):j=h,null===(c=s(j)))throw new TypeError(y("invalid argument. Must provide a recognized data type. Value: `%s`.",j));if("generic"===j){if(E=arguments[0],0===u){if(e(E)?x=E:t(E)&&(x=E.length),void 0!==x)return l(x,b,d);if(i(E))throw new Error("invalid arguments. Creating a generic array from an ArrayBuffer is not supported.");if(a(E)){if(!1===v)throw new TypeError(y("invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.",E));if(!n(E[p]))throw new TypeError(y("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",E));if(E=E[p](),!n(E.next))throw new TypeError(y("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",E));return g(E,b,d)}throw new TypeError(y("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",E))}if(i(E))throw new Error("invalid arguments. Creating a generic array from an ArrayBuffer is not supported.");throw new TypeError(y("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",E))}if(0===u)if(t(E=arguments[0]))w=new c(E.length);else if(i(E))w=new c(E);else if(e(E))w=new c(E);else{if(!a(E))throw new TypeError(y("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",E));if(!1===v)throw new TypeError(y("invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.",E));if(!n(E[p]))throw new TypeError(y("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",E));if(E=E[p](),!n(E.next))throw new TypeError(y("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",E));w=new c(m(E))}else w=1===u?new c(arguments[0],arguments[1]):new c(arguments[0],arguments[1],arguments[2]);return w.length>0&&(/^complex/.test(j)?f(w,b,d):o(w.length,w,1,k)),w;function k(r,e){return b.call(d,e)}}export{j as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 35f9b7f..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.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\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport isCollection from '@stdlib/assert-is-collection';\nimport isArrayBuffer from '@stdlib/assert-is-arraybuffer';\nimport isObject from '@stdlib/assert-is-object';\nimport isFunction from '@stdlib/assert-is-function';\nimport ctors from '@stdlib/array-ctors';\nimport gfillBy from '@stdlib/blas-ext-base-gfill-by';\nimport filledArray from '@stdlib/array-base-filled-by';\nimport hasIteratorSymbolSupport from '@stdlib/assert-has-iterator-symbol-support';\nimport ITERATOR_SYMBOL from '@stdlib/symbol-iterator';\nimport iterLength from '@stdlib/iter-length';\nimport defaults from '@stdlib/array-defaults';\nimport format from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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\nexport default filledarrayBy;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","DEFAULT_DTYPE","defaults","get","filledArrayIterator","it","clbk","thisArg","arr","i","next","done","push","call","filledAccessors","length","set","filledarrayBy","nargs","dtype","ctor","len","arg","arguments","ctors","isString","TypeError","format","isFunction","isNonNegativeInteger","isCollection","filledArray","isArrayBuffer","Error","isObject","ITERATOR_SYMBOL","iterLength","test","gfillBy","callback","value","aidx"],"mappings":";;4zCAwCA,IAAIA,EAAsBC,IACtBC,EAAgBC,EAASC,IAAK,kBAclC,SAASC,EAAqBC,EAAIC,EAAMC,GACvC,IAAIC,EACAC,EAKJ,IAFAD,EAAM,GACNC,GAAK,GAEAJ,EAAGK,OACAC,MAGPF,GAAK,EACLD,EAAII,KAAMN,EAAKO,KAAMN,EAASE,IAE/B,OAAOD,CACR,CAWA,SAASM,EAAiBN,EAAKF,EAAMC,GACpC,IAAIE,EACJ,IAAMA,EAAI,EAAGA,EAAID,EAAIO,OAAQN,IAC5BD,EAAIQ,IAAKV,EAAKO,KAAMN,EAASE,GAAKA,GAEnC,OAAOD,CACR,CA4JA,SAASS,IACR,IAAIV,EACAW,EACAC,EACAb,EACAc,EACAZ,EACAa,EACAC,EAKJ,GAAe,KAHfJ,EAAQK,UAAUR,QAKjB,OAAO,IADPK,EAAOI,EAAOvB,IACG,GAIlB,GAAKwB,EADLN,EAAQI,UAAW,IACM,CAExB,GAAKL,EAAQ,EACZ,MAAM,IAAIQ,UAAW,6FAGtB,GAAc,QADdN,EAAOI,EAAOL,IAEb,MAAM,IAAIO,UAAWC,EAAQ,sEAAuER,IAGrG,OAAO,IAAIC,EAAM,EACjB,CAED,GAAKF,EAAQ,EACZ,MAAM,IAAIQ,UAAW,6FAMtB,GAAKE,EAAYL,UAHjBL,GAAS,IAKR,GAAKU,EAAYL,UAAWL,EAAM,KAMjC,GALAX,EAAUgB,UAAWL,GAErBZ,EAAOiB,UADPL,GAAS,GAIM,IAAVA,EACJ,MAAM,IAAIQ,UAAW,kGAItBpB,EAAOiB,UAAWL,OAIf,MAAKA,GAAS,GAUlB,MAAM,IAAIQ,UAAW,6FANrB,GAHAnB,EAAUgB,UAAWL,IAGfU,EADNtB,EAAOiB,UADPL,GAAS,IAGR,MAAM,IAAIQ,UAAWC,EAAQ,uEAAwErB,GAMtG,CAUD,IARAY,GAAS,IACK,GAAKO,EAAUF,UAAWL,KACvCC,EAAQI,UAAWL,GACnBA,GAAS,GAETC,EAAQlB,EAGK,QADdmB,EAAOI,EAAOL,IAEb,MAAM,IAAIO,UAAWC,EAAQ,sEAAuER,IAGrG,GAAe,YAAVA,EAAsB,CAE1B,GADAG,EAAMC,UAAW,GACF,IAAVL,EAAc,CAMlB,GALKW,EAAsBP,GAC1BD,EAAMC,EACKQ,EAAcR,KACzBD,EAAMC,EAAIP,aAEE,IAARM,EACJ,OAAOU,EAAaV,EAAKf,EAAMC,GAEhC,GAAKyB,EAAeV,GACnB,MAAM,IAAIW,MAAO,qFAElB,GAAKC,EAAUZ,GAAQ,CACtB,IAA6B,IAAxBvB,EACJ,MAAM,IAAI2B,UAAWC,EAAQ,sIAAuIL,IAErK,IAAMM,EAAYN,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,wGAAyGL,IAGvI,GADAA,EAAMA,EAAKa,MACLP,EAAYN,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,wGAAyGL,IAEvI,OAAOlB,EAAqBkB,EAAKhB,EAAMC,EACvC,CACD,MAAM,IAAImB,UAAWC,EAAQ,wGAAyGL,GACzI,CAAS,GAAKU,EAAeV,GAC1B,MAAM,IAAIW,MAAO,qFAElB,MAAM,IAAIP,UAAWC,EAAQ,wGAAyGL,GACtI,CACD,GAAe,IAAVJ,EAEJ,GAAKY,EADLR,EAAMC,UAAW,IAEhBf,EAAM,IAAIY,EAAME,EAAIP,aACd,GAAKiB,EAAeV,GAC1Bd,EAAM,IAAIY,EAAME,QACV,GAAKO,EAAsBP,GACjCd,EAAM,IAAIY,EAAME,OACV,KAAKY,EAAUZ,GAarB,MAAM,IAAII,UAAWC,EAAQ,wGAAyGL,IAZtI,IAA6B,IAAxBvB,EACJ,MAAM,IAAI2B,UAAWC,EAAQ,sIAAuIL,IAErK,IAAMM,EAAYN,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,wGAAyGL,IAGvI,GADAA,EAAMA,EAAKa,MACLP,EAAYN,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,wGAAyGL,IAEvId,EAAM,IAAIY,EAAMgB,EAAYd,GAG5B,MAEDd,EADqB,IAAVU,EACL,IAAIE,EAAMG,UAAU,GAAIA,UAAU,IAElC,IAAIH,EAAMG,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKf,EAAIO,OAAS,IACZ,WAAWsB,KAAMlB,GACrBL,EAAiBN,EAAKF,EAAMC,GAE5B+B,EAAS9B,EAAIO,OAAQP,EAAK,EAAG+B,IAGxB/B,EAYP,SAAS+B,EAAUC,EAAOC,GACzB,OAAOnC,EAAKO,KAAMN,EAASkC,EAC3B,CACF"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 15f7417..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From f1cde6ea54f91fd737260010b9957cbd9ccfcc08 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 25 Feb 2024 21:35:57 +0000 Subject: [PATCH 048/117] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 ---- .github/workflows/publish.yml | 249 -- .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 132 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 228 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 47 +- SECURITY.md | 5 - benchmark/benchmark.js | 319 -- benchmark/benchmark.length.complex128.js | 98 - benchmark/benchmark.length.complex64.js | 98 - benchmark/benchmark.length.float32.js | 97 - benchmark/benchmark.length.float64.js | 97 - benchmark/benchmark.length.generic.js | 97 - benchmark/benchmark.length.int16.js | 97 - benchmark/benchmark.length.int32.js | 97 - benchmark/benchmark.length.int8.js | 97 - benchmark/benchmark.length.uint16.js | 97 - benchmark/benchmark.length.uint32.js | 97 - benchmark/benchmark.length.uint8.js | 97 - benchmark/benchmark.length.uint8c.js | 97 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 174 - docs/types/test.ts | 606 --- examples/index.js | 37 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 192 - lib/main.js | 414 -- package.json | 92 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 4248 ------------------ 54 files changed, 4869 insertions(+), 10545 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.length.complex128.js delete mode 100644 benchmark/benchmark.length.complex64.js delete mode 100644 benchmark/benchmark.length.float32.js delete mode 100644 benchmark/benchmark.length.float64.js delete mode 100644 benchmark/benchmark.length.generic.js delete mode 100644 benchmark/benchmark.length.int16.js delete mode 100644 benchmark/benchmark.length.int32.js delete mode 100644 benchmark/benchmark.length.int8.js delete mode 100644 benchmark/benchmark.length.uint16.js delete mode 100644 benchmark/benchmark.length.uint32.js delete mode 100644 benchmark/benchmark.length.uint8.js delete mode 100644 benchmark/benchmark.length.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 8be0b82..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index f988046..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index b2c1f9c..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '42 6 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 9106b5d..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -293,7 +284,7 @@ for ( i = 0; i < dt.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -364,9 +355,9 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/filled]: https://github.com/stdlib-js/array-filled +[@stdlib/array/filled]: https://github.com/stdlib-js/array-filled/tree/esm -[@stdlib/array/typed]: https://github.com/stdlib-js/array-typed +[@stdlib/array/typed]: https://github.com/stdlib-js/array-typed/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 67ba493..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,319 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); -var isArray = require( '@stdlib/assert-is-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var pkg = require( './../package.json' ).name; -var filledarrayBy = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 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=float64', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'float64', 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=float32', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'float32', 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; - var i; - - clbk = constantFunction( new Complex128( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'complex128', 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=complex64', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( new Complex64( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'complex64', 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=int32', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int32', 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=uint32', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint32', 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=int16', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int16', 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=uint16', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint16', 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=int8', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int8', 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=uint8', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint8', 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=uint8c', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint8c', 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=generic', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'generic', clbk ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.length.complex128.js b/benchmark/benchmark.length.complex128.js deleted file mode 100644 index 27f6c66..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 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 Complex128 = require( '@stdlib/complex-float64' ); -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( new Complex128( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'complex128', 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=complex128,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.complex64.js b/benchmark/benchmark.length.complex64.js deleted file mode 100644 index c094ae9..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 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 Complex64 = require( '@stdlib/complex-float32' ); -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( new Complex64( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'complex64', 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=complex64,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.float32.js b/benchmark/benchmark.length.float32.js deleted file mode 100644 index d2b2ba7..0000000 --- a/benchmark/benchmark.length.float32.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'float32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=float32,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.float64.js b/benchmark/benchmark.length.float64.js deleted file mode 100644 index 65064e3..0000000 --- a/benchmark/benchmark.length.float64.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'float64', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=float64,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.generic.js b/benchmark/benchmark.length.generic.js deleted file mode 100644 index eb87dfa..0000000 --- a/benchmark/benchmark.length.generic.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isArray = require( '@stdlib/assert-is-array' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'generic', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isArray( 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=generic,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int16.js b/benchmark/benchmark.length.int16.js deleted file mode 100644 index 914ff7c..0000000 --- a/benchmark/benchmark.length.int16.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int16', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=int16,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int32.js b/benchmark/benchmark.length.int32.js deleted file mode 100644 index cc0f678..0000000 --- a/benchmark/benchmark.length.int32.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=int32,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int8.js b/benchmark/benchmark.length.int8.js deleted file mode 100644 index 77553b0..0000000 --- a/benchmark/benchmark.length.int8.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int8', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=int8,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint16.js b/benchmark/benchmark.length.uint16.js deleted file mode 100644 index c68efdd..0000000 --- a/benchmark/benchmark.length.uint16.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint16', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint16,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint32.js b/benchmark/benchmark.length.uint32.js deleted file mode 100644 index 27c1742..0000000 --- a/benchmark/benchmark.length.uint32.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint32,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint8.js b/benchmark/benchmark.length.uint8.js deleted file mode 100644 index 2a26be4..0000000 --- a/benchmark/benchmark.length.uint8.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint8', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint8,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint8c.js b/benchmark/benchmark.length.uint8c.js deleted file mode 100644 index dd6e8c2..0000000 --- a/benchmark/benchmark.length.uint8c.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint8c', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint8c,len='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index c138144..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by" -%% click B href "https://github.com/stdlib-js/array-filled-by/tree/main" -%% click C href "https://github.com/stdlib-js/array-filled-by/tree/production" -%% click D href "https://github.com/stdlib-js/array-filled-by/tree/esm" -%% click E href "https://github.com/stdlib-js/array-filled-by/tree/deno" -%% click F href "https://github.com/stdlib-js/array-filled-by/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by -[production-url]: https://github.com/stdlib-js/array-filled-by/tree/production -[deno-url]: https://github.com/stdlib-js/array-filled-by/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-filled-by/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-filled-by/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-filled-by/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-filled-by/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-filled-by/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 188fc9b..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import filledarrayBy from '../docs/types/index'; -export = filledarrayBy; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 468e99c..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"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 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 00888a2..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "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,EAAQ,UAAU,OAGbA,IAAU,EACd,OAAAE,EAAOrB,EAAOS,CAAc,EACrB,IAAIY,EAAM,CAAE,EAIpB,GADAD,EAAQ,UAAW,CAAE,EAChB1B,EAAU0B,CAAM,EAAI,CAExB,GAAKD,EAAQ,EACZ,MAAM,IAAI,UAAW,2FAA4F,EAGlH,GADAE,EAAOrB,EAAOoB,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWd,EAAQ,sEAAuEa,CAAM,CAAE,EAG7G,OAAO,IAAIC,EAAM,CAAE,CACpB,CAEA,GAAKF,EAAQ,EACZ,MAAM,IAAI,UAAW,2FAA4F,EAMlH,GAHAA,GAAS,EAGJpB,EAAY,UAAWoB,CAAM,CAAE,EAEnC,GAAKpB,EAAY,UAAWoB,EAAM,CAAE,CAAE,GAMrC,GALAN,EAAU,UAAWM,CAAM,EAC3BA,GAAS,EACTP,EAAO,UAAWO,CAAM,EAGnBA,IAAU,EACd,MAAM,IAAI,UAAW,2FAA4F,OAIlHP,EAAO,UAAWO,CAAM,UAIhBA,GAAS,GAIlB,GAHAN,EAAU,UAAWM,CAAM,EAC3BA,GAAS,EACTP,EAAO,UAAWO,CAAM,EACnB,CAACpB,EAAYa,CAAK,EACtB,MAAM,IAAI,UAAWL,EAAQ,uEAAwEK,CAAK,CAAE,MAK7G,OAAM,IAAI,UAAW,2FAA4F,EAWlH,GARAO,GAAS,EACJA,GAAS,GAAKzB,EAAU,UAAWyB,CAAM,CAAE,GAC/CC,EAAQ,UAAWD,CAAM,EACzBA,GAAS,GAETC,EAAQX,EAETY,EAAOrB,EAAOoB,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWd,EAAQ,sEAAuEa,CAAM,CAAE,EAG7G,GAAKA,IAAU,UAAY,CAE1B,GADAG,EAAM,UAAW,CAAE,EACdJ,IAAU,EAAI,CAMlB,GALKxB,EAAsB4B,CAAI,EAC9BD,EAAMC,EACK3B,EAAc2B,CAAI,IAC7BD,EAAMC,EAAI,QAEND,IAAQ,OACZ,OAAOpB,EAAaoB,EAAKV,EAAMC,CAAQ,EAExC,GAAKhB,EAAe0B,CAAI,EACvB,MAAM,IAAI,MAAO,mFAAoF,EAEtG,GAAKzB,EAAUyB,CAAI,EAAI,CACtB,GAAKf,IAAwB,GAC5B,MAAM,IAAI,UAAWD,EAAQ,sIAAuIgB,CAAI,CAAE,EAE3K,GAAK,CAACxB,EAAYwB,EAAKnB,CAAgB,CAAE,EACxC,MAAM,IAAI,UAAWG,EAAQ,wGAAyGgB,CAAI,CAAE,EAG7I,GADAA,EAAMA,EAAKnB,CAAgB,EAAE,EACxB,CAACL,EAAYwB,EAAI,IAAK,EAC1B,MAAM,IAAI,UAAWhB,EAAQ,wGAAyGgB,CAAI,CAAE,EAE7I,OAAOb,EAAqBa,EAAKX,EAAMC,CAAQ,CAChD,CACA,MAAM,IAAI,UAAWN,EAAQ,wGAAyGgB,CAAI,CAAE,CAC7I,SAAY1B,EAAe0B,CAAI,EAC9B,MAAM,IAAI,MAAO,mFAAoF,EAEtG,MAAM,IAAI,UAAWhB,EAAQ,wGAAyGgB,CAAI,CAAE,CAC7I,CACA,GAAKJ,IAAU,EAEd,GADAI,EAAM,UAAW,CAAE,EACd3B,EAAc2B,CAAI,EACtBT,EAAM,IAAIO,EAAME,EAAI,MAAO,UAChB1B,EAAe0B,CAAI,EAC9BT,EAAM,IAAIO,EAAME,CAAI,UACT5B,EAAsB4B,CAAI,EACrCT,EAAM,IAAIO,EAAME,CAAI,UACTzB,EAAUyB,CAAI,EAAI,CAC7B,GAAKf,IAAwB,GAC5B,MAAM,IAAI,UAAWD,EAAQ,sIAAuIgB,CAAI,CAAE,EAE3K,GAAK,CAACxB,EAAYwB,EAAKnB,CAAgB,CAAE,EACxC,MAAM,IAAI,UAAWG,EAAQ,wGAAyGgB,CAAI,CAAE,EAG7I,GADAA,EAAMA,EAAKnB,CAAgB,EAAE,EACxB,CAACL,EAAYwB,EAAI,IAAK,EAC1B,MAAM,IAAI,UAAWhB,EAAQ,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"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 5a68984..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,174 +0,0 @@ - -{{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) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr = {{alias}}() - - > arr = {{alias}}( 'float32' ) - - - -{{alias}}( length[, dtype], clbk[, thisArg] ) - Returns a filled array according to a provided callback function and having - a specified length. - - Parameters - ---------- - length: integer - Array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > function clbk() { return 1.0; }; - > var arr = {{alias}}( 5, clbk ) - [ 1.0, 1.0, 1.0, 1.0, 1.0 ] - > arr = {{alias}}( 5, 'int32', clbk ) - [ 1, 1, 1, 1, 1 ] - - -{{alias}}( array[, dtype], clbk[, thisArg] ) - Creates a filled array from another array (or array-like object) according - to a provided callback function. - - Parameters - ---------- - array: ArrayLikeObject - Array from which to generate another array. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias}}( [ 0.5, 0.5, 0.5 ], {{alias:@stdlib/utils/constant-function}}( 2.0 ) ) - [ 2.0, 2.0, 2.0 ] - > var arr2 = {{alias}}( arr1, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( iterable[, dtype], clbk[, thisArg] ) - Creates a filled array from an iterable according to a provided callback - function. - - Parameters - ---------- - iterable: Iterable - Iterable from which to generate an array. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias:@stdlib/iter/constant}}( 3.0, {'iter': 3} ); - > var arr2 = {{alias}}( arr1, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( buffer[, byteOffset[, length]][, dtype], clbk[, thisArg] ) - Returns a filled typed array view of an ArrayBuffer according to a provided - callback function. - - The 'generic' array data type is *not* supported. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( buf, 0, 4, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0, 1.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 394ac49..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,606 +0,0 @@ -/* -* @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. -*/ - -/// - -import { IterableIterator } from '@stdlib/types/iter'; -import filledarrayBy = require( './index' ); - - -/** -* Returns an iterator protocol-compliant object. -* -* @returns iterator protocol-compliant object -*/ -function iterator(): IterableIterator { - const obj: IterableIterator = { - [Symbol.iterator]: iterator, - 'next': next - }; - return obj; -} - -/** -* Implements the iterator protocol `next` method. -* -* @returns iterator protocol-compliant object -*/ -function next(): any { - return { - 'value': 1.0, - 'done': false - }; -} - -/** -* Callback function. -* -* @param i - current array index -* @returns return value -*/ -function clbk( i: number ): number { - return i; -} - - -// TESTS // - -// The function returns an array or typed array... -{ - filledarrayBy(); // $ExpectType ArrayOrTypedArray - filledarrayBy( 'float32' ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( 10, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( 10, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( 10, 'int32', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( 10, 'int32', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const x = new Float64Array( 10 ); - filledarrayBy( x, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( x, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( x, 'uint8', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( x, 'uint8', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const y = [ 2.0, 2.0, 2.0 ]; - filledarrayBy( y, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( y, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( y, 'float64', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( y, 'float64', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const it = iterator(); - filledarrayBy( it, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( it, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( it, 'uint8c', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( it, 'uint8c', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const buf = new ArrayBuffer( 32 ); - filledarrayBy( buf, clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 'uint32', clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 'uint32', clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 8, clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 8, clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 8, 'uint16', clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 8, 'uint16', clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 8, 2, clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 8, 2, clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 8, 2, 'int16', clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 8, 2, 'int16', clbk, {} ); // $ExpectType RealOrComplexTypedArray -} - -// The compiler throws an error if a callback function argument is not a function... -{ - filledarrayBy( 'float64', '5' ); // $ExpectError - filledarrayBy( 'float64', 1.0 ); // $ExpectError - filledarrayBy( 'float64', false ); // $ExpectError - filledarrayBy( 'float64', true ); // $ExpectError - filledarrayBy( 'float64', null ); // $ExpectError - filledarrayBy( 'float64', undefined ); // $ExpectError - filledarrayBy( 'float64', [] ); // $ExpectError - filledarrayBy( 'float64', {} ); // $ExpectError - - filledarrayBy( 'float64', '5', {} ); // $ExpectError - filledarrayBy( 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( 'float64', false, {} ); // $ExpectError - filledarrayBy( 'float64', true, {} ); // $ExpectError - filledarrayBy( 'float64', null, {} ); // $ExpectError - filledarrayBy( 'float64', undefined, {} ); // $ExpectError - filledarrayBy( 'float64', [], {} ); // $ExpectError - filledarrayBy( 'float64', {}, {} ); // $ExpectError - - filledarrayBy( 10, '5' ); // $ExpectError - filledarrayBy( 10, 1.0 ); // $ExpectError - filledarrayBy( 10, false ); // $ExpectError - filledarrayBy( 10, true ); // $ExpectError - filledarrayBy( 10, null ); // $ExpectError - filledarrayBy( 10, undefined ); // $ExpectError - filledarrayBy( 10, [] ); // $ExpectError - filledarrayBy( 10, {} ); // $ExpectError - - filledarrayBy( 10, '5', {} ); // $ExpectError - filledarrayBy( 10, 1.0, {} ); // $ExpectError - filledarrayBy( 10, false, {} ); // $ExpectError - filledarrayBy( 10, true, {} ); // $ExpectError - filledarrayBy( 10, null, {} ); // $ExpectError - filledarrayBy( 10, undefined, {} ); // $ExpectError - filledarrayBy( 10, [], {} ); // $ExpectError - filledarrayBy( 10, {}, {} ); // $ExpectError - - filledarrayBy( 10, 'float64', '5' ); // $ExpectError - filledarrayBy( 10, 'float64', 1.0 ); // $ExpectError - filledarrayBy( 10, 'float64', false ); // $ExpectError - filledarrayBy( 10, 'float64', true ); // $ExpectError - filledarrayBy( 10, 'float64', null ); // $ExpectError - filledarrayBy( 10, 'float64', undefined ); // $ExpectError - filledarrayBy( 10, 'float64', [] ); // $ExpectError - filledarrayBy( 10, 'float64', {} ); // $ExpectError - - filledarrayBy( 10, 'float64', '5', {} ); // $ExpectError - filledarrayBy( 10, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( 10, 'float64', false, {} ); // $ExpectError - filledarrayBy( 10, 'float64', true, {} ); // $ExpectError - filledarrayBy( 10, 'float64', null, {} ); // $ExpectError - filledarrayBy( 10, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( 10, 'float64', [], {} ); // $ExpectError - filledarrayBy( 10, 'float64', {}, {} ); // $ExpectError - - const x = new Float64Array( 10 ); - filledarrayBy( x, '5' ); // $ExpectError - filledarrayBy( x, 1.0 ); // $ExpectError - filledarrayBy( x, false ); // $ExpectError - filledarrayBy( x, true ); // $ExpectError - filledarrayBy( x, null ); // $ExpectError - filledarrayBy( x, undefined ); // $ExpectError - filledarrayBy( x, [] ); // $ExpectError - filledarrayBy( x, {} ); // $ExpectError - - filledarrayBy( x, '5', {} ); // $ExpectError - filledarrayBy( x, 1.0, {} ); // $ExpectError - filledarrayBy( x, false, {} ); // $ExpectError - filledarrayBy( x, true, {} ); // $ExpectError - filledarrayBy( x, null, {} ); // $ExpectError - filledarrayBy( x, undefined, {} ); // $ExpectError - filledarrayBy( x, [], {} ); // $ExpectError - filledarrayBy( x, {}, {} ); // $ExpectError - - filledarrayBy( x, 'float64', '5' ); // $ExpectError - filledarrayBy( x, 'float64', 1.0 ); // $ExpectError - filledarrayBy( x, 'float64', false ); // $ExpectError - filledarrayBy( x, 'float64', true ); // $ExpectError - filledarrayBy( x, 'float64', null ); // $ExpectError - filledarrayBy( x, 'float64', undefined ); // $ExpectError - filledarrayBy( x, 'float64', [] ); // $ExpectError - filledarrayBy( x, 'float64', {} ); // $ExpectError - - filledarrayBy( x, 'float64', '5', {} ); // $ExpectError - filledarrayBy( x, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( x, 'float64', false, {} ); // $ExpectError - filledarrayBy( x, 'float64', true, {} ); // $ExpectError - filledarrayBy( x, 'float64', null, {} ); // $ExpectError - filledarrayBy( x, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( x, 'float64', [], {} ); // $ExpectError - filledarrayBy( x, 'float64', {}, {} ); // $ExpectError - - const y = [ 2.0, 2.0, 2.0 ]; - filledarrayBy( y, '5' ); // $ExpectError - filledarrayBy( y, 1.0 ); // $ExpectError - filledarrayBy( y, false ); // $ExpectError - filledarrayBy( y, true ); // $ExpectError - filledarrayBy( y, null ); // $ExpectError - filledarrayBy( y, undefined ); // $ExpectError - filledarrayBy( y, [] ); // $ExpectError - filledarrayBy( y, {} ); // $ExpectError - - filledarrayBy( y, '5', {} ); // $ExpectError - filledarrayBy( y, 1.0, {} ); // $ExpectError - filledarrayBy( y, false, {} ); // $ExpectError - filledarrayBy( y, true, {} ); // $ExpectError - filledarrayBy( y, null, {} ); // $ExpectError - filledarrayBy( y, undefined, {} ); // $ExpectError - filledarrayBy( y, [], {} ); // $ExpectError - filledarrayBy( y, {}, {} ); // $ExpectError - - filledarrayBy( y, 'float64', '5' ); // $ExpectError - filledarrayBy( y, 'float64', 1.0 ); // $ExpectError - filledarrayBy( y, 'float64', false ); // $ExpectError - filledarrayBy( y, 'float64', true ); // $ExpectError - filledarrayBy( y, 'float64', null ); // $ExpectError - filledarrayBy( y, 'float64', undefined ); // $ExpectError - filledarrayBy( y, 'float64', [] ); // $ExpectError - filledarrayBy( y, 'float64', {} ); // $ExpectError - - filledarrayBy( y, 'float64', '5', {} ); // $ExpectError - filledarrayBy( y, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( y, 'float64', false, {} ); // $ExpectError - filledarrayBy( y, 'float64', true, {} ); // $ExpectError - filledarrayBy( y, 'float64', null, {} ); // $ExpectError - filledarrayBy( y, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( y, 'float64', [], {} ); // $ExpectError - filledarrayBy( y, 'float64', {}, {} ); // $ExpectError - - const it = iterator(); - filledarrayBy( it, '5' ); // $ExpectError - filledarrayBy( it, 1.0 ); // $ExpectError - filledarrayBy( it, false ); // $ExpectError - filledarrayBy( it, true ); // $ExpectError - filledarrayBy( it, null ); // $ExpectError - filledarrayBy( it, undefined ); // $ExpectError - filledarrayBy( it, [] ); // $ExpectError - filledarrayBy( it, {} ); // $ExpectError - - filledarrayBy( it, '5', {} ); // $ExpectError - filledarrayBy( it, 1.0, {} ); // $ExpectError - filledarrayBy( it, false, {} ); // $ExpectError - filledarrayBy( it, true, {} ); // $ExpectError - filledarrayBy( it, null, {} ); // $ExpectError - filledarrayBy( it, undefined, {} ); // $ExpectError - filledarrayBy( it, [], {} ); // $ExpectError - filledarrayBy( it, {}, {} ); // $ExpectError - - filledarrayBy( it, 'float64', '5' ); // $ExpectError - filledarrayBy( it, 'float64', 1.0 ); // $ExpectError - filledarrayBy( it, 'float64', false ); // $ExpectError - filledarrayBy( it, 'float64', true ); // $ExpectError - filledarrayBy( it, 'float64', null ); // $ExpectError - filledarrayBy( it, 'float64', undefined ); // $ExpectError - filledarrayBy( it, 'float64', [] ); // $ExpectError - filledarrayBy( it, 'float64', {} ); // $ExpectError - - filledarrayBy( it, 'float64', '5', {} ); // $ExpectError - filledarrayBy( it, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( it, 'float64', false, {} ); // $ExpectError - filledarrayBy( it, 'float64', true, {} ); // $ExpectError - filledarrayBy( it, 'float64', null, {} ); // $ExpectError - filledarrayBy( it, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( it, 'float64', [], {} ); // $ExpectError - filledarrayBy( it, 'float64', {}, {} ); // $ExpectError - - const buf = new ArrayBuffer( 32 ); - filledarrayBy( buf, '5' ); // $ExpectError - filledarrayBy( buf, 1.0 ); // $ExpectError - filledarrayBy( buf, false ); // $ExpectError - filledarrayBy( buf, true ); // $ExpectError - filledarrayBy( buf, null ); // $ExpectError - filledarrayBy( buf, undefined ); // $ExpectError - filledarrayBy( buf, [] ); // $ExpectError - filledarrayBy( buf, {} ); // $ExpectError - - filledarrayBy( buf, '5', {} ); // $ExpectError - filledarrayBy( buf, 1.0, {} ); // $ExpectError - filledarrayBy( buf, false, {} ); // $ExpectError - filledarrayBy( buf, true, {} ); // $ExpectError - filledarrayBy( buf, null, {} ); // $ExpectError - filledarrayBy( buf, undefined, {} ); // $ExpectError - filledarrayBy( buf, [], {} ); // $ExpectError - filledarrayBy( buf, {}, {} ); // $ExpectError - - filledarrayBy( buf, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 'float64', false ); // $ExpectError - filledarrayBy( buf, 'float64', true ); // $ExpectError - filledarrayBy( buf, 'float64', null ); // $ExpectError - filledarrayBy( buf, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 'float64', {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5' ); // $ExpectError - filledarrayBy( buf, 8, 1.0 ); // $ExpectError - filledarrayBy( buf, 8, false ); // $ExpectError - filledarrayBy( buf, 8, true ); // $ExpectError - filledarrayBy( buf, 8, null ); // $ExpectError - filledarrayBy( buf, 8, undefined ); // $ExpectError - filledarrayBy( buf, 8, [] ); // $ExpectError - filledarrayBy( buf, 8, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, false, {} ); // $ExpectError - filledarrayBy( buf, 8, true, {} ); // $ExpectError - filledarrayBy( buf, 8, null, {} ); // $ExpectError - filledarrayBy( buf, 8, undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, [], {} ); // $ExpectError - filledarrayBy( buf, 8, {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 8, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 'float64', false ); // $ExpectError - filledarrayBy( buf, 8, 'float64', true ); // $ExpectError - filledarrayBy( buf, 8, 'float64', null ); // $ExpectError - filledarrayBy( buf, 8, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 8, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 8, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 8, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, '5' ); // $ExpectError - filledarrayBy( buf, 8, 2, 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 2, false ); // $ExpectError - filledarrayBy( buf, 8, 2, true ); // $ExpectError - filledarrayBy( buf, 8, 2, null ); // $ExpectError - filledarrayBy( buf, 8, 2, undefined ); // $ExpectError - filledarrayBy( buf, 8, 2, [] ); // $ExpectError - filledarrayBy( buf, 8, 2, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, false, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, true, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, null, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, [], {} ); // $ExpectError - filledarrayBy( buf, 8, 2, {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', false ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', true ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', null ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', {}, {} ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid length, typed array, array-like object, `ArrayBuffer`, or iterable argument... -{ - filledarrayBy( false, clbk ); // $ExpectError - filledarrayBy( true, clbk ); // $ExpectError - filledarrayBy( null, clbk ); // $ExpectError - filledarrayBy( {}, clbk ); // $ExpectError - - filledarrayBy( false, clbk, {} ); // $ExpectError - filledarrayBy( true, clbk, {} ); // $ExpectError - filledarrayBy( null, clbk, {} ); // $ExpectError - filledarrayBy( {}, clbk, {} ); // $ExpectError - - filledarrayBy( false, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 'float64', clbk ); // $ExpectError - - filledarrayBy( false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, clbk ); // $ExpectError - filledarrayBy( 1.0, 8, clbk ); // $ExpectError - filledarrayBy( false, 8, clbk ); // $ExpectError - filledarrayBy( true, 8, clbk ); // $ExpectError - filledarrayBy( null, 8, clbk ); // $ExpectError - filledarrayBy( undefined, 8, clbk ); // $ExpectError - filledarrayBy( [], 8, clbk ); // $ExpectError - filledarrayBy( {}, 8, clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, clbk ); // $ExpectError - - filledarrayBy( '5', 8, clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, clbk, {} ); // $ExpectError - filledarrayBy( false, 8, clbk, {} ); // $ExpectError - filledarrayBy( true, 8, clbk, {} ); // $ExpectError - filledarrayBy( null, 8, clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, clbk, {} ); // $ExpectError - filledarrayBy( [], 8, clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 'float64', clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( false, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( [], 8, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 'float64', clbk ); // $ExpectError - - filledarrayBy( '5', 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 2, clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 2, clbk ); // $ExpectError - filledarrayBy( false, 8, 2, clbk ); // $ExpectError - filledarrayBy( true, 8, 2, clbk ); // $ExpectError - filledarrayBy( null, 8, 2, clbk ); // $ExpectError - filledarrayBy( undefined, 8, 2, clbk ); // $ExpectError - filledarrayBy( [], 8, 2, clbk ); // $ExpectError - filledarrayBy( {}, 8, 2, clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, clbk ); // $ExpectError - - filledarrayBy( '5', 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( false, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( [], 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, 'float64', clbk ); // $ExpectError - - filledarrayBy( '5', 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a byte offset argument which is not a number... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, false, clbk ); // $ExpectError - filledarrayBy( buf, true, clbk ); // $ExpectError - filledarrayBy( buf, null, clbk ); // $ExpectError - filledarrayBy( buf, [], clbk ); // $ExpectError - filledarrayBy( buf, {}, clbk ); // $ExpectError - - filledarrayBy( buf, false, clbk, {} ); // $ExpectError - filledarrayBy( buf, true, clbk, {} ); // $ExpectError - filledarrayBy( buf, null, clbk, {} ); // $ExpectError - filledarrayBy( buf, [], clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, clbk, {} ); // $ExpectError - - filledarrayBy( buf, '5', 'float64', clbk ); // $ExpectError - filledarrayBy( buf, false, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, true, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, null, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, [], 'float64', clbk ); // $ExpectError - filledarrayBy( buf, {}, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, '5', 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( buf, false, 2, clbk ); // $ExpectError - filledarrayBy( buf, true, 2, clbk ); // $ExpectError - filledarrayBy( buf, null, 2, clbk ); // $ExpectError - filledarrayBy( buf, [], 2, clbk ); // $ExpectError - filledarrayBy( buf, {}, 2, clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, clbk ); // $ExpectError - - filledarrayBy( buf, false, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, clbk, {} ); // $ExpectError - - filledarrayBy( buf, '5', 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, false, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, true, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, null, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, undefined, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, [], 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, {}, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, '5', 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, false, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, undefined, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a view length argument which is not a number... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, 8, false, clbk ); // $ExpectError - filledarrayBy( buf, 8, true, clbk ); // $ExpectError - filledarrayBy( buf, 8, null, clbk ); // $ExpectError - filledarrayBy( buf, 8, [], clbk ); // $ExpectError - filledarrayBy( buf, 8, {}, clbk ); // $ExpectError - - filledarrayBy( buf, 8, false, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, true, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, null, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, [], clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, {}, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, clbk, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5', 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, false, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, true, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, null, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, [], 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, {}, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, 8, '5', 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, [], 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, {}, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided too many arguments... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, 8, 2, 'float64', 1, clbk, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 997a381..0000000 --- a/examples/index.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ).factory; -var dtypes = require( '@stdlib/array-typed-real-dtypes' ); -var filledarrayBy = require( './../lib' ); - -// Create a pseudorandom number generator: -var rand = discreteUniform( 0, 100 ); - -// Get a list of array data types: -var dt = dtypes(); - -// Generate filled arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = filledarrayBy( 10, dt[ i ], rand ); - console.log( arr ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index b1fd829..e1b94a1 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, RealOrComplexTypedArray, DataType } from '@stdlib/types/array'; import { IterableIterator } from '@stdlib/types/iter'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..8499817 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.1-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-ctors@v0.2.1-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill-by@v0.2.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled-by@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.2.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.1-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@v0.2.1-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.2.1-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";var j=d(),a=p.get("dtypes.default");function v(){var d,p,v,c,g,y,b,u;if(0===(p=arguments.length))return new(g=o(a))(0);if(r(v=arguments[0])){if(p>1)throw new TypeError(w("00h05"));if(null===(g=o(v)))throw new TypeError(w("00h2Y",v));return new g(0)}if(p<2)throw new TypeError(w("00h05"));if(n(arguments[p-=1]))if(n(arguments[p-1])){if(d=arguments[p],c=arguments[p-=1],0===p)throw new TypeError(w("00h05"))}else c=arguments[p];else{if(!(p>=2))throw new TypeError(w("00h05"));if(d=arguments[p],!n(c=arguments[p-=1]))throw new TypeError(w("00h2b",c))}if((p-=1)>=0&&r(arguments[p])?(v=arguments[p],p-=1):v=a,null===(g=o(v)))throw new TypeError(w("00h2Y",v));if("generic"===v){if(u=arguments[0],0===p){if(e(u)?b=u:t(u)&&(b=u.length),void 0!==b)return l(b,c,d);if(s(u))throw new Error(w("00h04"));if(i(u)){if(!1===j)throw new TypeError(w("00h2Z",u));if(!n(u[m]))throw new TypeError(w("00h2a",u));if(u=u[m](),!n(u.next))throw new TypeError(w("00h2a",u));return function(r,e,t){var s,i;for(s=[],i=-1;!r.next().done;)i+=1,s.push(e.call(t,i));return s}(u,c,d)}throw new TypeError(w("00h2a",u))}if(s(u))throw new Error(w("00h04"));throw new TypeError(w("00h2a",u))}if(0===p)if(t(u=arguments[0]))y=new g(u.length);else if(s(u))y=new g(u);else if(e(u))y=new g(u);else{if(!i(u))throw new TypeError(w("00h2a",u));if(!1===j)throw new TypeError(w("00h2Z",u));if(!n(u[m]))throw new TypeError(w("00h2a",u));if(u=u[m](),!n(u.next))throw new TypeError(w("00h2a",u));y=new g(f(u))}else y=1===p?new g(arguments[0],arguments[1]):new g(arguments[0],arguments[1],arguments[2]);return y.length>0&&(/^complex/.test(v)?function(r,e,t){var s;for(s=0;s\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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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( format('00h05') );\n\t\t}\n\t\tctor = ctors( dtype );\n\t\tif ( ctor === null ) {\n\t\t\tthrow new TypeError( format( '00h2Y', 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( format('00h05') );\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( format('00h05') );\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( '00h2b', 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( format('00h05') );\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( '00h2Y', 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( format('00h04') );\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( '00h2Z', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00h2a', 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( '00h2a', 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( '00h2a', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format('00h04') );\n\t\t}\n\t\tthrow new TypeError( format( '00h2a', 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( '00h2Z', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00h2a', 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( '00h2a', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00h2a', 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\nexport default filledarrayBy;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","DEFAULT_DTYPE","defaults","get","filledarrayBy","thisArg","nargs","dtype","clbk","ctor","arr","len","arg","arguments","length","ctors","isString","TypeError","format","isFunction","isNonNegativeInteger","isCollection","filledArray","isArrayBuffer","Error","isObject","ITERATOR_SYMBOL","next","it","i","done","push","call","filledArrayIterator","iterLength","test","set","filledAccessors","gfillBy","value","aidx"],"mappings":";;q0CAwCA,IAAIA,EAAsBC,IACtBC,EAAgBC,EAASC,IAAK,kBA2MlC,SAASC,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAKJ,GAAe,KAHfN,EAAQO,UAAUC,QAKjB,OAAO,IADPL,EAAOM,EAAOd,IACG,GAIlB,GAAKe,EADLT,EAAQM,UAAW,IACM,CAExB,GAAKP,EAAQ,EACZ,MAAM,IAAIW,UAAWC,EAAO,UAG7B,GAAc,QADdT,EAAOM,EAAOR,IAEb,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,OAAO,IAAIE,EAAM,EACjB,CAED,GAAKH,EAAQ,EACZ,MAAM,IAAIW,UAAWC,EAAO,UAM7B,GAAKC,EAAYN,UAHjBP,GAAS,IAKR,GAAKa,EAAYN,UAAWP,EAAM,KAMjC,GALAD,EAAUQ,UAAWP,GAErBE,EAAOK,UADPP,GAAS,GAIM,IAAVA,EACJ,MAAM,IAAIW,UAAWC,EAAO,eAI7BV,EAAOK,UAAWP,OAIf,MAAKA,GAAS,GAUlB,MAAM,IAAIW,UAAWC,EAAO,UAN5B,GAHAb,EAAUQ,UAAWP,IAGfa,EADNX,EAAOK,UADPP,GAAS,IAGR,MAAM,IAAIW,UAAWC,EAAQ,QAASV,GAMvC,CAUD,IARAF,GAAS,IACK,GAAKU,EAAUH,UAAWP,KACvCC,EAAQM,UAAWP,GACnBA,GAAS,GAETC,EAAQN,EAGK,QADdQ,EAAOM,EAAOR,IAEb,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,GAAe,YAAVA,EAAsB,CAE1B,GADAK,EAAMC,UAAW,GACF,IAAVP,EAAc,CAMlB,GALKc,EAAsBR,GAC1BD,EAAMC,EACKS,EAAcT,KACzBD,EAAMC,EAAIE,aAEE,IAARH,EACJ,OAAOW,EAAaX,EAAKH,EAAMH,GAEhC,GAAKkB,EAAeX,GACnB,MAAM,IAAIY,MAAON,EAAO,UAEzB,GAAKO,EAAUb,GAAQ,CACtB,IAA6B,IAAxBb,EACJ,MAAM,IAAIkB,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAYP,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLP,EAAYP,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvC,OAvSJ,SAA8BgB,EAAIpB,EAAMH,GACvC,IAAIK,EACAmB,EAKJ,IAFAnB,EAAM,GACNmB,GAAK,GAEAD,EAAGD,OACAG,MAGPD,GAAK,EACLnB,EAAIqB,KAAMvB,EAAKwB,KAAM3B,EAASwB,IAE/B,OAAOnB,CACR,CAuRWuB,CAAqBrB,EAAKJ,EAAMH,EACvC,CACD,MAAM,IAAIY,UAAWC,EAAQ,QAASN,GACzC,CAAS,GAAKW,EAAeX,GAC1B,MAAM,IAAIY,MAAON,EAAO,UAEzB,MAAM,IAAID,UAAWC,EAAQ,QAASN,GACtC,CACD,GAAe,IAAVN,EAEJ,GAAKe,EADLT,EAAMC,UAAW,IAEhBH,EAAM,IAAID,EAAMG,EAAIE,aACd,GAAKS,EAAeX,GAC1BF,EAAM,IAAID,EAAMG,QACV,GAAKQ,EAAsBR,GACjCF,EAAM,IAAID,EAAMG,OACV,KAAKa,EAAUb,GAarB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAZtC,IAA6B,IAAxBb,EACJ,MAAM,IAAIkB,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAYP,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLP,EAAYP,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvCF,EAAM,IAAID,EAAMyB,EAAYtB,GAG5B,MAEDF,EADqB,IAAVJ,EACL,IAAIG,EAAMI,UAAU,GAAIA,UAAU,IAElC,IAAIJ,EAAMI,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKH,EAAII,OAAS,IACZ,WAAWqB,KAAM5B,GAjTxB,SAA0BG,EAAKF,EAAMH,GACpC,IAAIwB,EACJ,IAAMA,EAAI,EAAGA,EAAInB,EAAII,OAAQe,IAC5BnB,EAAI0B,IAAK5B,EAAKwB,KAAM3B,EAASwB,GAAKA,EAGpC,CA4SGQ,CAAiB3B,EAAKF,EAAMH,GAE5BiC,EAAS5B,EAAII,OAAQJ,EAAK,GAe5B,SAAmB6B,EAAOC,GACzB,OAAOhC,EAAKwB,KAAM3B,EAASmC,EAC3B,KAdM9B,CAeR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d115cf0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,192 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -/** -* Create a filled array according to a provided callback function. -* -* @module @stdlib/array-filled-by -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* var arr = filledarrayBy(); -* // returns -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'generic', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( [ 0.5, 0.5 ], clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1; -* } -* -* var arr = filledarrayBy( [ 5, -3 ], 'int32', clbk ); -* // returns [ 1, 1 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk1() { -* return 10; -* } -* -* function clbk2() { -* return 1.0; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, clbk2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk1() { -* return 1.0; -* } -* -* function clbk2() { -* return 2; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, 'uint32', clbk2 ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 'float32', clbk ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, clbk ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, 'int32', clbk ); -* // returns [ 1, 1 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 06bc8b6..0000000 --- a/lib/main.js +++ /dev/null @@ -1,414 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var isCollection = require( '@stdlib/assert-is-collection' ); -var isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isObject = require( '@stdlib/assert-is-object' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var ctors = require( '@stdlib/array-ctors' ); -var gfillBy = require( '@stdlib/blas-ext-base-gfill-by' ); -var filledArray = require( '@stdlib/array-base-filled-by' ); -var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var iterLength = require( '@stdlib/iter-length' ); -var defaults = require( '@stdlib/array-defaults' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport(); -var DEFAULT_DTYPE = defaults.get( 'dtypes.default' ); - - -// FUNCTIONS // - -/** -* Creates a filled "generic" array from an iterator. -* -* @private -* @param {Iterable} it - iterator -* @param {Callback} clbk - callback function -* @param {*} thisArg - callback function execution context -* @returns {Array} filled array -*/ -function filledArrayIterator( it, clbk, thisArg ) { - var arr; - var i; - var v; - - arr = []; - i = -1; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - i += 1; - arr.push( clbk.call( thisArg, i ) ); - } - return arr; -} - -/** -* Fills an array exposing accessors for getting and setting array elements. -* -* @private -* @param {Collection} arr - input array -* @param {Callback} clbk - callback function -* @param {*} thisArg - callback function execution context -* @returns {Collection} input array -*/ -function filledAccessors( arr, clbk, thisArg ) { - var i; - for ( i = 0; i < arr.length; i++ ) { - arr.set( clbk.call( thisArg, i ), i ); - } - return arr; -} - - -// MAIN // - -/** -* Creates a filled array according to a provided callback function. -* -* @param {(NonNegativeInteger|TypedArray|ArrayLikeObject|ArrayBuffer|Iterable)} [arg] - a length, typed array, array-like object, buffer, or iterable -* @param {NonNegativeInteger} [byteOffset=0] - byte offset -* @param {NonNegativeInteger} [length] - view length -* @param {string} [dtype="float64"] - data type -* @param {Callback} [clbk] - callback to invoke -* @param {*} [thisArg] - callback execution context -* @throws {TypeError} must provide a recognized data type -* @throws {TypeError} must provide a length, typed array, array-like object, buffer, or iterable -* @throws {TypeError} callback argument must be a function. -* @throws {Error} creating a generic array from an `ArrayBuffer` is not supported -* @returns {(TypedArray|Array)} array or typed array -* -* @example -* var arr = filledarrayBy(); -* // returns -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'generic', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( [ 0.5, 0.5 ], clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1; -* } -* -* var arr = filledarrayBy( [ 5, -3 ], 'int32', clbk ); -* // returns [ 1, 1 ] -* -* @example -* function clbk1() { -* return 10; -* } -* -* function clbk2() { -* return 1.0; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, clbk2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk1() { -* return 1.0; -* } -* -* function clbk2() { -* return 2; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, 'uint32', clbk2 ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 'float32', clbk ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, clbk ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, 'int32', clbk ); -* // returns [ 1, 1 ] -*/ -function filledarrayBy() { - var thisArg; - var nargs; - var dtype; - var clbk; - var ctor; - var arr; - var len; - var arg; - - nargs = arguments.length; - - // If we weren't provided any arguments, return an empty array... - if ( nargs === 0 ) { - ctor = ctors( DEFAULT_DTYPE ); - return new ctor( 0 ); - } - // Check if we were provided a dtype as the first argument... - dtype = arguments[ 0 ]; - if ( isString( dtype ) ) { - // Invoking this function with arguments `f( dtype, clbk[, thisArg] )` is not allowed (otherwise, we'd need to also allow `f( clbk[, thisArg] )`)... - if ( nargs > 1 ) { - throw new TypeError( format('00h05') ); - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '00h2Y', dtype ) ); - } - // Return an empty array having the specified dtype: - return new ctor( 0 ); - } - // For all other supported invocations, we need at least two arguments... - if ( nargs < 2 ) { - throw new TypeError( format('00h05') ); - } - // At this point, we need to do some argument juggling... - nargs -= 1; // henceforth, the number of available arguments is `nargs+1` - - // Determine whether the last argument is a callback or "this" context... - if ( isFunction( arguments[ nargs ] ) ) { - // 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... - if ( isFunction( arguments[ nargs-1 ] ) ) { - thisArg = arguments[ nargs ]; - nargs -= 1; - clbk = arguments[ nargs ]; - - // Check if we were provided only a callback and a "this" context.. - if ( nargs === 0 ) { - throw new TypeError( format('00h05') ); - } - } else { - // "this" context is left undefined... - clbk = arguments[ nargs ]; - } - } - // 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... - else if ( nargs >= 2 ) { - thisArg = arguments[ nargs ]; - nargs -= 1; - clbk = arguments[ nargs ]; - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '00h2b', clbk ) ); - } - } - // If were were only provided 2 arguments and the last argument was not a function, we've been provided an insufficient number of arguments... - else { - throw new TypeError( format('00h05') ); - } - // Now that we've processed the callback arguments, let's continue working backward to see if we've been provided a `dtype` argument... - nargs -= 1; - if ( nargs >= 0 && isString( arguments[ nargs ] ) ) { - dtype = arguments[ nargs ]; - nargs -= 1; - } else { - dtype = DEFAULT_DTYPE; - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '00h2Y', dtype ) ); - } - // At this point, we've resolved the output array data type, and now we can actually create the output array... - if ( dtype === 'generic' ) { - arg = arguments[ 0 ]; - if ( nargs === 0 ) { - if ( isNonNegativeInteger( arg ) ) { - len = arg; - } else if ( isCollection( arg ) ) { - len = arg.length; - } - if ( len !== void 0 ) { - return filledArray( len, clbk, thisArg ); - } - if ( isArrayBuffer( arg ) ) { - throw new Error( format('00h04') ); - } - if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( '00h2Z', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00h2a', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00h2a', arg ) ); - } - return filledArrayIterator( arg, clbk, thisArg ); - } - throw new TypeError( format( '00h2a', arg ) ); - } else if ( isArrayBuffer( arg ) ) { - throw new Error( format('00h04') ); - } - throw new TypeError( format( '00h2a', arg ) ); - } - if ( nargs === 0 ) { // length || array-like || ArrayBuffer || iterable - arg = arguments[ 0 ]; - if ( isCollection( arg ) ) { - arr = new ctor( arg.length ); - } else if ( isArrayBuffer( arg ) ) { - arr = new ctor( arg ); - } else if ( isNonNegativeInteger( arg ) ) { - arr = new ctor( arg ); - } else if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( '00h2Z', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00h2a', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00h2a', arg ) ); - } - arr = new ctor( iterLength( arg ) ); - } else { - throw new TypeError( format( '00h2a', arg ) ); - } - } else if ( nargs === 1 ) { - arr = new ctor( arguments[0], arguments[1] ); // (ArrayBuffer, byteOffset) - } else { - arr = new ctor( arguments[0], arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset, length) - } - if ( arr.length > 0 ) { - if ( /^complex/.test( dtype ) ) { - filledAccessors( arr, clbk, thisArg ); - } else { - gfillBy( arr.length, arr, 1, callback ); - } - } - return arr; - - /** - * Callback which wraps a provided callback and is invoked for each array element. - * - * @private - * @param {*} value - element value - * @param {NonNegativeInteger} aidx - array index - * @param {NonNegativeInteger} sidx - strided index - * @param {Collection} array - input array/collection - * @returns {*} callback return value - */ - function callback( value, aidx ) { - return clbk.call( thisArg, aidx ); - } -} - - -// EXPORTS // - -module.exports = filledarrayBy; diff --git a/package.json b/package.json index 7d042f2..b16be36 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Create a filled array according to a provided callback function.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,71 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-filled-by": "^0.2.1", - "@stdlib/array-ctors": "^0.2.1", - "@stdlib/array-defaults": "^0.2.1", - "@stdlib/assert-has-iterator-symbol-support": "^0.2.1", - "@stdlib/assert-is-arraybuffer": "^0.2.1", - "@stdlib/assert-is-collection": "^0.2.1", - "@stdlib/assert-is-function": "^0.2.1", - "@stdlib/assert-is-nonnegative-integer": "^0.2.1", - "@stdlib/assert-is-object": "^0.2.1", - "@stdlib/assert-is-string": "^0.2.1", - "@stdlib/blas-ext-base-gfill-by": "^0.2.1", - "@stdlib/iter-length": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1", - "@stdlib/symbol-iterator": "^0.2.1", - "@stdlib/types": "^0.3.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/array-buffer": "^0.2.1", - "@stdlib/array-complex128": "^0.2.0", - "@stdlib/array-complex64": "^0.2.0", - "@stdlib/array-float32": "^0.2.1", - "@stdlib/array-float64": "^0.2.1", - "@stdlib/array-int16": "^0.2.1", - "@stdlib/array-int32": "^0.2.1", - "@stdlib/array-int8": "^0.2.1", - "@stdlib/array-typed-real-dtypes": "^0.2.1", - "@stdlib/array-uint16": "^0.2.1", - "@stdlib/array-uint32": "^0.2.1", - "@stdlib/array-uint8": "^0.2.1", - "@stdlib/array-uint8c": "^0.2.1", - "@stdlib/assert-instance-of": "^0.2.1", - "@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": "^0.2.1", - "@stdlib/complex-float64": "^0.2.1", - "@stdlib/iter-constant": "^0.2.1", - "@stdlib/math-base-special-pow": "^0.2.1", - "@stdlib/random-base-discrete-uniform": "^0.2.0", - "@stdlib/strided-base-reinterpret-complex128": "^0.2.1", - "@stdlib/strided-base-reinterpret-complex64": "^0.2.0", - "@stdlib/utils-constant-function": "^0.2.1", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.1" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..ad91791 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index b55aa4a..0000000 --- a/test/test.js +++ /dev/null @@ -1,4248 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 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. -*/ - -/* eslint-disable max-len */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -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 ArrayBuffer = require( '@stdlib/array-buffer' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var iterConstant = require( '@stdlib/iter-constant' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var filledarrayBy = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': !hasIteratorSymbolSupport() -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof filledarrayBy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if only provided callback arguments', function test( t ) { - t.throws( clbk1, TypeError, 'throws an error' ); - t.throws( clbk2, TypeError, 'throws an error' ); - t.throws( clbk3, TypeError, 'throws an error' ); - t.end(); - - function clbk1() { - filledarrayBy( constantFunction( 1.0 ) ); - } - - function clbk2() { - filledarrayBy( constantFunction( 1.0 ), {} ); - } - - function clbk3() { - filledarrayBy( constantFunction( 1.0 ), constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (only argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (typed array; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (array-like object)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (array-like object; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 8 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 8 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, 1, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (iterator)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( iterConstant( 1.0 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (iterator; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( iterConstant( 1.0 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if only provided data type and callback arguments', function test( t ) { - t.throws( clbk1, TypeError, 'throws an error' ); - t.throws( clbk2, TypeError, 'throws an error' ); - t.throws( clbk3, TypeError, 'throws an error' ); - t.end(); - - function clbk1() { - filledarrayBy( 'float64', constantFunction( 1.0 ) ); - } - - function clbk2() { - filledarrayBy( 'float64', constantFunction( 1.0 ), {} ); - } - - function clbk3() { - filledarrayBy( 'float64', constantFunction( 1.0 ), constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (array-like object)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (array-like object; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, 1, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, 1, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (no iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (no iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (non-function iterator symbol property)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (non-function iterator symbol property; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (`next` property is not a function)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ) ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (`next` property is not a function; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ), {} ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (no iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (no iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (non-function iterator symbol property)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (non-function iterator symbol property; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (`next` property is not a function)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ) ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (`next` property is not a function; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ), {} ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 1, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 1, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function returns a filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - arr = filledarrayBy(); - - t.strictEqual( instanceOf( arr, Float64Array ), 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=float64)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - arr = filledarrayBy( 'float64' ); - - t.strictEqual( instanceOf( arr, Float64Array ), 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=float32)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( 0 ); - arr = filledarrayBy( 'float32' ); - - t.strictEqual( instanceOf( arr, Float32Array ), 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; - - expected = new Complex128Array( 0 ); - arr = filledarrayBy( 'complex128' ); - - t.strictEqual( instanceOf( arr, Complex128Array ), 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=complex64)', function test( t ) { - var expected; - var arr; - - expected = new Complex64Array( 0 ); - arr = filledarrayBy( 'complex64' ); - - t.strictEqual( instanceOf( arr, Complex64Array ), 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=int32)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( 0 ); - arr = filledarrayBy( 'int32' ); - - t.strictEqual( instanceOf( arr, Int32Array ), 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=uint32)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( 0 ); - arr = filledarrayBy( 'uint32' ); - - t.strictEqual( instanceOf( arr, Uint32Array ), 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=int16)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( 0 ); - arr = filledarrayBy( 'int16' ); - - t.strictEqual( instanceOf( arr, Int16Array ), 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=uint16)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( 0 ); - arr = filledarrayBy( 'uint16' ); - - t.strictEqual( instanceOf( arr, Uint16Array ), 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=int8)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( 0 ); - arr = filledarrayBy( 'int8' ); - - t.strictEqual( instanceOf( arr, Int8Array ), 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=uint8)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( 0 ); - arr = filledarrayBy( 'uint8' ); - - t.strictEqual( instanceOf( arr, Uint8Array ), 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=uint8c)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( 0 ); - arr = filledarrayBy( 'uint8c' ); - - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), 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=generic)', function test( t ) { - var expected; - var arr; - - expected = []; - arr = filledarrayBy( 'generic' ); - - t.strictEqual( instanceOf( arr, Array ), 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 (default, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, length=0)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array(); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 0, clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, clbk, ctx ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (default, length; thisArg=function)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, clbk, context ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this(); // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } - - function context() { - ctx.count += 1; - } -}); - -tape( 'the function returns a filled array (dtype=float64, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, 'float64', clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, length; thisArg=function)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, 'float64', clbk, context ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this(); // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } - - function context() { - ctx.count += 1; - } -}); - -tape( 'the function returns a filled array (dtype=float32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, 'float32', clbk ); - - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex128, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = filledarrayBy( 5, 'complex128', clbk ); - - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = filledarrayBy( 5, 'complex64', clbk ); - - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int32Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int32', clbk ); - - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint32Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint32', clbk ); - - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int16Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int16', clbk ); - - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint16', clbk ); - - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int8Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int8', clbk ); - - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint8', clbk ); - - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint8c', clbk ); - - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = [ 1, 1, 1, 1, 1 ]; - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'generic', clbk ); - - t.strictEqual( instanceOf( arr, Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex128, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = [ 1.0, 2.0 ]; - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = [ 1.0, 2.0 ]; - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int32', clbk ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, typed array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, typed array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex128, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = new Float64Array( [ 1.0, 2.0 ] ); - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = new Float64Array( [ 1.0, 2.0 ] ); - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (default, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex128, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer, byteoffset; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer, byteoffset; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, 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; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 48 ); - out = filledarrayBy( buf, 16, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 24 ); - out = filledarrayBy( buf, 8, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int32', clbk ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint8c', clbk ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, 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; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 64 ); - out = filledarrayBy( buf, 16, 2, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset, length)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 1, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 1, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled array (default, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, iterator; thisArg)', opts, function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - ctx = { - 'count': 0 - }; - indices = []; - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, iterator; thisArg)', opts, function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - ctx = { - 'count': 0 - }; - indices = []; - out = filledarrayBy( arr, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex128, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = iterConstant( new Complex128( 3.0, 3.0 ), { - 'iter': 2 - }); - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = iterConstant( new Complex64( 3.0, 3.0 ), { - 'iter': 2 - }); - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); From afb31345edeaef8d1b82a7885ded361949cba640 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 25 Feb 2024 22:14:22 +0000 Subject: [PATCH 049/117] Update README.md for ESM bundle v0.2.1 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e799105..eaa6959 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import filledarrayBy from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-filled-by@esm/index.mjs'; +import filledarrayBy from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-filled-by@v0.2.1-esm/index.mjs'; ``` #### filledarrayBy( \[dtype] ) @@ -227,7 +227,7 @@ arr = filledarrayBy( buf, 10, 4, 'int16', clbk ); var discreteUniform = require( 'https://cdn.jsdelivr.net/gh/stdlib-js/random-base-discrete-uniform' ).factory; import dtypes from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-typed-real-dtypes@esm/index.mjs'; -import filledarrayBy from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-filled-by@esm/index.mjs'; +import filledarrayBy from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-filled-by@v0.2.1-esm/index.mjs'; // Create a pseudorandom number generator: var rand = discreteUniform( 0, 100 ); From 25ea84cfa0c8a1c064b9db7014f4dbc000acafcd Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 25 Feb 2024 22:14:22 +0000 Subject: [PATCH 050/117] Auto-generated commit --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index eaa6959..a66917a 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,11 @@ limitations under the License. ## Usage +```javascript +import filledarrayBy from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-filled-by@esm/index.mjs'; +``` +The previous example will load the latest bundled code from the esm branch. Alternatively, you may load a specific version by loading the file from one of the [tagged bundles](https://github.com/stdlib-js/array-filled-by/tags). For example, + ```javascript import filledarrayBy from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-filled-by@v0.2.1-esm/index.mjs'; ``` @@ -227,7 +232,7 @@ arr = filledarrayBy( buf, 10, 4, 'int16', clbk ); var discreteUniform = require( 'https://cdn.jsdelivr.net/gh/stdlib-js/random-base-discrete-uniform' ).factory; import dtypes from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-typed-real-dtypes@esm/index.mjs'; -import filledarrayBy from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-filled-by@v0.2.1-esm/index.mjs'; +import filledarrayBy from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-filled-by@esm/index.mjs'; // Create a pseudorandom number generator: var rand = discreteUniform( 0, 100 ); From 3f193ed5a4eb030186c16df5150b144637cd9355 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Mar 2024 08:33:06 +0000 Subject: [PATCH 051/117] Transform error messages --- lib/main.js | 38 +++++++++++++++++++------------------- package.json | 2 +- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/lib/main.js b/lib/main.js index 0f134bb..06bc8b6 100644 --- a/lib/main.js +++ b/lib/main.js @@ -33,7 +33,7 @@ var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-supp var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); var iterLength = require( '@stdlib/iter-length' ); var defaults = require( '@stdlib/array-defaults' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -264,18 +264,18 @@ function filledarrayBy() { if ( isString( dtype ) ) { // Invoking this function with arguments `f( dtype, clbk[, thisArg] )` is not allowed (otherwise, we'd need to also allow `f( clbk[, thisArg] )`)... if ( nargs > 1 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format('00h05') ); } ctor = ctors( dtype ); if ( ctor === null ) { - throw new TypeError( format( 'invalid argument. Must provide a recognized data type. Value: `%s`.', dtype ) ); + throw new TypeError( format( '00h2Y', dtype ) ); } // Return an empty array having the specified dtype: return new ctor( 0 ); } // For all other supported invocations, we need at least two arguments... if ( nargs < 2 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format('00h05') ); } // At this point, we need to do some argument juggling... nargs -= 1; // henceforth, the number of available arguments is `nargs+1` @@ -290,7 +290,7 @@ function filledarrayBy() { // Check if we were provided only a callback and a "this" context.. if ( nargs === 0 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format('00h05') ); } } else { // "this" context is left undefined... @@ -303,12 +303,12 @@ function filledarrayBy() { nargs -= 1; clbk = arguments[ nargs ]; if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '00h2b', clbk ) ); } } // If were were only provided 2 arguments and the last argument was not a function, we've been provided an insufficient number of arguments... else { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format('00h05') ); } // Now that we've processed the callback arguments, let's continue working backward to see if we've been provided a `dtype` argument... nargs -= 1; @@ -320,7 +320,7 @@ function filledarrayBy() { } ctor = ctors( dtype ); if ( ctor === null ) { - throw new TypeError( format( 'invalid argument. Must provide a recognized data type. Value: `%s`.', dtype ) ); + throw new TypeError( format( '00h2Y', dtype ) ); } // At this point, we've resolved the output array data type, and now we can actually create the output array... if ( dtype === 'generic' ) { @@ -335,26 +335,26 @@ function filledarrayBy() { return filledArray( len, clbk, thisArg ); } if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format('00h04') ); } if ( isObject( arg ) ) { if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2Z', arg ) ); } if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } arg = arg[ ITERATOR_SYMBOL ](); if ( !isFunction( arg.next ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } return filledArrayIterator( arg, clbk, thisArg ); } - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } else if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format('00h04') ); } - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } if ( nargs === 0 ) { // length || array-like || ArrayBuffer || iterable arg = arguments[ 0 ]; @@ -366,18 +366,18 @@ function filledarrayBy() { arr = new ctor( arg ); } else if ( isObject( arg ) ) { if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2Z', arg ) ); } if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } arg = arg[ ITERATOR_SYMBOL ](); if ( !isFunction( arg.next ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } arr = new ctor( iterLength( arg ) ); } else { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } } else if ( nargs === 1 ) { arr = new ctor( arguments[0], arguments[1] ); // (ArrayBuffer, byteOffset) diff --git a/package.json b/package.json index 8efaed0..fe41e9b 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "@stdlib/assert-is-string": "^0.2.1", "@stdlib/blas-ext-base-gfill-by": "^0.2.1", "@stdlib/iter-length": "^0.2.1", - "@stdlib/string-format": "^0.2.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1", "@stdlib/symbol-iterator": "^0.2.1", "@stdlib/types": "^0.3.2", "@stdlib/error-tools-fmtprodmsg": "^0.2.1" From cc8a3263047e369a21b8f8374a140e3ad0a45121 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Mar 2024 14:19:54 +0000 Subject: [PATCH 052/117] Remove files --- index.d.ts | 426 ----- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5273 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index e1b94a1..0000000 --- a/index.d.ts +++ /dev/null @@ -1,426 +0,0 @@ -/* -* @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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, RealOrComplexTypedArray, DataType } from '@stdlib/types/array'; -import { IterableIterator } from '@stdlib/types/iter'; - -/** -* Array or typed array. -*/ -type ArrayOrTypedArray = Array | RealOrComplexTypedArray; - -/** -* Nullary callback function. -* -* @returns fill value -*/ -type Nullary = () => any; - -/** -* Unary callback function. -* -* @param i - current array index -* @returns fill value -*/ -type Unary = ( i: number ) => any; - -/** -* Callback function. -* -* @param i - current array index -* @returns fill value -*/ -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 -* -* @example -* var arr = filledarrayBy(); -* // returns -* -* @example -* var arr = filledarrayBy( 'float32' ); -* // returns -*/ -declare function filledarrayBy( dtype?: DataType ): ArrayOrTypedArray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Creates a filled array according to a provided callback function and having a specified `length`. -* -* @param length - array length -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* -* var arr = filledarrayBy( 5, constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( length: number, clbk: Callback, thisArg?: any ): ArrayOrTypedArray; - -/** -* 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 -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* -* var arr = filledarrayBy( 5, 'float64', constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( length: number, dtype: DataType, clbk: Callback, thisArg?: any ): ArrayOrTypedArray; - -/** -* Creates a filled array from another `array` according to a provided callback function. -* -* @param array - typed array or array-like object -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* -* 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; - -/** -* 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 -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* -* 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; - -/** -* Creates a filled array from an iterable according to a callback function. -* -* @param iterable - iterable -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var iterConstant = require( '@stdlib/iter-constant' ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarrayBy( it, constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( iterable: IterableIterator, callback: Callback, thisArg?: any ): ArrayOrTypedArray; - -/** -* 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 -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var iterConstant = require( '@stdlib/iter-constant' ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* 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; - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; - -/** -* 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. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; - -/** -* 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. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; - -/** -* 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. -* -* @param buffer - `ArrayBuffer` -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; - - -// EXPORTS // - -export = filledarrayBy; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 8499817..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.1-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-ctors@v0.2.1-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill-by@v0.2.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled-by@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.2.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.1-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@v0.2.1-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.2.1-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";var j=d(),a=p.get("dtypes.default");function v(){var d,p,v,c,g,y,b,u;if(0===(p=arguments.length))return new(g=o(a))(0);if(r(v=arguments[0])){if(p>1)throw new TypeError(w("00h05"));if(null===(g=o(v)))throw new TypeError(w("00h2Y",v));return new g(0)}if(p<2)throw new TypeError(w("00h05"));if(n(arguments[p-=1]))if(n(arguments[p-1])){if(d=arguments[p],c=arguments[p-=1],0===p)throw new TypeError(w("00h05"))}else c=arguments[p];else{if(!(p>=2))throw new TypeError(w("00h05"));if(d=arguments[p],!n(c=arguments[p-=1]))throw new TypeError(w("00h2b",c))}if((p-=1)>=0&&r(arguments[p])?(v=arguments[p],p-=1):v=a,null===(g=o(v)))throw new TypeError(w("00h2Y",v));if("generic"===v){if(u=arguments[0],0===p){if(e(u)?b=u:t(u)&&(b=u.length),void 0!==b)return l(b,c,d);if(s(u))throw new Error(w("00h04"));if(i(u)){if(!1===j)throw new TypeError(w("00h2Z",u));if(!n(u[m]))throw new TypeError(w("00h2a",u));if(u=u[m](),!n(u.next))throw new TypeError(w("00h2a",u));return function(r,e,t){var s,i;for(s=[],i=-1;!r.next().done;)i+=1,s.push(e.call(t,i));return s}(u,c,d)}throw new TypeError(w("00h2a",u))}if(s(u))throw new Error(w("00h04"));throw new TypeError(w("00h2a",u))}if(0===p)if(t(u=arguments[0]))y=new g(u.length);else if(s(u))y=new g(u);else if(e(u))y=new g(u);else{if(!i(u))throw new TypeError(w("00h2a",u));if(!1===j)throw new TypeError(w("00h2Z",u));if(!n(u[m]))throw new TypeError(w("00h2a",u));if(u=u[m](),!n(u.next))throw new TypeError(w("00h2a",u));y=new g(f(u))}else y=1===p?new g(arguments[0],arguments[1]):new g(arguments[0],arguments[1],arguments[2]);return y.length>0&&(/^complex/.test(v)?function(r,e,t){var s;for(s=0;s\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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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( format('00h05') );\n\t\t}\n\t\tctor = ctors( dtype );\n\t\tif ( ctor === null ) {\n\t\t\tthrow new TypeError( format( '00h2Y', 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( format('00h05') );\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( format('00h05') );\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( '00h2b', 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( format('00h05') );\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( '00h2Y', 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( format('00h04') );\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( '00h2Z', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00h2a', 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( '00h2a', 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( '00h2a', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format('00h04') );\n\t\t}\n\t\tthrow new TypeError( format( '00h2a', 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( '00h2Z', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00h2a', 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( '00h2a', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00h2a', 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\nexport default filledarrayBy;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","DEFAULT_DTYPE","defaults","get","filledarrayBy","thisArg","nargs","dtype","clbk","ctor","arr","len","arg","arguments","length","ctors","isString","TypeError","format","isFunction","isNonNegativeInteger","isCollection","filledArray","isArrayBuffer","Error","isObject","ITERATOR_SYMBOL","next","it","i","done","push","call","filledArrayIterator","iterLength","test","set","filledAccessors","gfillBy","value","aidx"],"mappings":";;q0CAwCA,IAAIA,EAAsBC,IACtBC,EAAgBC,EAASC,IAAK,kBA2MlC,SAASC,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAKJ,GAAe,KAHfN,EAAQO,UAAUC,QAKjB,OAAO,IADPL,EAAOM,EAAOd,IACG,GAIlB,GAAKe,EADLT,EAAQM,UAAW,IACM,CAExB,GAAKP,EAAQ,EACZ,MAAM,IAAIW,UAAWC,EAAO,UAG7B,GAAc,QADdT,EAAOM,EAAOR,IAEb,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,OAAO,IAAIE,EAAM,EACjB,CAED,GAAKH,EAAQ,EACZ,MAAM,IAAIW,UAAWC,EAAO,UAM7B,GAAKC,EAAYN,UAHjBP,GAAS,IAKR,GAAKa,EAAYN,UAAWP,EAAM,KAMjC,GALAD,EAAUQ,UAAWP,GAErBE,EAAOK,UADPP,GAAS,GAIM,IAAVA,EACJ,MAAM,IAAIW,UAAWC,EAAO,eAI7BV,EAAOK,UAAWP,OAIf,MAAKA,GAAS,GAUlB,MAAM,IAAIW,UAAWC,EAAO,UAN5B,GAHAb,EAAUQ,UAAWP,IAGfa,EADNX,EAAOK,UADPP,GAAS,IAGR,MAAM,IAAIW,UAAWC,EAAQ,QAASV,GAMvC,CAUD,IARAF,GAAS,IACK,GAAKU,EAAUH,UAAWP,KACvCC,EAAQM,UAAWP,GACnBA,GAAS,GAETC,EAAQN,EAGK,QADdQ,EAAOM,EAAOR,IAEb,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,GAAe,YAAVA,EAAsB,CAE1B,GADAK,EAAMC,UAAW,GACF,IAAVP,EAAc,CAMlB,GALKc,EAAsBR,GAC1BD,EAAMC,EACKS,EAAcT,KACzBD,EAAMC,EAAIE,aAEE,IAARH,EACJ,OAAOW,EAAaX,EAAKH,EAAMH,GAEhC,GAAKkB,EAAeX,GACnB,MAAM,IAAIY,MAAON,EAAO,UAEzB,GAAKO,EAAUb,GAAQ,CACtB,IAA6B,IAAxBb,EACJ,MAAM,IAAIkB,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAYP,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLP,EAAYP,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvC,OAvSJ,SAA8BgB,EAAIpB,EAAMH,GACvC,IAAIK,EACAmB,EAKJ,IAFAnB,EAAM,GACNmB,GAAK,GAEAD,EAAGD,OACAG,MAGPD,GAAK,EACLnB,EAAIqB,KAAMvB,EAAKwB,KAAM3B,EAASwB,IAE/B,OAAOnB,CACR,CAuRWuB,CAAqBrB,EAAKJ,EAAMH,EACvC,CACD,MAAM,IAAIY,UAAWC,EAAQ,QAASN,GACzC,CAAS,GAAKW,EAAeX,GAC1B,MAAM,IAAIY,MAAON,EAAO,UAEzB,MAAM,IAAID,UAAWC,EAAQ,QAASN,GACtC,CACD,GAAe,IAAVN,EAEJ,GAAKe,EADLT,EAAMC,UAAW,IAEhBH,EAAM,IAAID,EAAMG,EAAIE,aACd,GAAKS,EAAeX,GAC1BF,EAAM,IAAID,EAAMG,QACV,GAAKQ,EAAsBR,GACjCF,EAAM,IAAID,EAAMG,OACV,KAAKa,EAAUb,GAarB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAZtC,IAA6B,IAAxBb,EACJ,MAAM,IAAIkB,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAYP,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLP,EAAYP,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvCF,EAAM,IAAID,EAAMyB,EAAYtB,GAG5B,MAEDF,EADqB,IAAVJ,EACL,IAAIG,EAAMI,UAAU,GAAIA,UAAU,IAElC,IAAIJ,EAAMI,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKH,EAAII,OAAS,IACZ,WAAWqB,KAAM5B,GAjTxB,SAA0BG,EAAKF,EAAMH,GACpC,IAAIwB,EACJ,IAAMA,EAAI,EAAGA,EAAInB,EAAII,OAAQe,IAC5BnB,EAAI0B,IAAK5B,EAAKwB,KAAM3B,EAASwB,GAAKA,EAGpC,CA4SGQ,CAAiB3B,EAAKF,EAAMH,GAE5BiC,EAAS5B,EAAII,OAAQJ,EAAK,GAe5B,SAAmB6B,EAAOC,GACzB,OAAOhC,EAAKwB,KAAM3B,EAASmC,EAC3B,KAdM9B,CAeR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index ad91791..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 4967967c394cea99cb98a2cd541e61e308c73e93 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Mar 2024 14:20:12 +0000 Subject: [PATCH 053/117] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 ---- .github/workflows/publish.yml | 249 -- .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 132 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 229 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 47 +- SECURITY.md | 5 - benchmark/benchmark.js | 319 -- benchmark/benchmark.length.complex128.js | 98 - benchmark/benchmark.length.complex64.js | 98 - benchmark/benchmark.length.float32.js | 97 - benchmark/benchmark.length.float64.js | 97 - benchmark/benchmark.length.generic.js | 97 - benchmark/benchmark.length.int16.js | 97 - benchmark/benchmark.length.int32.js | 97 - benchmark/benchmark.length.int8.js | 97 - benchmark/benchmark.length.uint16.js | 97 - benchmark/benchmark.length.uint32.js | 97 - benchmark/benchmark.length.uint8.js | 97 - benchmark/benchmark.length.uint8c.js | 97 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 174 - docs/types/test.ts | 606 --- examples/index.js | 37 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 192 - lib/main.js | 414 -- package.json | 92 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 4248 ------------------ 55 files changed, 4869 insertions(+), 10547 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.length.complex128.js delete mode 100644 benchmark/benchmark.length.complex64.js delete mode 100644 benchmark/benchmark.length.float32.js delete mode 100644 benchmark/benchmark.length.float64.js delete mode 100644 benchmark/benchmark.length.generic.js delete mode 100644 benchmark/benchmark.length.int16.js delete mode 100644 benchmark/benchmark.length.int32.js delete mode 100644 benchmark/benchmark.length.int8.js delete mode 100644 benchmark/benchmark.length.uint16.js delete mode 100644 benchmark/benchmark.length.uint32.js delete mode 100644 benchmark/benchmark.length.uint8.js delete mode 100644 benchmark/benchmark.length.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 4a8b4ad..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-03-01T06:11:01.683Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 8be0b82..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index f988046..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index b2c1f9c..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '42 6 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 9106b5d..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -293,7 +284,7 @@ for ( i = 0; i < dt.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -364,9 +355,9 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/filled]: https://github.com/stdlib-js/array-filled +[@stdlib/array/filled]: https://github.com/stdlib-js/array-filled/tree/esm -[@stdlib/array/typed]: https://github.com/stdlib-js/array-typed +[@stdlib/array/typed]: https://github.com/stdlib-js/array-typed/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 67ba493..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,319 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); -var isArray = require( '@stdlib/assert-is-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var pkg = require( './../package.json' ).name; -var filledarrayBy = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 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=float64', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'float64', 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=float32', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'float32', 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; - var i; - - clbk = constantFunction( new Complex128( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'complex128', 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=complex64', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( new Complex64( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'complex64', 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=int32', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int32', 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=uint32', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint32', 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=int16', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int16', 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=uint16', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint16', 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=int8', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int8', 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=uint8', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint8', 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=uint8c', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint8c', 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=generic', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'generic', clbk ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.length.complex128.js b/benchmark/benchmark.length.complex128.js deleted file mode 100644 index 27f6c66..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 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 Complex128 = require( '@stdlib/complex-float64' ); -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( new Complex128( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'complex128', 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=complex128,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.complex64.js b/benchmark/benchmark.length.complex64.js deleted file mode 100644 index c094ae9..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 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 Complex64 = require( '@stdlib/complex-float32' ); -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( new Complex64( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'complex64', 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=complex64,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.float32.js b/benchmark/benchmark.length.float32.js deleted file mode 100644 index d2b2ba7..0000000 --- a/benchmark/benchmark.length.float32.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'float32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=float32,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.float64.js b/benchmark/benchmark.length.float64.js deleted file mode 100644 index 65064e3..0000000 --- a/benchmark/benchmark.length.float64.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'float64', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=float64,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.generic.js b/benchmark/benchmark.length.generic.js deleted file mode 100644 index eb87dfa..0000000 --- a/benchmark/benchmark.length.generic.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isArray = require( '@stdlib/assert-is-array' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'generic', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isArray( 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=generic,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int16.js b/benchmark/benchmark.length.int16.js deleted file mode 100644 index 914ff7c..0000000 --- a/benchmark/benchmark.length.int16.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int16', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=int16,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int32.js b/benchmark/benchmark.length.int32.js deleted file mode 100644 index cc0f678..0000000 --- a/benchmark/benchmark.length.int32.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=int32,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int8.js b/benchmark/benchmark.length.int8.js deleted file mode 100644 index 77553b0..0000000 --- a/benchmark/benchmark.length.int8.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int8', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=int8,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint16.js b/benchmark/benchmark.length.uint16.js deleted file mode 100644 index c68efdd..0000000 --- a/benchmark/benchmark.length.uint16.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint16', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint16,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint32.js b/benchmark/benchmark.length.uint32.js deleted file mode 100644 index 27c1742..0000000 --- a/benchmark/benchmark.length.uint32.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint32,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint8.js b/benchmark/benchmark.length.uint8.js deleted file mode 100644 index 2a26be4..0000000 --- a/benchmark/benchmark.length.uint8.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint8', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint8,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint8c.js b/benchmark/benchmark.length.uint8c.js deleted file mode 100644 index dd6e8c2..0000000 --- a/benchmark/benchmark.length.uint8c.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint8c', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint8c,len='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index c138144..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by" -%% click B href "https://github.com/stdlib-js/array-filled-by/tree/main" -%% click C href "https://github.com/stdlib-js/array-filled-by/tree/production" -%% click D href "https://github.com/stdlib-js/array-filled-by/tree/esm" -%% click E href "https://github.com/stdlib-js/array-filled-by/tree/deno" -%% click F href "https://github.com/stdlib-js/array-filled-by/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by -[production-url]: https://github.com/stdlib-js/array-filled-by/tree/production -[deno-url]: https://github.com/stdlib-js/array-filled-by/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-filled-by/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-filled-by/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-filled-by/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-filled-by/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-filled-by/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 188fc9b..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import filledarrayBy from '../docs/types/index'; -export = filledarrayBy; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 468e99c..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"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 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 00888a2..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "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,EAAQ,UAAU,OAGbA,IAAU,EACd,OAAAE,EAAOrB,EAAOS,CAAc,EACrB,IAAIY,EAAM,CAAE,EAIpB,GADAD,EAAQ,UAAW,CAAE,EAChB1B,EAAU0B,CAAM,EAAI,CAExB,GAAKD,EAAQ,EACZ,MAAM,IAAI,UAAW,2FAA4F,EAGlH,GADAE,EAAOrB,EAAOoB,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWd,EAAQ,sEAAuEa,CAAM,CAAE,EAG7G,OAAO,IAAIC,EAAM,CAAE,CACpB,CAEA,GAAKF,EAAQ,EACZ,MAAM,IAAI,UAAW,2FAA4F,EAMlH,GAHAA,GAAS,EAGJpB,EAAY,UAAWoB,CAAM,CAAE,EAEnC,GAAKpB,EAAY,UAAWoB,EAAM,CAAE,CAAE,GAMrC,GALAN,EAAU,UAAWM,CAAM,EAC3BA,GAAS,EACTP,EAAO,UAAWO,CAAM,EAGnBA,IAAU,EACd,MAAM,IAAI,UAAW,2FAA4F,OAIlHP,EAAO,UAAWO,CAAM,UAIhBA,GAAS,GAIlB,GAHAN,EAAU,UAAWM,CAAM,EAC3BA,GAAS,EACTP,EAAO,UAAWO,CAAM,EACnB,CAACpB,EAAYa,CAAK,EACtB,MAAM,IAAI,UAAWL,EAAQ,uEAAwEK,CAAK,CAAE,MAK7G,OAAM,IAAI,UAAW,2FAA4F,EAWlH,GARAO,GAAS,EACJA,GAAS,GAAKzB,EAAU,UAAWyB,CAAM,CAAE,GAC/CC,EAAQ,UAAWD,CAAM,EACzBA,GAAS,GAETC,EAAQX,EAETY,EAAOrB,EAAOoB,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWd,EAAQ,sEAAuEa,CAAM,CAAE,EAG7G,GAAKA,IAAU,UAAY,CAE1B,GADAG,EAAM,UAAW,CAAE,EACdJ,IAAU,EAAI,CAMlB,GALKxB,EAAsB4B,CAAI,EAC9BD,EAAMC,EACK3B,EAAc2B,CAAI,IAC7BD,EAAMC,EAAI,QAEND,IAAQ,OACZ,OAAOpB,EAAaoB,EAAKV,EAAMC,CAAQ,EAExC,GAAKhB,EAAe0B,CAAI,EACvB,MAAM,IAAI,MAAO,mFAAoF,EAEtG,GAAKzB,EAAUyB,CAAI,EAAI,CACtB,GAAKf,IAAwB,GAC5B,MAAM,IAAI,UAAWD,EAAQ,sIAAuIgB,CAAI,CAAE,EAE3K,GAAK,CAACxB,EAAYwB,EAAKnB,CAAgB,CAAE,EACxC,MAAM,IAAI,UAAWG,EAAQ,wGAAyGgB,CAAI,CAAE,EAG7I,GADAA,EAAMA,EAAKnB,CAAgB,EAAE,EACxB,CAACL,EAAYwB,EAAI,IAAK,EAC1B,MAAM,IAAI,UAAWhB,EAAQ,wGAAyGgB,CAAI,CAAE,EAE7I,OAAOb,EAAqBa,EAAKX,EAAMC,CAAQ,CAChD,CACA,MAAM,IAAI,UAAWN,EAAQ,wGAAyGgB,CAAI,CAAE,CAC7I,SAAY1B,EAAe0B,CAAI,EAC9B,MAAM,IAAI,MAAO,mFAAoF,EAEtG,MAAM,IAAI,UAAWhB,EAAQ,wGAAyGgB,CAAI,CAAE,CAC7I,CACA,GAAKJ,IAAU,EAEd,GADAI,EAAM,UAAW,CAAE,EACd3B,EAAc2B,CAAI,EACtBT,EAAM,IAAIO,EAAME,EAAI,MAAO,UAChB1B,EAAe0B,CAAI,EAC9BT,EAAM,IAAIO,EAAME,CAAI,UACT5B,EAAsB4B,CAAI,EACrCT,EAAM,IAAIO,EAAME,CAAI,UACTzB,EAAUyB,CAAI,EAAI,CAC7B,GAAKf,IAAwB,GAC5B,MAAM,IAAI,UAAWD,EAAQ,sIAAuIgB,CAAI,CAAE,EAE3K,GAAK,CAACxB,EAAYwB,EAAKnB,CAAgB,CAAE,EACxC,MAAM,IAAI,UAAWG,EAAQ,wGAAyGgB,CAAI,CAAE,EAG7I,GADAA,EAAMA,EAAKnB,CAAgB,EAAE,EACxB,CAACL,EAAYwB,EAAI,IAAK,EAC1B,MAAM,IAAI,UAAWhB,EAAQ,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"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 5a68984..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,174 +0,0 @@ - -{{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) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr = {{alias}}() - - > arr = {{alias}}( 'float32' ) - - - -{{alias}}( length[, dtype], clbk[, thisArg] ) - Returns a filled array according to a provided callback function and having - a specified length. - - Parameters - ---------- - length: integer - Array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > function clbk() { return 1.0; }; - > var arr = {{alias}}( 5, clbk ) - [ 1.0, 1.0, 1.0, 1.0, 1.0 ] - > arr = {{alias}}( 5, 'int32', clbk ) - [ 1, 1, 1, 1, 1 ] - - -{{alias}}( array[, dtype], clbk[, thisArg] ) - Creates a filled array from another array (or array-like object) according - to a provided callback function. - - Parameters - ---------- - array: ArrayLikeObject - Array from which to generate another array. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias}}( [ 0.5, 0.5, 0.5 ], {{alias:@stdlib/utils/constant-function}}( 2.0 ) ) - [ 2.0, 2.0, 2.0 ] - > var arr2 = {{alias}}( arr1, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( iterable[, dtype], clbk[, thisArg] ) - Creates a filled array from an iterable according to a provided callback - function. - - Parameters - ---------- - iterable: Iterable - Iterable from which to generate an array. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias:@stdlib/iter/constant}}( 3.0, {'iter': 3} ); - > var arr2 = {{alias}}( arr1, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( buffer[, byteOffset[, length]][, dtype], clbk[, thisArg] ) - Returns a filled typed array view of an ArrayBuffer according to a provided - callback function. - - The 'generic' array data type is *not* supported. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( buf, 0, 4, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0, 1.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 394ac49..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,606 +0,0 @@ -/* -* @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. -*/ - -/// - -import { IterableIterator } from '@stdlib/types/iter'; -import filledarrayBy = require( './index' ); - - -/** -* Returns an iterator protocol-compliant object. -* -* @returns iterator protocol-compliant object -*/ -function iterator(): IterableIterator { - const obj: IterableIterator = { - [Symbol.iterator]: iterator, - 'next': next - }; - return obj; -} - -/** -* Implements the iterator protocol `next` method. -* -* @returns iterator protocol-compliant object -*/ -function next(): any { - return { - 'value': 1.0, - 'done': false - }; -} - -/** -* Callback function. -* -* @param i - current array index -* @returns return value -*/ -function clbk( i: number ): number { - return i; -} - - -// TESTS // - -// The function returns an array or typed array... -{ - filledarrayBy(); // $ExpectType ArrayOrTypedArray - filledarrayBy( 'float32' ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( 10, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( 10, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( 10, 'int32', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( 10, 'int32', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const x = new Float64Array( 10 ); - filledarrayBy( x, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( x, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( x, 'uint8', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( x, 'uint8', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const y = [ 2.0, 2.0, 2.0 ]; - filledarrayBy( y, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( y, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( y, 'float64', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( y, 'float64', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const it = iterator(); - filledarrayBy( it, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( it, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( it, 'uint8c', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( it, 'uint8c', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const buf = new ArrayBuffer( 32 ); - filledarrayBy( buf, clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 'uint32', clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 'uint32', clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 8, clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 8, clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 8, 'uint16', clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 8, 'uint16', clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 8, 2, clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 8, 2, clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 8, 2, 'int16', clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 8, 2, 'int16', clbk, {} ); // $ExpectType RealOrComplexTypedArray -} - -// The compiler throws an error if a callback function argument is not a function... -{ - filledarrayBy( 'float64', '5' ); // $ExpectError - filledarrayBy( 'float64', 1.0 ); // $ExpectError - filledarrayBy( 'float64', false ); // $ExpectError - filledarrayBy( 'float64', true ); // $ExpectError - filledarrayBy( 'float64', null ); // $ExpectError - filledarrayBy( 'float64', undefined ); // $ExpectError - filledarrayBy( 'float64', [] ); // $ExpectError - filledarrayBy( 'float64', {} ); // $ExpectError - - filledarrayBy( 'float64', '5', {} ); // $ExpectError - filledarrayBy( 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( 'float64', false, {} ); // $ExpectError - filledarrayBy( 'float64', true, {} ); // $ExpectError - filledarrayBy( 'float64', null, {} ); // $ExpectError - filledarrayBy( 'float64', undefined, {} ); // $ExpectError - filledarrayBy( 'float64', [], {} ); // $ExpectError - filledarrayBy( 'float64', {}, {} ); // $ExpectError - - filledarrayBy( 10, '5' ); // $ExpectError - filledarrayBy( 10, 1.0 ); // $ExpectError - filledarrayBy( 10, false ); // $ExpectError - filledarrayBy( 10, true ); // $ExpectError - filledarrayBy( 10, null ); // $ExpectError - filledarrayBy( 10, undefined ); // $ExpectError - filledarrayBy( 10, [] ); // $ExpectError - filledarrayBy( 10, {} ); // $ExpectError - - filledarrayBy( 10, '5', {} ); // $ExpectError - filledarrayBy( 10, 1.0, {} ); // $ExpectError - filledarrayBy( 10, false, {} ); // $ExpectError - filledarrayBy( 10, true, {} ); // $ExpectError - filledarrayBy( 10, null, {} ); // $ExpectError - filledarrayBy( 10, undefined, {} ); // $ExpectError - filledarrayBy( 10, [], {} ); // $ExpectError - filledarrayBy( 10, {}, {} ); // $ExpectError - - filledarrayBy( 10, 'float64', '5' ); // $ExpectError - filledarrayBy( 10, 'float64', 1.0 ); // $ExpectError - filledarrayBy( 10, 'float64', false ); // $ExpectError - filledarrayBy( 10, 'float64', true ); // $ExpectError - filledarrayBy( 10, 'float64', null ); // $ExpectError - filledarrayBy( 10, 'float64', undefined ); // $ExpectError - filledarrayBy( 10, 'float64', [] ); // $ExpectError - filledarrayBy( 10, 'float64', {} ); // $ExpectError - - filledarrayBy( 10, 'float64', '5', {} ); // $ExpectError - filledarrayBy( 10, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( 10, 'float64', false, {} ); // $ExpectError - filledarrayBy( 10, 'float64', true, {} ); // $ExpectError - filledarrayBy( 10, 'float64', null, {} ); // $ExpectError - filledarrayBy( 10, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( 10, 'float64', [], {} ); // $ExpectError - filledarrayBy( 10, 'float64', {}, {} ); // $ExpectError - - const x = new Float64Array( 10 ); - filledarrayBy( x, '5' ); // $ExpectError - filledarrayBy( x, 1.0 ); // $ExpectError - filledarrayBy( x, false ); // $ExpectError - filledarrayBy( x, true ); // $ExpectError - filledarrayBy( x, null ); // $ExpectError - filledarrayBy( x, undefined ); // $ExpectError - filledarrayBy( x, [] ); // $ExpectError - filledarrayBy( x, {} ); // $ExpectError - - filledarrayBy( x, '5', {} ); // $ExpectError - filledarrayBy( x, 1.0, {} ); // $ExpectError - filledarrayBy( x, false, {} ); // $ExpectError - filledarrayBy( x, true, {} ); // $ExpectError - filledarrayBy( x, null, {} ); // $ExpectError - filledarrayBy( x, undefined, {} ); // $ExpectError - filledarrayBy( x, [], {} ); // $ExpectError - filledarrayBy( x, {}, {} ); // $ExpectError - - filledarrayBy( x, 'float64', '5' ); // $ExpectError - filledarrayBy( x, 'float64', 1.0 ); // $ExpectError - filledarrayBy( x, 'float64', false ); // $ExpectError - filledarrayBy( x, 'float64', true ); // $ExpectError - filledarrayBy( x, 'float64', null ); // $ExpectError - filledarrayBy( x, 'float64', undefined ); // $ExpectError - filledarrayBy( x, 'float64', [] ); // $ExpectError - filledarrayBy( x, 'float64', {} ); // $ExpectError - - filledarrayBy( x, 'float64', '5', {} ); // $ExpectError - filledarrayBy( x, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( x, 'float64', false, {} ); // $ExpectError - filledarrayBy( x, 'float64', true, {} ); // $ExpectError - filledarrayBy( x, 'float64', null, {} ); // $ExpectError - filledarrayBy( x, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( x, 'float64', [], {} ); // $ExpectError - filledarrayBy( x, 'float64', {}, {} ); // $ExpectError - - const y = [ 2.0, 2.0, 2.0 ]; - filledarrayBy( y, '5' ); // $ExpectError - filledarrayBy( y, 1.0 ); // $ExpectError - filledarrayBy( y, false ); // $ExpectError - filledarrayBy( y, true ); // $ExpectError - filledarrayBy( y, null ); // $ExpectError - filledarrayBy( y, undefined ); // $ExpectError - filledarrayBy( y, [] ); // $ExpectError - filledarrayBy( y, {} ); // $ExpectError - - filledarrayBy( y, '5', {} ); // $ExpectError - filledarrayBy( y, 1.0, {} ); // $ExpectError - filledarrayBy( y, false, {} ); // $ExpectError - filledarrayBy( y, true, {} ); // $ExpectError - filledarrayBy( y, null, {} ); // $ExpectError - filledarrayBy( y, undefined, {} ); // $ExpectError - filledarrayBy( y, [], {} ); // $ExpectError - filledarrayBy( y, {}, {} ); // $ExpectError - - filledarrayBy( y, 'float64', '5' ); // $ExpectError - filledarrayBy( y, 'float64', 1.0 ); // $ExpectError - filledarrayBy( y, 'float64', false ); // $ExpectError - filledarrayBy( y, 'float64', true ); // $ExpectError - filledarrayBy( y, 'float64', null ); // $ExpectError - filledarrayBy( y, 'float64', undefined ); // $ExpectError - filledarrayBy( y, 'float64', [] ); // $ExpectError - filledarrayBy( y, 'float64', {} ); // $ExpectError - - filledarrayBy( y, 'float64', '5', {} ); // $ExpectError - filledarrayBy( y, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( y, 'float64', false, {} ); // $ExpectError - filledarrayBy( y, 'float64', true, {} ); // $ExpectError - filledarrayBy( y, 'float64', null, {} ); // $ExpectError - filledarrayBy( y, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( y, 'float64', [], {} ); // $ExpectError - filledarrayBy( y, 'float64', {}, {} ); // $ExpectError - - const it = iterator(); - filledarrayBy( it, '5' ); // $ExpectError - filledarrayBy( it, 1.0 ); // $ExpectError - filledarrayBy( it, false ); // $ExpectError - filledarrayBy( it, true ); // $ExpectError - filledarrayBy( it, null ); // $ExpectError - filledarrayBy( it, undefined ); // $ExpectError - filledarrayBy( it, [] ); // $ExpectError - filledarrayBy( it, {} ); // $ExpectError - - filledarrayBy( it, '5', {} ); // $ExpectError - filledarrayBy( it, 1.0, {} ); // $ExpectError - filledarrayBy( it, false, {} ); // $ExpectError - filledarrayBy( it, true, {} ); // $ExpectError - filledarrayBy( it, null, {} ); // $ExpectError - filledarrayBy( it, undefined, {} ); // $ExpectError - filledarrayBy( it, [], {} ); // $ExpectError - filledarrayBy( it, {}, {} ); // $ExpectError - - filledarrayBy( it, 'float64', '5' ); // $ExpectError - filledarrayBy( it, 'float64', 1.0 ); // $ExpectError - filledarrayBy( it, 'float64', false ); // $ExpectError - filledarrayBy( it, 'float64', true ); // $ExpectError - filledarrayBy( it, 'float64', null ); // $ExpectError - filledarrayBy( it, 'float64', undefined ); // $ExpectError - filledarrayBy( it, 'float64', [] ); // $ExpectError - filledarrayBy( it, 'float64', {} ); // $ExpectError - - filledarrayBy( it, 'float64', '5', {} ); // $ExpectError - filledarrayBy( it, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( it, 'float64', false, {} ); // $ExpectError - filledarrayBy( it, 'float64', true, {} ); // $ExpectError - filledarrayBy( it, 'float64', null, {} ); // $ExpectError - filledarrayBy( it, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( it, 'float64', [], {} ); // $ExpectError - filledarrayBy( it, 'float64', {}, {} ); // $ExpectError - - const buf = new ArrayBuffer( 32 ); - filledarrayBy( buf, '5' ); // $ExpectError - filledarrayBy( buf, 1.0 ); // $ExpectError - filledarrayBy( buf, false ); // $ExpectError - filledarrayBy( buf, true ); // $ExpectError - filledarrayBy( buf, null ); // $ExpectError - filledarrayBy( buf, undefined ); // $ExpectError - filledarrayBy( buf, [] ); // $ExpectError - filledarrayBy( buf, {} ); // $ExpectError - - filledarrayBy( buf, '5', {} ); // $ExpectError - filledarrayBy( buf, 1.0, {} ); // $ExpectError - filledarrayBy( buf, false, {} ); // $ExpectError - filledarrayBy( buf, true, {} ); // $ExpectError - filledarrayBy( buf, null, {} ); // $ExpectError - filledarrayBy( buf, undefined, {} ); // $ExpectError - filledarrayBy( buf, [], {} ); // $ExpectError - filledarrayBy( buf, {}, {} ); // $ExpectError - - filledarrayBy( buf, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 'float64', false ); // $ExpectError - filledarrayBy( buf, 'float64', true ); // $ExpectError - filledarrayBy( buf, 'float64', null ); // $ExpectError - filledarrayBy( buf, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 'float64', {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5' ); // $ExpectError - filledarrayBy( buf, 8, 1.0 ); // $ExpectError - filledarrayBy( buf, 8, false ); // $ExpectError - filledarrayBy( buf, 8, true ); // $ExpectError - filledarrayBy( buf, 8, null ); // $ExpectError - filledarrayBy( buf, 8, undefined ); // $ExpectError - filledarrayBy( buf, 8, [] ); // $ExpectError - filledarrayBy( buf, 8, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, false, {} ); // $ExpectError - filledarrayBy( buf, 8, true, {} ); // $ExpectError - filledarrayBy( buf, 8, null, {} ); // $ExpectError - filledarrayBy( buf, 8, undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, [], {} ); // $ExpectError - filledarrayBy( buf, 8, {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 8, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 'float64', false ); // $ExpectError - filledarrayBy( buf, 8, 'float64', true ); // $ExpectError - filledarrayBy( buf, 8, 'float64', null ); // $ExpectError - filledarrayBy( buf, 8, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 8, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 8, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 8, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, '5' ); // $ExpectError - filledarrayBy( buf, 8, 2, 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 2, false ); // $ExpectError - filledarrayBy( buf, 8, 2, true ); // $ExpectError - filledarrayBy( buf, 8, 2, null ); // $ExpectError - filledarrayBy( buf, 8, 2, undefined ); // $ExpectError - filledarrayBy( buf, 8, 2, [] ); // $ExpectError - filledarrayBy( buf, 8, 2, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, false, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, true, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, null, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, [], {} ); // $ExpectError - filledarrayBy( buf, 8, 2, {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', false ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', true ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', null ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', {}, {} ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid length, typed array, array-like object, `ArrayBuffer`, or iterable argument... -{ - filledarrayBy( false, clbk ); // $ExpectError - filledarrayBy( true, clbk ); // $ExpectError - filledarrayBy( null, clbk ); // $ExpectError - filledarrayBy( {}, clbk ); // $ExpectError - - filledarrayBy( false, clbk, {} ); // $ExpectError - filledarrayBy( true, clbk, {} ); // $ExpectError - filledarrayBy( null, clbk, {} ); // $ExpectError - filledarrayBy( {}, clbk, {} ); // $ExpectError - - filledarrayBy( false, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 'float64', clbk ); // $ExpectError - - filledarrayBy( false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, clbk ); // $ExpectError - filledarrayBy( 1.0, 8, clbk ); // $ExpectError - filledarrayBy( false, 8, clbk ); // $ExpectError - filledarrayBy( true, 8, clbk ); // $ExpectError - filledarrayBy( null, 8, clbk ); // $ExpectError - filledarrayBy( undefined, 8, clbk ); // $ExpectError - filledarrayBy( [], 8, clbk ); // $ExpectError - filledarrayBy( {}, 8, clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, clbk ); // $ExpectError - - filledarrayBy( '5', 8, clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, clbk, {} ); // $ExpectError - filledarrayBy( false, 8, clbk, {} ); // $ExpectError - filledarrayBy( true, 8, clbk, {} ); // $ExpectError - filledarrayBy( null, 8, clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, clbk, {} ); // $ExpectError - filledarrayBy( [], 8, clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 'float64', clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( false, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( [], 8, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 'float64', clbk ); // $ExpectError - - filledarrayBy( '5', 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 2, clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 2, clbk ); // $ExpectError - filledarrayBy( false, 8, 2, clbk ); // $ExpectError - filledarrayBy( true, 8, 2, clbk ); // $ExpectError - filledarrayBy( null, 8, 2, clbk ); // $ExpectError - filledarrayBy( undefined, 8, 2, clbk ); // $ExpectError - filledarrayBy( [], 8, 2, clbk ); // $ExpectError - filledarrayBy( {}, 8, 2, clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, clbk ); // $ExpectError - - filledarrayBy( '5', 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( false, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( [], 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, 'float64', clbk ); // $ExpectError - - filledarrayBy( '5', 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a byte offset argument which is not a number... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, false, clbk ); // $ExpectError - filledarrayBy( buf, true, clbk ); // $ExpectError - filledarrayBy( buf, null, clbk ); // $ExpectError - filledarrayBy( buf, [], clbk ); // $ExpectError - filledarrayBy( buf, {}, clbk ); // $ExpectError - - filledarrayBy( buf, false, clbk, {} ); // $ExpectError - filledarrayBy( buf, true, clbk, {} ); // $ExpectError - filledarrayBy( buf, null, clbk, {} ); // $ExpectError - filledarrayBy( buf, [], clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, clbk, {} ); // $ExpectError - - filledarrayBy( buf, '5', 'float64', clbk ); // $ExpectError - filledarrayBy( buf, false, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, true, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, null, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, [], 'float64', clbk ); // $ExpectError - filledarrayBy( buf, {}, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, '5', 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( buf, false, 2, clbk ); // $ExpectError - filledarrayBy( buf, true, 2, clbk ); // $ExpectError - filledarrayBy( buf, null, 2, clbk ); // $ExpectError - filledarrayBy( buf, [], 2, clbk ); // $ExpectError - filledarrayBy( buf, {}, 2, clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, clbk ); // $ExpectError - - filledarrayBy( buf, false, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, clbk, {} ); // $ExpectError - - filledarrayBy( buf, '5', 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, false, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, true, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, null, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, undefined, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, [], 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, {}, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, '5', 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, false, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, undefined, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a view length argument which is not a number... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, 8, false, clbk ); // $ExpectError - filledarrayBy( buf, 8, true, clbk ); // $ExpectError - filledarrayBy( buf, 8, null, clbk ); // $ExpectError - filledarrayBy( buf, 8, [], clbk ); // $ExpectError - filledarrayBy( buf, 8, {}, clbk ); // $ExpectError - - filledarrayBy( buf, 8, false, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, true, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, null, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, [], clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, {}, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, clbk, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5', 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, false, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, true, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, null, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, [], 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, {}, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, 8, '5', 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, [], 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, {}, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided too many arguments... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, 8, 2, 'float64', 1, clbk, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 997a381..0000000 --- a/examples/index.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ).factory; -var dtypes = require( '@stdlib/array-typed-real-dtypes' ); -var filledarrayBy = require( './../lib' ); - -// Create a pseudorandom number generator: -var rand = discreteUniform( 0, 100 ); - -// Get a list of array data types: -var dt = dtypes(); - -// Generate filled arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = filledarrayBy( 10, dt[ i ], rand ); - console.log( arr ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index b1fd829..e1b94a1 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, RealOrComplexTypedArray, DataType } from '@stdlib/types/array'; import { IterableIterator } from '@stdlib/types/iter'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..56b3976 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.1-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-ctors@v0.2.1-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill-by@v0.2.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled-by@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.2.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.1-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@v0.2.1-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.2.1-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";var j=d(),a=p.get("dtypes.default");function v(){var d,p,v,c,g,y,b,u;if(0===(p=arguments.length))return new(g=o(a))(0);if(r(v=arguments[0])){if(p>1)throw new TypeError(w("00h05"));if(null===(g=o(v)))throw new TypeError(w("00h2Y",v));return new g(0)}if(p<2)throw new TypeError(w("00h05"));if(n(arguments[p-=1]))if(n(arguments[p-1])){if(d=arguments[p],c=arguments[p-=1],0===p)throw new TypeError(w("00h05"))}else c=arguments[p];else{if(!(p>=2))throw new TypeError(w("00h05"));if(d=arguments[p],!n(c=arguments[p-=1]))throw new TypeError(w("00h2b",c))}if((p-=1)>=0&&r(arguments[p])?(v=arguments[p],p-=1):v=a,null===(g=o(v)))throw new TypeError(w("00h2Y",v));if("generic"===v){if(u=arguments[0],0===p){if(e(u)?b=u:t(u)&&(b=u.length),void 0!==b)return l(b,c,d);if(s(u))throw new Error(w("00h04"));if(i(u)){if(!1===j)throw new TypeError(w("00h2Z",u));if(!n(u[m]))throw new TypeError(w("00h2a",u));if(u=u[m](),!n(u.next))throw new TypeError(w("00h2a",u));return function(r,e,t){var s,i;for(s=[],i=-1;!r.next().done;)i+=1,s.push(e.call(t,i));return s}(u,c,d)}throw new TypeError(w("00h2a",u))}if(s(u))throw new Error(w("00h04"));throw new TypeError(w("00h2a",u))}if(0===p)if(t(u=arguments[0]))y=new g(u.length);else if(s(u))y=new g(u);else if(e(u))y=new g(u);else{if(!i(u))throw new TypeError(w("00h2a",u));if(!1===j)throw new TypeError(w("00h2Z",u));if(!n(u[m]))throw new TypeError(w("00h2a",u));if(u=u[m](),!n(u.next))throw new TypeError(w("00h2a",u));y=new g(f(u))}else y=1===p?new g(arguments[0],arguments[1]):new g(arguments[0],arguments[1],arguments[2]);return y.length>0&&(/^complex/.test(v)?function(r,e,t){var s;for(s=0;s\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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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( format('00h05') );\n\t\t}\n\t\tctor = ctors( dtype );\n\t\tif ( ctor === null ) {\n\t\t\tthrow new TypeError( format( '00h2Y', 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( format('00h05') );\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( format('00h05') );\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( '00h2b', 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( format('00h05') );\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( '00h2Y', 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( format('00h04') );\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( '00h2Z', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00h2a', 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( '00h2a', 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( '00h2a', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format('00h04') );\n\t\t}\n\t\tthrow new TypeError( format( '00h2a', 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( '00h2Z', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00h2a', 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( '00h2a', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00h2a', 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\nexport default filledarrayBy;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","DEFAULT_DTYPE","defaults","get","filledarrayBy","thisArg","nargs","dtype","clbk","ctor","arr","len","arg","arguments","length","ctors","isString","TypeError","format","isFunction","isNonNegativeInteger","isCollection","filledArray","isArrayBuffer","Error","isObject","ITERATOR_SYMBOL","next","it","i","done","push","call","filledArrayIterator","iterLength","test","set","filledAccessors","gfillBy","value","aidx"],"mappings":";;q0CAwCA,IAAIA,EAAsBC,IACtBC,EAAgBC,EAASC,IAAK,kBA2MlC,SAASC,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAKJ,GAAe,KAHfN,EAAQO,UAAUC,QAKjB,OAAO,IADPL,EAAOM,EAAOd,IACG,GAIlB,GAAKe,EADLT,EAAQM,UAAW,IACM,CAExB,GAAKP,EAAQ,EACZ,MAAM,IAAIW,UAAWC,EAAO,UAG7B,GAAc,QADdT,EAAOM,EAAOR,IAEb,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,OAAO,IAAIE,EAAM,EACjB,CAED,GAAKH,EAAQ,EACZ,MAAM,IAAIW,UAAWC,EAAO,UAM7B,GAAKC,EAAYN,UAHjBP,GAAS,IAKR,GAAKa,EAAYN,UAAWP,EAAM,KAMjC,GALAD,EAAUQ,UAAWP,GAErBE,EAAOK,UADPP,GAAS,GAIM,IAAVA,EACJ,MAAM,IAAIW,UAAWC,EAAO,eAI7BV,EAAOK,UAAWP,OAIf,MAAKA,GAAS,GAUlB,MAAM,IAAIW,UAAWC,EAAO,UAN5B,GAHAb,EAAUQ,UAAWP,IAGfa,EADNX,EAAOK,UADPP,GAAS,IAGR,MAAM,IAAIW,UAAWC,EAAQ,QAASV,GAMvC,CAUD,IARAF,GAAS,IACK,GAAKU,EAAUH,UAAWP,KACvCC,EAAQM,UAAWP,GACnBA,GAAS,GAETC,EAAQN,EAGK,QADdQ,EAAOM,EAAOR,IAEb,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,GAAe,YAAVA,EAAsB,CAE1B,GADAK,EAAMC,UAAW,GACF,IAAVP,EAAc,CAMlB,GALKc,EAAsBR,GAC1BD,EAAMC,EACKS,EAAcT,KACzBD,EAAMC,EAAIE,aAEE,IAARH,EACJ,OAAOW,EAAaX,EAAKH,EAAMH,GAEhC,GAAKkB,EAAeX,GACnB,MAAM,IAAIY,MAAON,EAAO,UAEzB,GAAKO,EAAUb,GAAQ,CACtB,IAA6B,IAAxBb,EACJ,MAAM,IAAIkB,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAYP,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLP,EAAYP,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvC,OAvSJ,SAA8BgB,EAAIpB,EAAMH,GACvC,IAAIK,EACAmB,EAKJ,IAFAnB,EAAM,GACNmB,GAAK,GAEAD,EAAGD,OACAG,MAGPD,GAAK,EACLnB,EAAIqB,KAAMvB,EAAKwB,KAAM3B,EAASwB,IAE/B,OAAOnB,CACR,CAuRWuB,CAAqBrB,EAAKJ,EAAMH,EACvC,CACD,MAAM,IAAIY,UAAWC,EAAQ,QAASN,GACzC,CAAS,GAAKW,EAAeX,GAC1B,MAAM,IAAIY,MAAON,EAAO,UAEzB,MAAM,IAAID,UAAWC,EAAQ,QAASN,GACtC,CACD,GAAe,IAAVN,EAEJ,GAAKe,EADLT,EAAMC,UAAW,IAEhBH,EAAM,IAAID,EAAMG,EAAIE,aACd,GAAKS,EAAeX,GAC1BF,EAAM,IAAID,EAAMG,QACV,GAAKQ,EAAsBR,GACjCF,EAAM,IAAID,EAAMG,OACV,KAAKa,EAAUb,GAarB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAZtC,IAA6B,IAAxBb,EACJ,MAAM,IAAIkB,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAYP,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLP,EAAYP,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvCF,EAAM,IAAID,EAAMyB,EAAYtB,GAG5B,MAEDF,EADqB,IAAVJ,EACL,IAAIG,EAAMI,UAAU,GAAIA,UAAU,IAElC,IAAIJ,EAAMI,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKH,EAAII,OAAS,IACZ,WAAWqB,KAAM5B,GAjTxB,SAA0BG,EAAKF,EAAMH,GACpC,IAAIwB,EACJ,IAAMA,EAAI,EAAGA,EAAInB,EAAII,OAAQe,IAC5BnB,EAAI0B,IAAK5B,EAAKwB,KAAM3B,EAASwB,GAAKA,EAGpC,CA4SGQ,CAAiB3B,EAAKF,EAAMH,GAE5BiC,EAAS5B,EAAII,OAAQJ,EAAK,GAe5B,SAAmB6B,EAAOC,GACzB,OAAOhC,EAAKwB,KAAM3B,EAASmC,EAC3B,KAdM9B,CAeR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d115cf0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,192 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -/** -* Create a filled array according to a provided callback function. -* -* @module @stdlib/array-filled-by -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* var arr = filledarrayBy(); -* // returns -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'generic', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( [ 0.5, 0.5 ], clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1; -* } -* -* var arr = filledarrayBy( [ 5, -3 ], 'int32', clbk ); -* // returns [ 1, 1 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk1() { -* return 10; -* } -* -* function clbk2() { -* return 1.0; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, clbk2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk1() { -* return 1.0; -* } -* -* function clbk2() { -* return 2; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, 'uint32', clbk2 ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 'float32', clbk ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, clbk ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, 'int32', clbk ); -* // returns [ 1, 1 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 06bc8b6..0000000 --- a/lib/main.js +++ /dev/null @@ -1,414 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var isCollection = require( '@stdlib/assert-is-collection' ); -var isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isObject = require( '@stdlib/assert-is-object' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var ctors = require( '@stdlib/array-ctors' ); -var gfillBy = require( '@stdlib/blas-ext-base-gfill-by' ); -var filledArray = require( '@stdlib/array-base-filled-by' ); -var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var iterLength = require( '@stdlib/iter-length' ); -var defaults = require( '@stdlib/array-defaults' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport(); -var DEFAULT_DTYPE = defaults.get( 'dtypes.default' ); - - -// FUNCTIONS // - -/** -* Creates a filled "generic" array from an iterator. -* -* @private -* @param {Iterable} it - iterator -* @param {Callback} clbk - callback function -* @param {*} thisArg - callback function execution context -* @returns {Array} filled array -*/ -function filledArrayIterator( it, clbk, thisArg ) { - var arr; - var i; - var v; - - arr = []; - i = -1; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - i += 1; - arr.push( clbk.call( thisArg, i ) ); - } - return arr; -} - -/** -* Fills an array exposing accessors for getting and setting array elements. -* -* @private -* @param {Collection} arr - input array -* @param {Callback} clbk - callback function -* @param {*} thisArg - callback function execution context -* @returns {Collection} input array -*/ -function filledAccessors( arr, clbk, thisArg ) { - var i; - for ( i = 0; i < arr.length; i++ ) { - arr.set( clbk.call( thisArg, i ), i ); - } - return arr; -} - - -// MAIN // - -/** -* Creates a filled array according to a provided callback function. -* -* @param {(NonNegativeInteger|TypedArray|ArrayLikeObject|ArrayBuffer|Iterable)} [arg] - a length, typed array, array-like object, buffer, or iterable -* @param {NonNegativeInteger} [byteOffset=0] - byte offset -* @param {NonNegativeInteger} [length] - view length -* @param {string} [dtype="float64"] - data type -* @param {Callback} [clbk] - callback to invoke -* @param {*} [thisArg] - callback execution context -* @throws {TypeError} must provide a recognized data type -* @throws {TypeError} must provide a length, typed array, array-like object, buffer, or iterable -* @throws {TypeError} callback argument must be a function. -* @throws {Error} creating a generic array from an `ArrayBuffer` is not supported -* @returns {(TypedArray|Array)} array or typed array -* -* @example -* var arr = filledarrayBy(); -* // returns -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'generic', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( [ 0.5, 0.5 ], clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1; -* } -* -* var arr = filledarrayBy( [ 5, -3 ], 'int32', clbk ); -* // returns [ 1, 1 ] -* -* @example -* function clbk1() { -* return 10; -* } -* -* function clbk2() { -* return 1.0; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, clbk2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk1() { -* return 1.0; -* } -* -* function clbk2() { -* return 2; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, 'uint32', clbk2 ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 'float32', clbk ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, clbk ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, 'int32', clbk ); -* // returns [ 1, 1 ] -*/ -function filledarrayBy() { - var thisArg; - var nargs; - var dtype; - var clbk; - var ctor; - var arr; - var len; - var arg; - - nargs = arguments.length; - - // If we weren't provided any arguments, return an empty array... - if ( nargs === 0 ) { - ctor = ctors( DEFAULT_DTYPE ); - return new ctor( 0 ); - } - // Check if we were provided a dtype as the first argument... - dtype = arguments[ 0 ]; - if ( isString( dtype ) ) { - // Invoking this function with arguments `f( dtype, clbk[, thisArg] )` is not allowed (otherwise, we'd need to also allow `f( clbk[, thisArg] )`)... - if ( nargs > 1 ) { - throw new TypeError( format('00h05') ); - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '00h2Y', dtype ) ); - } - // Return an empty array having the specified dtype: - return new ctor( 0 ); - } - // For all other supported invocations, we need at least two arguments... - if ( nargs < 2 ) { - throw new TypeError( format('00h05') ); - } - // At this point, we need to do some argument juggling... - nargs -= 1; // henceforth, the number of available arguments is `nargs+1` - - // Determine whether the last argument is a callback or "this" context... - if ( isFunction( arguments[ nargs ] ) ) { - // 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... - if ( isFunction( arguments[ nargs-1 ] ) ) { - thisArg = arguments[ nargs ]; - nargs -= 1; - clbk = arguments[ nargs ]; - - // Check if we were provided only a callback and a "this" context.. - if ( nargs === 0 ) { - throw new TypeError( format('00h05') ); - } - } else { - // "this" context is left undefined... - clbk = arguments[ nargs ]; - } - } - // 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... - else if ( nargs >= 2 ) { - thisArg = arguments[ nargs ]; - nargs -= 1; - clbk = arguments[ nargs ]; - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '00h2b', clbk ) ); - } - } - // If were were only provided 2 arguments and the last argument was not a function, we've been provided an insufficient number of arguments... - else { - throw new TypeError( format('00h05') ); - } - // Now that we've processed the callback arguments, let's continue working backward to see if we've been provided a `dtype` argument... - nargs -= 1; - if ( nargs >= 0 && isString( arguments[ nargs ] ) ) { - dtype = arguments[ nargs ]; - nargs -= 1; - } else { - dtype = DEFAULT_DTYPE; - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '00h2Y', dtype ) ); - } - // At this point, we've resolved the output array data type, and now we can actually create the output array... - if ( dtype === 'generic' ) { - arg = arguments[ 0 ]; - if ( nargs === 0 ) { - if ( isNonNegativeInteger( arg ) ) { - len = arg; - } else if ( isCollection( arg ) ) { - len = arg.length; - } - if ( len !== void 0 ) { - return filledArray( len, clbk, thisArg ); - } - if ( isArrayBuffer( arg ) ) { - throw new Error( format('00h04') ); - } - if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( '00h2Z', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00h2a', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00h2a', arg ) ); - } - return filledArrayIterator( arg, clbk, thisArg ); - } - throw new TypeError( format( '00h2a', arg ) ); - } else if ( isArrayBuffer( arg ) ) { - throw new Error( format('00h04') ); - } - throw new TypeError( format( '00h2a', arg ) ); - } - if ( nargs === 0 ) { // length || array-like || ArrayBuffer || iterable - arg = arguments[ 0 ]; - if ( isCollection( arg ) ) { - arr = new ctor( arg.length ); - } else if ( isArrayBuffer( arg ) ) { - arr = new ctor( arg ); - } else if ( isNonNegativeInteger( arg ) ) { - arr = new ctor( arg ); - } else if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( '00h2Z', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00h2a', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00h2a', arg ) ); - } - arr = new ctor( iterLength( arg ) ); - } else { - throw new TypeError( format( '00h2a', arg ) ); - } - } else if ( nargs === 1 ) { - arr = new ctor( arguments[0], arguments[1] ); // (ArrayBuffer, byteOffset) - } else { - arr = new ctor( arguments[0], arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset, length) - } - if ( arr.length > 0 ) { - if ( /^complex/.test( dtype ) ) { - filledAccessors( arr, clbk, thisArg ); - } else { - gfillBy( arr.length, arr, 1, callback ); - } - } - return arr; - - /** - * Callback which wraps a provided callback and is invoked for each array element. - * - * @private - * @param {*} value - element value - * @param {NonNegativeInteger} aidx - array index - * @param {NonNegativeInteger} sidx - strided index - * @param {Collection} array - input array/collection - * @returns {*} callback return value - */ - function callback( value, aidx ) { - return clbk.call( thisArg, aidx ); - } -} - - -// EXPORTS // - -module.exports = filledarrayBy; diff --git a/package.json b/package.json index fe41e9b..b16be36 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Create a filled array according to a provided callback function.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,71 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-filled-by": "^0.2.1", - "@stdlib/array-ctors": "^0.2.1", - "@stdlib/array-defaults": "^0.2.1", - "@stdlib/assert-has-iterator-symbol-support": "^0.2.1", - "@stdlib/assert-is-arraybuffer": "^0.2.1", - "@stdlib/assert-is-collection": "^0.2.1", - "@stdlib/assert-is-function": "^0.2.1", - "@stdlib/assert-is-nonnegative-integer": "^0.2.1", - "@stdlib/assert-is-object": "^0.2.1", - "@stdlib/assert-is-string": "^0.2.1", - "@stdlib/blas-ext-base-gfill-by": "^0.2.1", - "@stdlib/iter-length": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1", - "@stdlib/symbol-iterator": "^0.2.1", - "@stdlib/types": "^0.3.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/array-buffer": "^0.2.1", - "@stdlib/array-complex128": "^0.2.1", - "@stdlib/array-complex64": "^0.2.1", - "@stdlib/array-float32": "^0.2.1", - "@stdlib/array-float64": "^0.2.1", - "@stdlib/array-int16": "^0.2.1", - "@stdlib/array-int32": "^0.2.1", - "@stdlib/array-int8": "^0.2.1", - "@stdlib/array-typed-real-dtypes": "^0.2.1", - "@stdlib/array-uint16": "^0.2.1", - "@stdlib/array-uint32": "^0.2.1", - "@stdlib/array-uint8": "^0.2.1", - "@stdlib/array-uint8c": "^0.2.1", - "@stdlib/assert-instance-of": "^0.2.1", - "@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": "^0.2.1", - "@stdlib/complex-float64": "^0.2.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-complex128": "^0.2.1", - "@stdlib/strided-base-reinterpret-complex64": "^0.2.0", - "@stdlib/utils-constant-function": "^0.2.1", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.1" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..0fbbd35 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index b55aa4a..0000000 --- a/test/test.js +++ /dev/null @@ -1,4248 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 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. -*/ - -/* eslint-disable max-len */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -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 ArrayBuffer = require( '@stdlib/array-buffer' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var iterConstant = require( '@stdlib/iter-constant' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var filledarrayBy = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': !hasIteratorSymbolSupport() -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof filledarrayBy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if only provided callback arguments', function test( t ) { - t.throws( clbk1, TypeError, 'throws an error' ); - t.throws( clbk2, TypeError, 'throws an error' ); - t.throws( clbk3, TypeError, 'throws an error' ); - t.end(); - - function clbk1() { - filledarrayBy( constantFunction( 1.0 ) ); - } - - function clbk2() { - filledarrayBy( constantFunction( 1.0 ), {} ); - } - - function clbk3() { - filledarrayBy( constantFunction( 1.0 ), constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (only argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (typed array; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (array-like object)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (array-like object; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 8 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 8 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, 1, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (iterator)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( iterConstant( 1.0 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (iterator; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( iterConstant( 1.0 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if only provided data type and callback arguments', function test( t ) { - t.throws( clbk1, TypeError, 'throws an error' ); - t.throws( clbk2, TypeError, 'throws an error' ); - t.throws( clbk3, TypeError, 'throws an error' ); - t.end(); - - function clbk1() { - filledarrayBy( 'float64', constantFunction( 1.0 ) ); - } - - function clbk2() { - filledarrayBy( 'float64', constantFunction( 1.0 ), {} ); - } - - function clbk3() { - filledarrayBy( 'float64', constantFunction( 1.0 ), constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (array-like object)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (array-like object; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, 1, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, 1, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (no iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (no iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (non-function iterator symbol property)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (non-function iterator symbol property; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (`next` property is not a function)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ) ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (`next` property is not a function; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ), {} ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (no iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (no iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (non-function iterator symbol property)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (non-function iterator symbol property; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (`next` property is not a function)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ) ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (`next` property is not a function; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ), {} ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 1, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 1, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function returns a filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - arr = filledarrayBy(); - - t.strictEqual( instanceOf( arr, Float64Array ), 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=float64)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - arr = filledarrayBy( 'float64' ); - - t.strictEqual( instanceOf( arr, Float64Array ), 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=float32)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( 0 ); - arr = filledarrayBy( 'float32' ); - - t.strictEqual( instanceOf( arr, Float32Array ), 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; - - expected = new Complex128Array( 0 ); - arr = filledarrayBy( 'complex128' ); - - t.strictEqual( instanceOf( arr, Complex128Array ), 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=complex64)', function test( t ) { - var expected; - var arr; - - expected = new Complex64Array( 0 ); - arr = filledarrayBy( 'complex64' ); - - t.strictEqual( instanceOf( arr, Complex64Array ), 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=int32)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( 0 ); - arr = filledarrayBy( 'int32' ); - - t.strictEqual( instanceOf( arr, Int32Array ), 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=uint32)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( 0 ); - arr = filledarrayBy( 'uint32' ); - - t.strictEqual( instanceOf( arr, Uint32Array ), 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=int16)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( 0 ); - arr = filledarrayBy( 'int16' ); - - t.strictEqual( instanceOf( arr, Int16Array ), 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=uint16)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( 0 ); - arr = filledarrayBy( 'uint16' ); - - t.strictEqual( instanceOf( arr, Uint16Array ), 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=int8)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( 0 ); - arr = filledarrayBy( 'int8' ); - - t.strictEqual( instanceOf( arr, Int8Array ), 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=uint8)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( 0 ); - arr = filledarrayBy( 'uint8' ); - - t.strictEqual( instanceOf( arr, Uint8Array ), 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=uint8c)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( 0 ); - arr = filledarrayBy( 'uint8c' ); - - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), 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=generic)', function test( t ) { - var expected; - var arr; - - expected = []; - arr = filledarrayBy( 'generic' ); - - t.strictEqual( instanceOf( arr, Array ), 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 (default, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, length=0)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array(); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 0, clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, clbk, ctx ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (default, length; thisArg=function)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, clbk, context ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this(); // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } - - function context() { - ctx.count += 1; - } -}); - -tape( 'the function returns a filled array (dtype=float64, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, 'float64', clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, length; thisArg=function)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, 'float64', clbk, context ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this(); // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } - - function context() { - ctx.count += 1; - } -}); - -tape( 'the function returns a filled array (dtype=float32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, 'float32', clbk ); - - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex128, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = filledarrayBy( 5, 'complex128', clbk ); - - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = filledarrayBy( 5, 'complex64', clbk ); - - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int32Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int32', clbk ); - - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint32Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint32', clbk ); - - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int16Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int16', clbk ); - - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint16', clbk ); - - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int8Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int8', clbk ); - - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint8', clbk ); - - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint8c', clbk ); - - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = [ 1, 1, 1, 1, 1 ]; - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'generic', clbk ); - - t.strictEqual( instanceOf( arr, Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex128, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = [ 1.0, 2.0 ]; - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = [ 1.0, 2.0 ]; - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int32', clbk ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, typed array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, typed array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex128, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = new Float64Array( [ 1.0, 2.0 ] ); - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = new Float64Array( [ 1.0, 2.0 ] ); - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (default, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex128, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer, byteoffset; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer, byteoffset; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, 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; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 48 ); - out = filledarrayBy( buf, 16, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 24 ); - out = filledarrayBy( buf, 8, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int32', clbk ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint8c', clbk ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, 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; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 64 ); - out = filledarrayBy( buf, 16, 2, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset, length)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 1, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 1, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled array (default, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, iterator; thisArg)', opts, function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - ctx = { - 'count': 0 - }; - indices = []; - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, iterator; thisArg)', opts, function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - ctx = { - 'count': 0 - }; - indices = []; - out = filledarrayBy( arr, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex128, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = iterConstant( new Complex128( 3.0, 3.0 ), { - 'iter': 2 - }); - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = iterConstant( new Complex64( 3.0, 3.0 ), { - 'iter': 2 - }); - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); From 638eb2b2d0e357dfc85d97f41b07dc1a20520b3a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 07:49:54 +0000 Subject: [PATCH 054/117] Transform error messages --- lib/main.js | 38 +++++++++++++++++++------------------- package.json | 2 +- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/lib/main.js b/lib/main.js index 0f134bb..06bc8b6 100644 --- a/lib/main.js +++ b/lib/main.js @@ -33,7 +33,7 @@ var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-supp var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); var iterLength = require( '@stdlib/iter-length' ); var defaults = require( '@stdlib/array-defaults' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -264,18 +264,18 @@ function filledarrayBy() { if ( isString( dtype ) ) { // Invoking this function with arguments `f( dtype, clbk[, thisArg] )` is not allowed (otherwise, we'd need to also allow `f( clbk[, thisArg] )`)... if ( nargs > 1 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format('00h05') ); } ctor = ctors( dtype ); if ( ctor === null ) { - throw new TypeError( format( 'invalid argument. Must provide a recognized data type. Value: `%s`.', dtype ) ); + throw new TypeError( format( '00h2Y', dtype ) ); } // Return an empty array having the specified dtype: return new ctor( 0 ); } // For all other supported invocations, we need at least two arguments... if ( nargs < 2 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format('00h05') ); } // At this point, we need to do some argument juggling... nargs -= 1; // henceforth, the number of available arguments is `nargs+1` @@ -290,7 +290,7 @@ function filledarrayBy() { // Check if we were provided only a callback and a "this" context.. if ( nargs === 0 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format('00h05') ); } } else { // "this" context is left undefined... @@ -303,12 +303,12 @@ function filledarrayBy() { nargs -= 1; clbk = arguments[ nargs ]; if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '00h2b', clbk ) ); } } // If were were only provided 2 arguments and the last argument was not a function, we've been provided an insufficient number of arguments... else { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format('00h05') ); } // Now that we've processed the callback arguments, let's continue working backward to see if we've been provided a `dtype` argument... nargs -= 1; @@ -320,7 +320,7 @@ function filledarrayBy() { } ctor = ctors( dtype ); if ( ctor === null ) { - throw new TypeError( format( 'invalid argument. Must provide a recognized data type. Value: `%s`.', dtype ) ); + throw new TypeError( format( '00h2Y', dtype ) ); } // At this point, we've resolved the output array data type, and now we can actually create the output array... if ( dtype === 'generic' ) { @@ -335,26 +335,26 @@ function filledarrayBy() { return filledArray( len, clbk, thisArg ); } if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format('00h04') ); } if ( isObject( arg ) ) { if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2Z', arg ) ); } if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } arg = arg[ ITERATOR_SYMBOL ](); if ( !isFunction( arg.next ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } return filledArrayIterator( arg, clbk, thisArg ); } - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } else if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format('00h04') ); } - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } if ( nargs === 0 ) { // length || array-like || ArrayBuffer || iterable arg = arguments[ 0 ]; @@ -366,18 +366,18 @@ function filledarrayBy() { arr = new ctor( arg ); } else if ( isObject( arg ) ) { if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2Z', arg ) ); } if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } arg = arg[ ITERATOR_SYMBOL ](); if ( !isFunction( arg.next ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } arr = new ctor( iterLength( arg ) ); } else { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } } else if ( nargs === 1 ) { arr = new ctor( arguments[0], arguments[1] ); // (ArrayBuffer, byteOffset) diff --git a/package.json b/package.json index 8efaed0..fe41e9b 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "@stdlib/assert-is-string": "^0.2.1", "@stdlib/blas-ext-base-gfill-by": "^0.2.1", "@stdlib/iter-length": "^0.2.1", - "@stdlib/string-format": "^0.2.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1", "@stdlib/symbol-iterator": "^0.2.1", "@stdlib/types": "^0.3.2", "@stdlib/error-tools-fmtprodmsg": "^0.2.1" From fe57081d0a63312abdcae27eb9e7e55c570aac67 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 13:19:13 +0000 Subject: [PATCH 055/117] Remove files --- index.d.ts | 426 ----- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5273 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index e1b94a1..0000000 --- a/index.d.ts +++ /dev/null @@ -1,426 +0,0 @@ -/* -* @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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, RealOrComplexTypedArray, DataType } from '@stdlib/types/array'; -import { IterableIterator } from '@stdlib/types/iter'; - -/** -* Array or typed array. -*/ -type ArrayOrTypedArray = Array | RealOrComplexTypedArray; - -/** -* Nullary callback function. -* -* @returns fill value -*/ -type Nullary = () => any; - -/** -* Unary callback function. -* -* @param i - current array index -* @returns fill value -*/ -type Unary = ( i: number ) => any; - -/** -* Callback function. -* -* @param i - current array index -* @returns fill value -*/ -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 -* -* @example -* var arr = filledarrayBy(); -* // returns -* -* @example -* var arr = filledarrayBy( 'float32' ); -* // returns -*/ -declare function filledarrayBy( dtype?: DataType ): ArrayOrTypedArray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Creates a filled array according to a provided callback function and having a specified `length`. -* -* @param length - array length -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* -* var arr = filledarrayBy( 5, constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( length: number, clbk: Callback, thisArg?: any ): ArrayOrTypedArray; - -/** -* 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 -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* -* var arr = filledarrayBy( 5, 'float64', constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( length: number, dtype: DataType, clbk: Callback, thisArg?: any ): ArrayOrTypedArray; - -/** -* Creates a filled array from another `array` according to a provided callback function. -* -* @param array - typed array or array-like object -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* -* 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; - -/** -* 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 -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* -* 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; - -/** -* Creates a filled array from an iterable according to a callback function. -* -* @param iterable - iterable -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var iterConstant = require( '@stdlib/iter-constant' ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarrayBy( it, constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( iterable: IterableIterator, callback: Callback, thisArg?: any ): ArrayOrTypedArray; - -/** -* 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 -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var iterConstant = require( '@stdlib/iter-constant' ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* 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; - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; - -/** -* 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. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; - -/** -* 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. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; - -/** -* 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. -* -* @param buffer - `ArrayBuffer` -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; - - -// EXPORTS // - -export = filledarrayBy; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 56b3976..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.1-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-ctors@v0.2.1-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill-by@v0.2.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled-by@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.2.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.1-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@v0.2.1-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.2.1-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";var j=d(),a=p.get("dtypes.default");function v(){var d,p,v,c,g,y,b,u;if(0===(p=arguments.length))return new(g=o(a))(0);if(r(v=arguments[0])){if(p>1)throw new TypeError(w("00h05"));if(null===(g=o(v)))throw new TypeError(w("00h2Y",v));return new g(0)}if(p<2)throw new TypeError(w("00h05"));if(n(arguments[p-=1]))if(n(arguments[p-1])){if(d=arguments[p],c=arguments[p-=1],0===p)throw new TypeError(w("00h05"))}else c=arguments[p];else{if(!(p>=2))throw new TypeError(w("00h05"));if(d=arguments[p],!n(c=arguments[p-=1]))throw new TypeError(w("00h2b",c))}if((p-=1)>=0&&r(arguments[p])?(v=arguments[p],p-=1):v=a,null===(g=o(v)))throw new TypeError(w("00h2Y",v));if("generic"===v){if(u=arguments[0],0===p){if(e(u)?b=u:t(u)&&(b=u.length),void 0!==b)return l(b,c,d);if(s(u))throw new Error(w("00h04"));if(i(u)){if(!1===j)throw new TypeError(w("00h2Z",u));if(!n(u[m]))throw new TypeError(w("00h2a",u));if(u=u[m](),!n(u.next))throw new TypeError(w("00h2a",u));return function(r,e,t){var s,i;for(s=[],i=-1;!r.next().done;)i+=1,s.push(e.call(t,i));return s}(u,c,d)}throw new TypeError(w("00h2a",u))}if(s(u))throw new Error(w("00h04"));throw new TypeError(w("00h2a",u))}if(0===p)if(t(u=arguments[0]))y=new g(u.length);else if(s(u))y=new g(u);else if(e(u))y=new g(u);else{if(!i(u))throw new TypeError(w("00h2a",u));if(!1===j)throw new TypeError(w("00h2Z",u));if(!n(u[m]))throw new TypeError(w("00h2a",u));if(u=u[m](),!n(u.next))throw new TypeError(w("00h2a",u));y=new g(f(u))}else y=1===p?new g(arguments[0],arguments[1]):new g(arguments[0],arguments[1],arguments[2]);return y.length>0&&(/^complex/.test(v)?function(r,e,t){var s;for(s=0;s\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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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( format('00h05') );\n\t\t}\n\t\tctor = ctors( dtype );\n\t\tif ( ctor === null ) {\n\t\t\tthrow new TypeError( format( '00h2Y', 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( format('00h05') );\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( format('00h05') );\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( '00h2b', 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( format('00h05') );\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( '00h2Y', 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( format('00h04') );\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( '00h2Z', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00h2a', 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( '00h2a', 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( '00h2a', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format('00h04') );\n\t\t}\n\t\tthrow new TypeError( format( '00h2a', 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( '00h2Z', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00h2a', 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( '00h2a', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00h2a', 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\nexport default filledarrayBy;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","DEFAULT_DTYPE","defaults","get","filledarrayBy","thisArg","nargs","dtype","clbk","ctor","arr","len","arg","arguments","length","ctors","isString","TypeError","format","isFunction","isNonNegativeInteger","isCollection","filledArray","isArrayBuffer","Error","isObject","ITERATOR_SYMBOL","next","it","i","done","push","call","filledArrayIterator","iterLength","test","set","filledAccessors","gfillBy","value","aidx"],"mappings":";;q0CAwCA,IAAIA,EAAsBC,IACtBC,EAAgBC,EAASC,IAAK,kBA2MlC,SAASC,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAKJ,GAAe,KAHfN,EAAQO,UAAUC,QAKjB,OAAO,IADPL,EAAOM,EAAOd,IACG,GAIlB,GAAKe,EADLT,EAAQM,UAAW,IACM,CAExB,GAAKP,EAAQ,EACZ,MAAM,IAAIW,UAAWC,EAAO,UAG7B,GAAc,QADdT,EAAOM,EAAOR,IAEb,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,OAAO,IAAIE,EAAM,EACjB,CAED,GAAKH,EAAQ,EACZ,MAAM,IAAIW,UAAWC,EAAO,UAM7B,GAAKC,EAAYN,UAHjBP,GAAS,IAKR,GAAKa,EAAYN,UAAWP,EAAM,KAMjC,GALAD,EAAUQ,UAAWP,GAErBE,EAAOK,UADPP,GAAS,GAIM,IAAVA,EACJ,MAAM,IAAIW,UAAWC,EAAO,eAI7BV,EAAOK,UAAWP,OAIf,MAAKA,GAAS,GAUlB,MAAM,IAAIW,UAAWC,EAAO,UAN5B,GAHAb,EAAUQ,UAAWP,IAGfa,EADNX,EAAOK,UADPP,GAAS,IAGR,MAAM,IAAIW,UAAWC,EAAQ,QAASV,GAMvC,CAUD,IARAF,GAAS,IACK,GAAKU,EAAUH,UAAWP,KACvCC,EAAQM,UAAWP,GACnBA,GAAS,GAETC,EAAQN,EAGK,QADdQ,EAAOM,EAAOR,IAEb,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,GAAe,YAAVA,EAAsB,CAE1B,GADAK,EAAMC,UAAW,GACF,IAAVP,EAAc,CAMlB,GALKc,EAAsBR,GAC1BD,EAAMC,EACKS,EAAcT,KACzBD,EAAMC,EAAIE,aAEE,IAARH,EACJ,OAAOW,EAAaX,EAAKH,EAAMH,GAEhC,GAAKkB,EAAeX,GACnB,MAAM,IAAIY,MAAON,EAAO,UAEzB,GAAKO,EAAUb,GAAQ,CACtB,IAA6B,IAAxBb,EACJ,MAAM,IAAIkB,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAYP,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLP,EAAYP,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvC,OAvSJ,SAA8BgB,EAAIpB,EAAMH,GACvC,IAAIK,EACAmB,EAKJ,IAFAnB,EAAM,GACNmB,GAAK,GAEAD,EAAGD,OACAG,MAGPD,GAAK,EACLnB,EAAIqB,KAAMvB,EAAKwB,KAAM3B,EAASwB,IAE/B,OAAOnB,CACR,CAuRWuB,CAAqBrB,EAAKJ,EAAMH,EACvC,CACD,MAAM,IAAIY,UAAWC,EAAQ,QAASN,GACzC,CAAS,GAAKW,EAAeX,GAC1B,MAAM,IAAIY,MAAON,EAAO,UAEzB,MAAM,IAAID,UAAWC,EAAQ,QAASN,GACtC,CACD,GAAe,IAAVN,EAEJ,GAAKe,EADLT,EAAMC,UAAW,IAEhBH,EAAM,IAAID,EAAMG,EAAIE,aACd,GAAKS,EAAeX,GAC1BF,EAAM,IAAID,EAAMG,QACV,GAAKQ,EAAsBR,GACjCF,EAAM,IAAID,EAAMG,OACV,KAAKa,EAAUb,GAarB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAZtC,IAA6B,IAAxBb,EACJ,MAAM,IAAIkB,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAYP,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLP,EAAYP,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvCF,EAAM,IAAID,EAAMyB,EAAYtB,GAG5B,MAEDF,EADqB,IAAVJ,EACL,IAAIG,EAAMI,UAAU,GAAIA,UAAU,IAElC,IAAIJ,EAAMI,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKH,EAAII,OAAS,IACZ,WAAWqB,KAAM5B,GAjTxB,SAA0BG,EAAKF,EAAMH,GACpC,IAAIwB,EACJ,IAAMA,EAAI,EAAGA,EAAInB,EAAII,OAAQe,IAC5BnB,EAAI0B,IAAK5B,EAAKwB,KAAM3B,EAASwB,GAAKA,EAGpC,CA4SGQ,CAAiB3B,EAAKF,EAAMH,GAE5BiC,EAAS5B,EAAII,OAAQJ,EAAK,GAe5B,SAAmB6B,EAAOC,GACzB,OAAOhC,EAAKwB,KAAM3B,EAASmC,EAC3B,KAdM9B,CAeR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 0fbbd35..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From cfb3bec4b1e89c1d2d0465227a3e18330a95097b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 13:19:38 +0000 Subject: [PATCH 056/117] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 ---- .github/workflows/publish.yml | 249 -- .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 132 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 47 +- SECURITY.md | 5 - benchmark/benchmark.js | 319 -- benchmark/benchmark.length.complex128.js | 98 - benchmark/benchmark.length.complex64.js | 98 - benchmark/benchmark.length.float32.js | 97 - benchmark/benchmark.length.float64.js | 97 - benchmark/benchmark.length.generic.js | 97 - benchmark/benchmark.length.int16.js | 97 - benchmark/benchmark.length.int32.js | 97 - benchmark/benchmark.length.int8.js | 97 - benchmark/benchmark.length.uint16.js | 97 - benchmark/benchmark.length.uint32.js | 97 - benchmark/benchmark.length.uint8.js | 97 - benchmark/benchmark.length.uint8c.js | 97 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 174 - docs/types/test.ts | 606 --- examples/index.js | 37 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 192 - lib/main.js | 414 -- package.json | 92 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 4248 ------------------ 55 files changed, 4869 insertions(+), 10550 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.length.complex128.js delete mode 100644 benchmark/benchmark.length.complex64.js delete mode 100644 benchmark/benchmark.length.float32.js delete mode 100644 benchmark/benchmark.length.float64.js delete mode 100644 benchmark/benchmark.length.generic.js delete mode 100644 benchmark/benchmark.length.int16.js delete mode 100644 benchmark/benchmark.length.int32.js delete mode 100644 benchmark/benchmark.length.int8.js delete mode 100644 benchmark/benchmark.length.uint16.js delete mode 100644 benchmark/benchmark.length.uint32.js delete mode 100644 benchmark/benchmark.length.uint8.js delete mode 100644 benchmark/benchmark.length.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index dcb33fe..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-04-01T05:26:56.736Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 8be0b82..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index f988046..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index b2c1f9c..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '42 6 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index ec90164..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -293,7 +284,7 @@ for ( i = 0; i < dt.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -364,9 +355,9 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/filled]: https://github.com/stdlib-js/array-filled +[@stdlib/array/filled]: https://github.com/stdlib-js/array-filled/tree/esm -[@stdlib/array/typed]: https://github.com/stdlib-js/array-typed +[@stdlib/array/typed]: https://github.com/stdlib-js/array-typed/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 67ba493..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,319 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); -var isArray = require( '@stdlib/assert-is-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var pkg = require( './../package.json' ).name; -var filledarrayBy = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 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=float64', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'float64', 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=float32', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'float32', 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; - var i; - - clbk = constantFunction( new Complex128( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'complex128', 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=complex64', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( new Complex64( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'complex64', 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=int32', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int32', 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=uint32', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint32', 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=int16', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int16', 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=uint16', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint16', 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=int8', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int8', 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=uint8', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint8', 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=uint8c', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint8c', 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=generic', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'generic', clbk ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.length.complex128.js b/benchmark/benchmark.length.complex128.js deleted file mode 100644 index 27f6c66..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 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 Complex128 = require( '@stdlib/complex-float64' ); -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( new Complex128( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'complex128', 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=complex128,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.complex64.js b/benchmark/benchmark.length.complex64.js deleted file mode 100644 index c094ae9..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 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 Complex64 = require( '@stdlib/complex-float32' ); -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( new Complex64( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'complex64', 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=complex64,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.float32.js b/benchmark/benchmark.length.float32.js deleted file mode 100644 index d2b2ba7..0000000 --- a/benchmark/benchmark.length.float32.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'float32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=float32,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.float64.js b/benchmark/benchmark.length.float64.js deleted file mode 100644 index 65064e3..0000000 --- a/benchmark/benchmark.length.float64.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'float64', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=float64,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.generic.js b/benchmark/benchmark.length.generic.js deleted file mode 100644 index eb87dfa..0000000 --- a/benchmark/benchmark.length.generic.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isArray = require( '@stdlib/assert-is-array' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'generic', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isArray( 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=generic,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int16.js b/benchmark/benchmark.length.int16.js deleted file mode 100644 index 914ff7c..0000000 --- a/benchmark/benchmark.length.int16.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int16', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=int16,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int32.js b/benchmark/benchmark.length.int32.js deleted file mode 100644 index cc0f678..0000000 --- a/benchmark/benchmark.length.int32.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=int32,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int8.js b/benchmark/benchmark.length.int8.js deleted file mode 100644 index 77553b0..0000000 --- a/benchmark/benchmark.length.int8.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int8', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=int8,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint16.js b/benchmark/benchmark.length.uint16.js deleted file mode 100644 index c68efdd..0000000 --- a/benchmark/benchmark.length.uint16.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint16', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint16,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint32.js b/benchmark/benchmark.length.uint32.js deleted file mode 100644 index 27c1742..0000000 --- a/benchmark/benchmark.length.uint32.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint32,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint8.js b/benchmark/benchmark.length.uint8.js deleted file mode 100644 index 2a26be4..0000000 --- a/benchmark/benchmark.length.uint8.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint8', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint8,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint8c.js b/benchmark/benchmark.length.uint8c.js deleted file mode 100644 index dd6e8c2..0000000 --- a/benchmark/benchmark.length.uint8c.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint8c', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint8c,len='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index c138144..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by" -%% click B href "https://github.com/stdlib-js/array-filled-by/tree/main" -%% click C href "https://github.com/stdlib-js/array-filled-by/tree/production" -%% click D href "https://github.com/stdlib-js/array-filled-by/tree/esm" -%% click E href "https://github.com/stdlib-js/array-filled-by/tree/deno" -%% click F href "https://github.com/stdlib-js/array-filled-by/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by -[production-url]: https://github.com/stdlib-js/array-filled-by/tree/production -[deno-url]: https://github.com/stdlib-js/array-filled-by/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-filled-by/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-filled-by/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-filled-by/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-filled-by/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-filled-by/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 188fc9b..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import filledarrayBy from '../docs/types/index'; -export = filledarrayBy; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 468e99c..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"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 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 00888a2..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "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,EAAQ,UAAU,OAGbA,IAAU,EACd,OAAAE,EAAOrB,EAAOS,CAAc,EACrB,IAAIY,EAAM,CAAE,EAIpB,GADAD,EAAQ,UAAW,CAAE,EAChB1B,EAAU0B,CAAM,EAAI,CAExB,GAAKD,EAAQ,EACZ,MAAM,IAAI,UAAW,2FAA4F,EAGlH,GADAE,EAAOrB,EAAOoB,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWd,EAAQ,sEAAuEa,CAAM,CAAE,EAG7G,OAAO,IAAIC,EAAM,CAAE,CACpB,CAEA,GAAKF,EAAQ,EACZ,MAAM,IAAI,UAAW,2FAA4F,EAMlH,GAHAA,GAAS,EAGJpB,EAAY,UAAWoB,CAAM,CAAE,EAEnC,GAAKpB,EAAY,UAAWoB,EAAM,CAAE,CAAE,GAMrC,GALAN,EAAU,UAAWM,CAAM,EAC3BA,GAAS,EACTP,EAAO,UAAWO,CAAM,EAGnBA,IAAU,EACd,MAAM,IAAI,UAAW,2FAA4F,OAIlHP,EAAO,UAAWO,CAAM,UAIhBA,GAAS,GAIlB,GAHAN,EAAU,UAAWM,CAAM,EAC3BA,GAAS,EACTP,EAAO,UAAWO,CAAM,EACnB,CAACpB,EAAYa,CAAK,EACtB,MAAM,IAAI,UAAWL,EAAQ,uEAAwEK,CAAK,CAAE,MAK7G,OAAM,IAAI,UAAW,2FAA4F,EAWlH,GARAO,GAAS,EACJA,GAAS,GAAKzB,EAAU,UAAWyB,CAAM,CAAE,GAC/CC,EAAQ,UAAWD,CAAM,EACzBA,GAAS,GAETC,EAAQX,EAETY,EAAOrB,EAAOoB,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWd,EAAQ,sEAAuEa,CAAM,CAAE,EAG7G,GAAKA,IAAU,UAAY,CAE1B,GADAG,EAAM,UAAW,CAAE,EACdJ,IAAU,EAAI,CAMlB,GALKxB,EAAsB4B,CAAI,EAC9BD,EAAMC,EACK3B,EAAc2B,CAAI,IAC7BD,EAAMC,EAAI,QAEND,IAAQ,OACZ,OAAOpB,EAAaoB,EAAKV,EAAMC,CAAQ,EAExC,GAAKhB,EAAe0B,CAAI,EACvB,MAAM,IAAI,MAAO,mFAAoF,EAEtG,GAAKzB,EAAUyB,CAAI,EAAI,CACtB,GAAKf,IAAwB,GAC5B,MAAM,IAAI,UAAWD,EAAQ,sIAAuIgB,CAAI,CAAE,EAE3K,GAAK,CAACxB,EAAYwB,EAAKnB,CAAgB,CAAE,EACxC,MAAM,IAAI,UAAWG,EAAQ,wGAAyGgB,CAAI,CAAE,EAG7I,GADAA,EAAMA,EAAKnB,CAAgB,EAAE,EACxB,CAACL,EAAYwB,EAAI,IAAK,EAC1B,MAAM,IAAI,UAAWhB,EAAQ,wGAAyGgB,CAAI,CAAE,EAE7I,OAAOb,EAAqBa,EAAKX,EAAMC,CAAQ,CAChD,CACA,MAAM,IAAI,UAAWN,EAAQ,wGAAyGgB,CAAI,CAAE,CAC7I,SAAY1B,EAAe0B,CAAI,EAC9B,MAAM,IAAI,MAAO,mFAAoF,EAEtG,MAAM,IAAI,UAAWhB,EAAQ,wGAAyGgB,CAAI,CAAE,CAC7I,CACA,GAAKJ,IAAU,EAEd,GADAI,EAAM,UAAW,CAAE,EACd3B,EAAc2B,CAAI,EACtBT,EAAM,IAAIO,EAAME,EAAI,MAAO,UAChB1B,EAAe0B,CAAI,EAC9BT,EAAM,IAAIO,EAAME,CAAI,UACT5B,EAAsB4B,CAAI,EACrCT,EAAM,IAAIO,EAAME,CAAI,UACTzB,EAAUyB,CAAI,EAAI,CAC7B,GAAKf,IAAwB,GAC5B,MAAM,IAAI,UAAWD,EAAQ,sIAAuIgB,CAAI,CAAE,EAE3K,GAAK,CAACxB,EAAYwB,EAAKnB,CAAgB,CAAE,EACxC,MAAM,IAAI,UAAWG,EAAQ,wGAAyGgB,CAAI,CAAE,EAG7I,GADAA,EAAMA,EAAKnB,CAAgB,EAAE,EACxB,CAACL,EAAYwB,EAAI,IAAK,EAC1B,MAAM,IAAI,UAAWhB,EAAQ,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"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 5a68984..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,174 +0,0 @@ - -{{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) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr = {{alias}}() - - > arr = {{alias}}( 'float32' ) - - - -{{alias}}( length[, dtype], clbk[, thisArg] ) - Returns a filled array according to a provided callback function and having - a specified length. - - Parameters - ---------- - length: integer - Array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > function clbk() { return 1.0; }; - > var arr = {{alias}}( 5, clbk ) - [ 1.0, 1.0, 1.0, 1.0, 1.0 ] - > arr = {{alias}}( 5, 'int32', clbk ) - [ 1, 1, 1, 1, 1 ] - - -{{alias}}( array[, dtype], clbk[, thisArg] ) - Creates a filled array from another array (or array-like object) according - to a provided callback function. - - Parameters - ---------- - array: ArrayLikeObject - Array from which to generate another array. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias}}( [ 0.5, 0.5, 0.5 ], {{alias:@stdlib/utils/constant-function}}( 2.0 ) ) - [ 2.0, 2.0, 2.0 ] - > var arr2 = {{alias}}( arr1, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( iterable[, dtype], clbk[, thisArg] ) - Creates a filled array from an iterable according to a provided callback - function. - - Parameters - ---------- - iterable: Iterable - Iterable from which to generate an array. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias:@stdlib/iter/constant}}( 3.0, {'iter': 3} ); - > var arr2 = {{alias}}( arr1, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( buffer[, byteOffset[, length]][, dtype], clbk[, thisArg] ) - Returns a filled typed array view of an ArrayBuffer according to a provided - callback function. - - The 'generic' array data type is *not* supported. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( buf, 0, 4, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0, 1.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 394ac49..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,606 +0,0 @@ -/* -* @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. -*/ - -/// - -import { IterableIterator } from '@stdlib/types/iter'; -import filledarrayBy = require( './index' ); - - -/** -* Returns an iterator protocol-compliant object. -* -* @returns iterator protocol-compliant object -*/ -function iterator(): IterableIterator { - const obj: IterableIterator = { - [Symbol.iterator]: iterator, - 'next': next - }; - return obj; -} - -/** -* Implements the iterator protocol `next` method. -* -* @returns iterator protocol-compliant object -*/ -function next(): any { - return { - 'value': 1.0, - 'done': false - }; -} - -/** -* Callback function. -* -* @param i - current array index -* @returns return value -*/ -function clbk( i: number ): number { - return i; -} - - -// TESTS // - -// The function returns an array or typed array... -{ - filledarrayBy(); // $ExpectType ArrayOrTypedArray - filledarrayBy( 'float32' ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( 10, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( 10, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( 10, 'int32', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( 10, 'int32', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const x = new Float64Array( 10 ); - filledarrayBy( x, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( x, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( x, 'uint8', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( x, 'uint8', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const y = [ 2.0, 2.0, 2.0 ]; - filledarrayBy( y, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( y, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( y, 'float64', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( y, 'float64', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const it = iterator(); - filledarrayBy( it, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( it, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( it, 'uint8c', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( it, 'uint8c', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const buf = new ArrayBuffer( 32 ); - filledarrayBy( buf, clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 'uint32', clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 'uint32', clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 8, clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 8, clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 8, 'uint16', clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 8, 'uint16', clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 8, 2, clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 8, 2, clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 8, 2, 'int16', clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 8, 2, 'int16', clbk, {} ); // $ExpectType RealOrComplexTypedArray -} - -// The compiler throws an error if a callback function argument is not a function... -{ - filledarrayBy( 'float64', '5' ); // $ExpectError - filledarrayBy( 'float64', 1.0 ); // $ExpectError - filledarrayBy( 'float64', false ); // $ExpectError - filledarrayBy( 'float64', true ); // $ExpectError - filledarrayBy( 'float64', null ); // $ExpectError - filledarrayBy( 'float64', undefined ); // $ExpectError - filledarrayBy( 'float64', [] ); // $ExpectError - filledarrayBy( 'float64', {} ); // $ExpectError - - filledarrayBy( 'float64', '5', {} ); // $ExpectError - filledarrayBy( 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( 'float64', false, {} ); // $ExpectError - filledarrayBy( 'float64', true, {} ); // $ExpectError - filledarrayBy( 'float64', null, {} ); // $ExpectError - filledarrayBy( 'float64', undefined, {} ); // $ExpectError - filledarrayBy( 'float64', [], {} ); // $ExpectError - filledarrayBy( 'float64', {}, {} ); // $ExpectError - - filledarrayBy( 10, '5' ); // $ExpectError - filledarrayBy( 10, 1.0 ); // $ExpectError - filledarrayBy( 10, false ); // $ExpectError - filledarrayBy( 10, true ); // $ExpectError - filledarrayBy( 10, null ); // $ExpectError - filledarrayBy( 10, undefined ); // $ExpectError - filledarrayBy( 10, [] ); // $ExpectError - filledarrayBy( 10, {} ); // $ExpectError - - filledarrayBy( 10, '5', {} ); // $ExpectError - filledarrayBy( 10, 1.0, {} ); // $ExpectError - filledarrayBy( 10, false, {} ); // $ExpectError - filledarrayBy( 10, true, {} ); // $ExpectError - filledarrayBy( 10, null, {} ); // $ExpectError - filledarrayBy( 10, undefined, {} ); // $ExpectError - filledarrayBy( 10, [], {} ); // $ExpectError - filledarrayBy( 10, {}, {} ); // $ExpectError - - filledarrayBy( 10, 'float64', '5' ); // $ExpectError - filledarrayBy( 10, 'float64', 1.0 ); // $ExpectError - filledarrayBy( 10, 'float64', false ); // $ExpectError - filledarrayBy( 10, 'float64', true ); // $ExpectError - filledarrayBy( 10, 'float64', null ); // $ExpectError - filledarrayBy( 10, 'float64', undefined ); // $ExpectError - filledarrayBy( 10, 'float64', [] ); // $ExpectError - filledarrayBy( 10, 'float64', {} ); // $ExpectError - - filledarrayBy( 10, 'float64', '5', {} ); // $ExpectError - filledarrayBy( 10, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( 10, 'float64', false, {} ); // $ExpectError - filledarrayBy( 10, 'float64', true, {} ); // $ExpectError - filledarrayBy( 10, 'float64', null, {} ); // $ExpectError - filledarrayBy( 10, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( 10, 'float64', [], {} ); // $ExpectError - filledarrayBy( 10, 'float64', {}, {} ); // $ExpectError - - const x = new Float64Array( 10 ); - filledarrayBy( x, '5' ); // $ExpectError - filledarrayBy( x, 1.0 ); // $ExpectError - filledarrayBy( x, false ); // $ExpectError - filledarrayBy( x, true ); // $ExpectError - filledarrayBy( x, null ); // $ExpectError - filledarrayBy( x, undefined ); // $ExpectError - filledarrayBy( x, [] ); // $ExpectError - filledarrayBy( x, {} ); // $ExpectError - - filledarrayBy( x, '5', {} ); // $ExpectError - filledarrayBy( x, 1.0, {} ); // $ExpectError - filledarrayBy( x, false, {} ); // $ExpectError - filledarrayBy( x, true, {} ); // $ExpectError - filledarrayBy( x, null, {} ); // $ExpectError - filledarrayBy( x, undefined, {} ); // $ExpectError - filledarrayBy( x, [], {} ); // $ExpectError - filledarrayBy( x, {}, {} ); // $ExpectError - - filledarrayBy( x, 'float64', '5' ); // $ExpectError - filledarrayBy( x, 'float64', 1.0 ); // $ExpectError - filledarrayBy( x, 'float64', false ); // $ExpectError - filledarrayBy( x, 'float64', true ); // $ExpectError - filledarrayBy( x, 'float64', null ); // $ExpectError - filledarrayBy( x, 'float64', undefined ); // $ExpectError - filledarrayBy( x, 'float64', [] ); // $ExpectError - filledarrayBy( x, 'float64', {} ); // $ExpectError - - filledarrayBy( x, 'float64', '5', {} ); // $ExpectError - filledarrayBy( x, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( x, 'float64', false, {} ); // $ExpectError - filledarrayBy( x, 'float64', true, {} ); // $ExpectError - filledarrayBy( x, 'float64', null, {} ); // $ExpectError - filledarrayBy( x, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( x, 'float64', [], {} ); // $ExpectError - filledarrayBy( x, 'float64', {}, {} ); // $ExpectError - - const y = [ 2.0, 2.0, 2.0 ]; - filledarrayBy( y, '5' ); // $ExpectError - filledarrayBy( y, 1.0 ); // $ExpectError - filledarrayBy( y, false ); // $ExpectError - filledarrayBy( y, true ); // $ExpectError - filledarrayBy( y, null ); // $ExpectError - filledarrayBy( y, undefined ); // $ExpectError - filledarrayBy( y, [] ); // $ExpectError - filledarrayBy( y, {} ); // $ExpectError - - filledarrayBy( y, '5', {} ); // $ExpectError - filledarrayBy( y, 1.0, {} ); // $ExpectError - filledarrayBy( y, false, {} ); // $ExpectError - filledarrayBy( y, true, {} ); // $ExpectError - filledarrayBy( y, null, {} ); // $ExpectError - filledarrayBy( y, undefined, {} ); // $ExpectError - filledarrayBy( y, [], {} ); // $ExpectError - filledarrayBy( y, {}, {} ); // $ExpectError - - filledarrayBy( y, 'float64', '5' ); // $ExpectError - filledarrayBy( y, 'float64', 1.0 ); // $ExpectError - filledarrayBy( y, 'float64', false ); // $ExpectError - filledarrayBy( y, 'float64', true ); // $ExpectError - filledarrayBy( y, 'float64', null ); // $ExpectError - filledarrayBy( y, 'float64', undefined ); // $ExpectError - filledarrayBy( y, 'float64', [] ); // $ExpectError - filledarrayBy( y, 'float64', {} ); // $ExpectError - - filledarrayBy( y, 'float64', '5', {} ); // $ExpectError - filledarrayBy( y, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( y, 'float64', false, {} ); // $ExpectError - filledarrayBy( y, 'float64', true, {} ); // $ExpectError - filledarrayBy( y, 'float64', null, {} ); // $ExpectError - filledarrayBy( y, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( y, 'float64', [], {} ); // $ExpectError - filledarrayBy( y, 'float64', {}, {} ); // $ExpectError - - const it = iterator(); - filledarrayBy( it, '5' ); // $ExpectError - filledarrayBy( it, 1.0 ); // $ExpectError - filledarrayBy( it, false ); // $ExpectError - filledarrayBy( it, true ); // $ExpectError - filledarrayBy( it, null ); // $ExpectError - filledarrayBy( it, undefined ); // $ExpectError - filledarrayBy( it, [] ); // $ExpectError - filledarrayBy( it, {} ); // $ExpectError - - filledarrayBy( it, '5', {} ); // $ExpectError - filledarrayBy( it, 1.0, {} ); // $ExpectError - filledarrayBy( it, false, {} ); // $ExpectError - filledarrayBy( it, true, {} ); // $ExpectError - filledarrayBy( it, null, {} ); // $ExpectError - filledarrayBy( it, undefined, {} ); // $ExpectError - filledarrayBy( it, [], {} ); // $ExpectError - filledarrayBy( it, {}, {} ); // $ExpectError - - filledarrayBy( it, 'float64', '5' ); // $ExpectError - filledarrayBy( it, 'float64', 1.0 ); // $ExpectError - filledarrayBy( it, 'float64', false ); // $ExpectError - filledarrayBy( it, 'float64', true ); // $ExpectError - filledarrayBy( it, 'float64', null ); // $ExpectError - filledarrayBy( it, 'float64', undefined ); // $ExpectError - filledarrayBy( it, 'float64', [] ); // $ExpectError - filledarrayBy( it, 'float64', {} ); // $ExpectError - - filledarrayBy( it, 'float64', '5', {} ); // $ExpectError - filledarrayBy( it, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( it, 'float64', false, {} ); // $ExpectError - filledarrayBy( it, 'float64', true, {} ); // $ExpectError - filledarrayBy( it, 'float64', null, {} ); // $ExpectError - filledarrayBy( it, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( it, 'float64', [], {} ); // $ExpectError - filledarrayBy( it, 'float64', {}, {} ); // $ExpectError - - const buf = new ArrayBuffer( 32 ); - filledarrayBy( buf, '5' ); // $ExpectError - filledarrayBy( buf, 1.0 ); // $ExpectError - filledarrayBy( buf, false ); // $ExpectError - filledarrayBy( buf, true ); // $ExpectError - filledarrayBy( buf, null ); // $ExpectError - filledarrayBy( buf, undefined ); // $ExpectError - filledarrayBy( buf, [] ); // $ExpectError - filledarrayBy( buf, {} ); // $ExpectError - - filledarrayBy( buf, '5', {} ); // $ExpectError - filledarrayBy( buf, 1.0, {} ); // $ExpectError - filledarrayBy( buf, false, {} ); // $ExpectError - filledarrayBy( buf, true, {} ); // $ExpectError - filledarrayBy( buf, null, {} ); // $ExpectError - filledarrayBy( buf, undefined, {} ); // $ExpectError - filledarrayBy( buf, [], {} ); // $ExpectError - filledarrayBy( buf, {}, {} ); // $ExpectError - - filledarrayBy( buf, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 'float64', false ); // $ExpectError - filledarrayBy( buf, 'float64', true ); // $ExpectError - filledarrayBy( buf, 'float64', null ); // $ExpectError - filledarrayBy( buf, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 'float64', {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5' ); // $ExpectError - filledarrayBy( buf, 8, 1.0 ); // $ExpectError - filledarrayBy( buf, 8, false ); // $ExpectError - filledarrayBy( buf, 8, true ); // $ExpectError - filledarrayBy( buf, 8, null ); // $ExpectError - filledarrayBy( buf, 8, undefined ); // $ExpectError - filledarrayBy( buf, 8, [] ); // $ExpectError - filledarrayBy( buf, 8, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, false, {} ); // $ExpectError - filledarrayBy( buf, 8, true, {} ); // $ExpectError - filledarrayBy( buf, 8, null, {} ); // $ExpectError - filledarrayBy( buf, 8, undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, [], {} ); // $ExpectError - filledarrayBy( buf, 8, {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 8, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 'float64', false ); // $ExpectError - filledarrayBy( buf, 8, 'float64', true ); // $ExpectError - filledarrayBy( buf, 8, 'float64', null ); // $ExpectError - filledarrayBy( buf, 8, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 8, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 8, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 8, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, '5' ); // $ExpectError - filledarrayBy( buf, 8, 2, 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 2, false ); // $ExpectError - filledarrayBy( buf, 8, 2, true ); // $ExpectError - filledarrayBy( buf, 8, 2, null ); // $ExpectError - filledarrayBy( buf, 8, 2, undefined ); // $ExpectError - filledarrayBy( buf, 8, 2, [] ); // $ExpectError - filledarrayBy( buf, 8, 2, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, false, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, true, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, null, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, [], {} ); // $ExpectError - filledarrayBy( buf, 8, 2, {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', false ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', true ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', null ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', {}, {} ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid length, typed array, array-like object, `ArrayBuffer`, or iterable argument... -{ - filledarrayBy( false, clbk ); // $ExpectError - filledarrayBy( true, clbk ); // $ExpectError - filledarrayBy( null, clbk ); // $ExpectError - filledarrayBy( {}, clbk ); // $ExpectError - - filledarrayBy( false, clbk, {} ); // $ExpectError - filledarrayBy( true, clbk, {} ); // $ExpectError - filledarrayBy( null, clbk, {} ); // $ExpectError - filledarrayBy( {}, clbk, {} ); // $ExpectError - - filledarrayBy( false, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 'float64', clbk ); // $ExpectError - - filledarrayBy( false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, clbk ); // $ExpectError - filledarrayBy( 1.0, 8, clbk ); // $ExpectError - filledarrayBy( false, 8, clbk ); // $ExpectError - filledarrayBy( true, 8, clbk ); // $ExpectError - filledarrayBy( null, 8, clbk ); // $ExpectError - filledarrayBy( undefined, 8, clbk ); // $ExpectError - filledarrayBy( [], 8, clbk ); // $ExpectError - filledarrayBy( {}, 8, clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, clbk ); // $ExpectError - - filledarrayBy( '5', 8, clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, clbk, {} ); // $ExpectError - filledarrayBy( false, 8, clbk, {} ); // $ExpectError - filledarrayBy( true, 8, clbk, {} ); // $ExpectError - filledarrayBy( null, 8, clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, clbk, {} ); // $ExpectError - filledarrayBy( [], 8, clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 'float64', clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( false, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( [], 8, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 'float64', clbk ); // $ExpectError - - filledarrayBy( '5', 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 2, clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 2, clbk ); // $ExpectError - filledarrayBy( false, 8, 2, clbk ); // $ExpectError - filledarrayBy( true, 8, 2, clbk ); // $ExpectError - filledarrayBy( null, 8, 2, clbk ); // $ExpectError - filledarrayBy( undefined, 8, 2, clbk ); // $ExpectError - filledarrayBy( [], 8, 2, clbk ); // $ExpectError - filledarrayBy( {}, 8, 2, clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, clbk ); // $ExpectError - - filledarrayBy( '5', 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( false, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( [], 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, 'float64', clbk ); // $ExpectError - - filledarrayBy( '5', 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a byte offset argument which is not a number... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, false, clbk ); // $ExpectError - filledarrayBy( buf, true, clbk ); // $ExpectError - filledarrayBy( buf, null, clbk ); // $ExpectError - filledarrayBy( buf, [], clbk ); // $ExpectError - filledarrayBy( buf, {}, clbk ); // $ExpectError - - filledarrayBy( buf, false, clbk, {} ); // $ExpectError - filledarrayBy( buf, true, clbk, {} ); // $ExpectError - filledarrayBy( buf, null, clbk, {} ); // $ExpectError - filledarrayBy( buf, [], clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, clbk, {} ); // $ExpectError - - filledarrayBy( buf, '5', 'float64', clbk ); // $ExpectError - filledarrayBy( buf, false, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, true, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, null, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, [], 'float64', clbk ); // $ExpectError - filledarrayBy( buf, {}, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, '5', 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( buf, false, 2, clbk ); // $ExpectError - filledarrayBy( buf, true, 2, clbk ); // $ExpectError - filledarrayBy( buf, null, 2, clbk ); // $ExpectError - filledarrayBy( buf, [], 2, clbk ); // $ExpectError - filledarrayBy( buf, {}, 2, clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, clbk ); // $ExpectError - - filledarrayBy( buf, false, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, clbk, {} ); // $ExpectError - - filledarrayBy( buf, '5', 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, false, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, true, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, null, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, undefined, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, [], 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, {}, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, '5', 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, false, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, undefined, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a view length argument which is not a number... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, 8, false, clbk ); // $ExpectError - filledarrayBy( buf, 8, true, clbk ); // $ExpectError - filledarrayBy( buf, 8, null, clbk ); // $ExpectError - filledarrayBy( buf, 8, [], clbk ); // $ExpectError - filledarrayBy( buf, 8, {}, clbk ); // $ExpectError - - filledarrayBy( buf, 8, false, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, true, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, null, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, [], clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, {}, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, clbk, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5', 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, false, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, true, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, null, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, [], 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, {}, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, 8, '5', 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, [], 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, {}, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided too many arguments... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, 8, 2, 'float64', 1, clbk, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 997a381..0000000 --- a/examples/index.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ).factory; -var dtypes = require( '@stdlib/array-typed-real-dtypes' ); -var filledarrayBy = require( './../lib' ); - -// Create a pseudorandom number generator: -var rand = discreteUniform( 0, 100 ); - -// Get a list of array data types: -var dt = dtypes(); - -// Generate filled arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = filledarrayBy( 10, dt[ i ], rand ); - console.log( arr ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index b1fd829..e1b94a1 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, RealOrComplexTypedArray, DataType } from '@stdlib/types/array'; import { IterableIterator } from '@stdlib/types/iter'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..56b3976 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.1-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-ctors@v0.2.1-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill-by@v0.2.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled-by@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.2.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.1-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@v0.2.1-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.2.1-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";var j=d(),a=p.get("dtypes.default");function v(){var d,p,v,c,g,y,b,u;if(0===(p=arguments.length))return new(g=o(a))(0);if(r(v=arguments[0])){if(p>1)throw new TypeError(w("00h05"));if(null===(g=o(v)))throw new TypeError(w("00h2Y",v));return new g(0)}if(p<2)throw new TypeError(w("00h05"));if(n(arguments[p-=1]))if(n(arguments[p-1])){if(d=arguments[p],c=arguments[p-=1],0===p)throw new TypeError(w("00h05"))}else c=arguments[p];else{if(!(p>=2))throw new TypeError(w("00h05"));if(d=arguments[p],!n(c=arguments[p-=1]))throw new TypeError(w("00h2b",c))}if((p-=1)>=0&&r(arguments[p])?(v=arguments[p],p-=1):v=a,null===(g=o(v)))throw new TypeError(w("00h2Y",v));if("generic"===v){if(u=arguments[0],0===p){if(e(u)?b=u:t(u)&&(b=u.length),void 0!==b)return l(b,c,d);if(s(u))throw new Error(w("00h04"));if(i(u)){if(!1===j)throw new TypeError(w("00h2Z",u));if(!n(u[m]))throw new TypeError(w("00h2a",u));if(u=u[m](),!n(u.next))throw new TypeError(w("00h2a",u));return function(r,e,t){var s,i;for(s=[],i=-1;!r.next().done;)i+=1,s.push(e.call(t,i));return s}(u,c,d)}throw new TypeError(w("00h2a",u))}if(s(u))throw new Error(w("00h04"));throw new TypeError(w("00h2a",u))}if(0===p)if(t(u=arguments[0]))y=new g(u.length);else if(s(u))y=new g(u);else if(e(u))y=new g(u);else{if(!i(u))throw new TypeError(w("00h2a",u));if(!1===j)throw new TypeError(w("00h2Z",u));if(!n(u[m]))throw new TypeError(w("00h2a",u));if(u=u[m](),!n(u.next))throw new TypeError(w("00h2a",u));y=new g(f(u))}else y=1===p?new g(arguments[0],arguments[1]):new g(arguments[0],arguments[1],arguments[2]);return y.length>0&&(/^complex/.test(v)?function(r,e,t){var s;for(s=0;s\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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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( format('00h05') );\n\t\t}\n\t\tctor = ctors( dtype );\n\t\tif ( ctor === null ) {\n\t\t\tthrow new TypeError( format( '00h2Y', 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( format('00h05') );\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( format('00h05') );\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( '00h2b', 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( format('00h05') );\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( '00h2Y', 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( format('00h04') );\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( '00h2Z', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00h2a', 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( '00h2a', 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( '00h2a', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format('00h04') );\n\t\t}\n\t\tthrow new TypeError( format( '00h2a', 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( '00h2Z', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00h2a', 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( '00h2a', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00h2a', 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\nexport default filledarrayBy;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","DEFAULT_DTYPE","defaults","get","filledarrayBy","thisArg","nargs","dtype","clbk","ctor","arr","len","arg","arguments","length","ctors","isString","TypeError","format","isFunction","isNonNegativeInteger","isCollection","filledArray","isArrayBuffer","Error","isObject","ITERATOR_SYMBOL","next","it","i","done","push","call","filledArrayIterator","iterLength","test","set","filledAccessors","gfillBy","value","aidx"],"mappings":";;q0CAwCA,IAAIA,EAAsBC,IACtBC,EAAgBC,EAASC,IAAK,kBA2MlC,SAASC,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAKJ,GAAe,KAHfN,EAAQO,UAAUC,QAKjB,OAAO,IADPL,EAAOM,EAAOd,IACG,GAIlB,GAAKe,EADLT,EAAQM,UAAW,IACM,CAExB,GAAKP,EAAQ,EACZ,MAAM,IAAIW,UAAWC,EAAO,UAG7B,GAAc,QADdT,EAAOM,EAAOR,IAEb,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,OAAO,IAAIE,EAAM,EACjB,CAED,GAAKH,EAAQ,EACZ,MAAM,IAAIW,UAAWC,EAAO,UAM7B,GAAKC,EAAYN,UAHjBP,GAAS,IAKR,GAAKa,EAAYN,UAAWP,EAAM,KAMjC,GALAD,EAAUQ,UAAWP,GAErBE,EAAOK,UADPP,GAAS,GAIM,IAAVA,EACJ,MAAM,IAAIW,UAAWC,EAAO,eAI7BV,EAAOK,UAAWP,OAIf,MAAKA,GAAS,GAUlB,MAAM,IAAIW,UAAWC,EAAO,UAN5B,GAHAb,EAAUQ,UAAWP,IAGfa,EADNX,EAAOK,UADPP,GAAS,IAGR,MAAM,IAAIW,UAAWC,EAAQ,QAASV,GAMvC,CAUD,IARAF,GAAS,IACK,GAAKU,EAAUH,UAAWP,KACvCC,EAAQM,UAAWP,GACnBA,GAAS,GAETC,EAAQN,EAGK,QADdQ,EAAOM,EAAOR,IAEb,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,GAAe,YAAVA,EAAsB,CAE1B,GADAK,EAAMC,UAAW,GACF,IAAVP,EAAc,CAMlB,GALKc,EAAsBR,GAC1BD,EAAMC,EACKS,EAAcT,KACzBD,EAAMC,EAAIE,aAEE,IAARH,EACJ,OAAOW,EAAaX,EAAKH,EAAMH,GAEhC,GAAKkB,EAAeX,GACnB,MAAM,IAAIY,MAAON,EAAO,UAEzB,GAAKO,EAAUb,GAAQ,CACtB,IAA6B,IAAxBb,EACJ,MAAM,IAAIkB,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAYP,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLP,EAAYP,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvC,OAvSJ,SAA8BgB,EAAIpB,EAAMH,GACvC,IAAIK,EACAmB,EAKJ,IAFAnB,EAAM,GACNmB,GAAK,GAEAD,EAAGD,OACAG,MAGPD,GAAK,EACLnB,EAAIqB,KAAMvB,EAAKwB,KAAM3B,EAASwB,IAE/B,OAAOnB,CACR,CAuRWuB,CAAqBrB,EAAKJ,EAAMH,EACvC,CACD,MAAM,IAAIY,UAAWC,EAAQ,QAASN,GACzC,CAAS,GAAKW,EAAeX,GAC1B,MAAM,IAAIY,MAAON,EAAO,UAEzB,MAAM,IAAID,UAAWC,EAAQ,QAASN,GACtC,CACD,GAAe,IAAVN,EAEJ,GAAKe,EADLT,EAAMC,UAAW,IAEhBH,EAAM,IAAID,EAAMG,EAAIE,aACd,GAAKS,EAAeX,GAC1BF,EAAM,IAAID,EAAMG,QACV,GAAKQ,EAAsBR,GACjCF,EAAM,IAAID,EAAMG,OACV,KAAKa,EAAUb,GAarB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAZtC,IAA6B,IAAxBb,EACJ,MAAM,IAAIkB,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAYP,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLP,EAAYP,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvCF,EAAM,IAAID,EAAMyB,EAAYtB,GAG5B,MAEDF,EADqB,IAAVJ,EACL,IAAIG,EAAMI,UAAU,GAAIA,UAAU,IAElC,IAAIJ,EAAMI,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKH,EAAII,OAAS,IACZ,WAAWqB,KAAM5B,GAjTxB,SAA0BG,EAAKF,EAAMH,GACpC,IAAIwB,EACJ,IAAMA,EAAI,EAAGA,EAAInB,EAAII,OAAQe,IAC5BnB,EAAI0B,IAAK5B,EAAKwB,KAAM3B,EAASwB,GAAKA,EAGpC,CA4SGQ,CAAiB3B,EAAKF,EAAMH,GAE5BiC,EAAS5B,EAAII,OAAQJ,EAAK,GAe5B,SAAmB6B,EAAOC,GACzB,OAAOhC,EAAKwB,KAAM3B,EAASmC,EAC3B,KAdM9B,CAeR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d115cf0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,192 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -/** -* Create a filled array according to a provided callback function. -* -* @module @stdlib/array-filled-by -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* var arr = filledarrayBy(); -* // returns -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'generic', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( [ 0.5, 0.5 ], clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1; -* } -* -* var arr = filledarrayBy( [ 5, -3 ], 'int32', clbk ); -* // returns [ 1, 1 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk1() { -* return 10; -* } -* -* function clbk2() { -* return 1.0; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, clbk2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk1() { -* return 1.0; -* } -* -* function clbk2() { -* return 2; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, 'uint32', clbk2 ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 'float32', clbk ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, clbk ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, 'int32', clbk ); -* // returns [ 1, 1 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 06bc8b6..0000000 --- a/lib/main.js +++ /dev/null @@ -1,414 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var isCollection = require( '@stdlib/assert-is-collection' ); -var isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isObject = require( '@stdlib/assert-is-object' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var ctors = require( '@stdlib/array-ctors' ); -var gfillBy = require( '@stdlib/blas-ext-base-gfill-by' ); -var filledArray = require( '@stdlib/array-base-filled-by' ); -var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var iterLength = require( '@stdlib/iter-length' ); -var defaults = require( '@stdlib/array-defaults' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport(); -var DEFAULT_DTYPE = defaults.get( 'dtypes.default' ); - - -// FUNCTIONS // - -/** -* Creates a filled "generic" array from an iterator. -* -* @private -* @param {Iterable} it - iterator -* @param {Callback} clbk - callback function -* @param {*} thisArg - callback function execution context -* @returns {Array} filled array -*/ -function filledArrayIterator( it, clbk, thisArg ) { - var arr; - var i; - var v; - - arr = []; - i = -1; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - i += 1; - arr.push( clbk.call( thisArg, i ) ); - } - return arr; -} - -/** -* Fills an array exposing accessors for getting and setting array elements. -* -* @private -* @param {Collection} arr - input array -* @param {Callback} clbk - callback function -* @param {*} thisArg - callback function execution context -* @returns {Collection} input array -*/ -function filledAccessors( arr, clbk, thisArg ) { - var i; - for ( i = 0; i < arr.length; i++ ) { - arr.set( clbk.call( thisArg, i ), i ); - } - return arr; -} - - -// MAIN // - -/** -* Creates a filled array according to a provided callback function. -* -* @param {(NonNegativeInteger|TypedArray|ArrayLikeObject|ArrayBuffer|Iterable)} [arg] - a length, typed array, array-like object, buffer, or iterable -* @param {NonNegativeInteger} [byteOffset=0] - byte offset -* @param {NonNegativeInteger} [length] - view length -* @param {string} [dtype="float64"] - data type -* @param {Callback} [clbk] - callback to invoke -* @param {*} [thisArg] - callback execution context -* @throws {TypeError} must provide a recognized data type -* @throws {TypeError} must provide a length, typed array, array-like object, buffer, or iterable -* @throws {TypeError} callback argument must be a function. -* @throws {Error} creating a generic array from an `ArrayBuffer` is not supported -* @returns {(TypedArray|Array)} array or typed array -* -* @example -* var arr = filledarrayBy(); -* // returns -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'generic', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( [ 0.5, 0.5 ], clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1; -* } -* -* var arr = filledarrayBy( [ 5, -3 ], 'int32', clbk ); -* // returns [ 1, 1 ] -* -* @example -* function clbk1() { -* return 10; -* } -* -* function clbk2() { -* return 1.0; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, clbk2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk1() { -* return 1.0; -* } -* -* function clbk2() { -* return 2; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, 'uint32', clbk2 ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 'float32', clbk ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, clbk ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, 'int32', clbk ); -* // returns [ 1, 1 ] -*/ -function filledarrayBy() { - var thisArg; - var nargs; - var dtype; - var clbk; - var ctor; - var arr; - var len; - var arg; - - nargs = arguments.length; - - // If we weren't provided any arguments, return an empty array... - if ( nargs === 0 ) { - ctor = ctors( DEFAULT_DTYPE ); - return new ctor( 0 ); - } - // Check if we were provided a dtype as the first argument... - dtype = arguments[ 0 ]; - if ( isString( dtype ) ) { - // Invoking this function with arguments `f( dtype, clbk[, thisArg] )` is not allowed (otherwise, we'd need to also allow `f( clbk[, thisArg] )`)... - if ( nargs > 1 ) { - throw new TypeError( format('00h05') ); - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '00h2Y', dtype ) ); - } - // Return an empty array having the specified dtype: - return new ctor( 0 ); - } - // For all other supported invocations, we need at least two arguments... - if ( nargs < 2 ) { - throw new TypeError( format('00h05') ); - } - // At this point, we need to do some argument juggling... - nargs -= 1; // henceforth, the number of available arguments is `nargs+1` - - // Determine whether the last argument is a callback or "this" context... - if ( isFunction( arguments[ nargs ] ) ) { - // 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... - if ( isFunction( arguments[ nargs-1 ] ) ) { - thisArg = arguments[ nargs ]; - nargs -= 1; - clbk = arguments[ nargs ]; - - // Check if we were provided only a callback and a "this" context.. - if ( nargs === 0 ) { - throw new TypeError( format('00h05') ); - } - } else { - // "this" context is left undefined... - clbk = arguments[ nargs ]; - } - } - // 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... - else if ( nargs >= 2 ) { - thisArg = arguments[ nargs ]; - nargs -= 1; - clbk = arguments[ nargs ]; - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '00h2b', clbk ) ); - } - } - // If were were only provided 2 arguments and the last argument was not a function, we've been provided an insufficient number of arguments... - else { - throw new TypeError( format('00h05') ); - } - // Now that we've processed the callback arguments, let's continue working backward to see if we've been provided a `dtype` argument... - nargs -= 1; - if ( nargs >= 0 && isString( arguments[ nargs ] ) ) { - dtype = arguments[ nargs ]; - nargs -= 1; - } else { - dtype = DEFAULT_DTYPE; - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '00h2Y', dtype ) ); - } - // At this point, we've resolved the output array data type, and now we can actually create the output array... - if ( dtype === 'generic' ) { - arg = arguments[ 0 ]; - if ( nargs === 0 ) { - if ( isNonNegativeInteger( arg ) ) { - len = arg; - } else if ( isCollection( arg ) ) { - len = arg.length; - } - if ( len !== void 0 ) { - return filledArray( len, clbk, thisArg ); - } - if ( isArrayBuffer( arg ) ) { - throw new Error( format('00h04') ); - } - if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( '00h2Z', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00h2a', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00h2a', arg ) ); - } - return filledArrayIterator( arg, clbk, thisArg ); - } - throw new TypeError( format( '00h2a', arg ) ); - } else if ( isArrayBuffer( arg ) ) { - throw new Error( format('00h04') ); - } - throw new TypeError( format( '00h2a', arg ) ); - } - if ( nargs === 0 ) { // length || array-like || ArrayBuffer || iterable - arg = arguments[ 0 ]; - if ( isCollection( arg ) ) { - arr = new ctor( arg.length ); - } else if ( isArrayBuffer( arg ) ) { - arr = new ctor( arg ); - } else if ( isNonNegativeInteger( arg ) ) { - arr = new ctor( arg ); - } else if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( '00h2Z', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00h2a', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00h2a', arg ) ); - } - arr = new ctor( iterLength( arg ) ); - } else { - throw new TypeError( format( '00h2a', arg ) ); - } - } else if ( nargs === 1 ) { - arr = new ctor( arguments[0], arguments[1] ); // (ArrayBuffer, byteOffset) - } else { - arr = new ctor( arguments[0], arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset, length) - } - if ( arr.length > 0 ) { - if ( /^complex/.test( dtype ) ) { - filledAccessors( arr, clbk, thisArg ); - } else { - gfillBy( arr.length, arr, 1, callback ); - } - } - return arr; - - /** - * Callback which wraps a provided callback and is invoked for each array element. - * - * @private - * @param {*} value - element value - * @param {NonNegativeInteger} aidx - array index - * @param {NonNegativeInteger} sidx - strided index - * @param {Collection} array - input array/collection - * @returns {*} callback return value - */ - function callback( value, aidx ) { - return clbk.call( thisArg, aidx ); - } -} - - -// EXPORTS // - -module.exports = filledarrayBy; diff --git a/package.json b/package.json index fe41e9b..b16be36 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Create a filled array according to a provided callback function.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,71 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-filled-by": "^0.2.1", - "@stdlib/array-ctors": "^0.2.1", - "@stdlib/array-defaults": "^0.2.1", - "@stdlib/assert-has-iterator-symbol-support": "^0.2.1", - "@stdlib/assert-is-arraybuffer": "^0.2.1", - "@stdlib/assert-is-collection": "^0.2.1", - "@stdlib/assert-is-function": "^0.2.1", - "@stdlib/assert-is-nonnegative-integer": "^0.2.1", - "@stdlib/assert-is-object": "^0.2.1", - "@stdlib/assert-is-string": "^0.2.1", - "@stdlib/blas-ext-base-gfill-by": "^0.2.1", - "@stdlib/iter-length": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1", - "@stdlib/symbol-iterator": "^0.2.1", - "@stdlib/types": "^0.3.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/array-buffer": "^0.2.1", - "@stdlib/array-complex128": "^0.2.1", - "@stdlib/array-complex64": "^0.2.1", - "@stdlib/array-float32": "^0.2.1", - "@stdlib/array-float64": "^0.2.1", - "@stdlib/array-int16": "^0.2.1", - "@stdlib/array-int32": "^0.2.1", - "@stdlib/array-int8": "^0.2.1", - "@stdlib/array-typed-real-dtypes": "^0.2.1", - "@stdlib/array-uint16": "^0.2.1", - "@stdlib/array-uint32": "^0.2.1", - "@stdlib/array-uint8": "^0.2.1", - "@stdlib/array-uint8c": "^0.2.1", - "@stdlib/assert-instance-of": "^0.2.1", - "@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": "^0.2.1", - "@stdlib/complex-float64": "^0.2.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-complex128": "^0.2.1", - "@stdlib/strided-base-reinterpret-complex64": "^0.2.0", - "@stdlib/utils-constant-function": "^0.2.1", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.1" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..0fbbd35 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index b55aa4a..0000000 --- a/test/test.js +++ /dev/null @@ -1,4248 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 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. -*/ - -/* eslint-disable max-len */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -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 ArrayBuffer = require( '@stdlib/array-buffer' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var iterConstant = require( '@stdlib/iter-constant' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var filledarrayBy = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': !hasIteratorSymbolSupport() -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof filledarrayBy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if only provided callback arguments', function test( t ) { - t.throws( clbk1, TypeError, 'throws an error' ); - t.throws( clbk2, TypeError, 'throws an error' ); - t.throws( clbk3, TypeError, 'throws an error' ); - t.end(); - - function clbk1() { - filledarrayBy( constantFunction( 1.0 ) ); - } - - function clbk2() { - filledarrayBy( constantFunction( 1.0 ), {} ); - } - - function clbk3() { - filledarrayBy( constantFunction( 1.0 ), constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (only argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (typed array; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (array-like object)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (array-like object; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 8 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 8 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, 1, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (iterator)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( iterConstant( 1.0 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (iterator; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( iterConstant( 1.0 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if only provided data type and callback arguments', function test( t ) { - t.throws( clbk1, TypeError, 'throws an error' ); - t.throws( clbk2, TypeError, 'throws an error' ); - t.throws( clbk3, TypeError, 'throws an error' ); - t.end(); - - function clbk1() { - filledarrayBy( 'float64', constantFunction( 1.0 ) ); - } - - function clbk2() { - filledarrayBy( 'float64', constantFunction( 1.0 ), {} ); - } - - function clbk3() { - filledarrayBy( 'float64', constantFunction( 1.0 ), constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (array-like object)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (array-like object; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, 1, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, 1, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (no iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (no iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (non-function iterator symbol property)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (non-function iterator symbol property; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (`next` property is not a function)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ) ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (`next` property is not a function; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ), {} ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (no iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (no iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (non-function iterator symbol property)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (non-function iterator symbol property; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (`next` property is not a function)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ) ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (`next` property is not a function; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ), {} ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 1, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 1, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function returns a filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - arr = filledarrayBy(); - - t.strictEqual( instanceOf( arr, Float64Array ), 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=float64)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - arr = filledarrayBy( 'float64' ); - - t.strictEqual( instanceOf( arr, Float64Array ), 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=float32)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( 0 ); - arr = filledarrayBy( 'float32' ); - - t.strictEqual( instanceOf( arr, Float32Array ), 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; - - expected = new Complex128Array( 0 ); - arr = filledarrayBy( 'complex128' ); - - t.strictEqual( instanceOf( arr, Complex128Array ), 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=complex64)', function test( t ) { - var expected; - var arr; - - expected = new Complex64Array( 0 ); - arr = filledarrayBy( 'complex64' ); - - t.strictEqual( instanceOf( arr, Complex64Array ), 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=int32)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( 0 ); - arr = filledarrayBy( 'int32' ); - - t.strictEqual( instanceOf( arr, Int32Array ), 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=uint32)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( 0 ); - arr = filledarrayBy( 'uint32' ); - - t.strictEqual( instanceOf( arr, Uint32Array ), 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=int16)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( 0 ); - arr = filledarrayBy( 'int16' ); - - t.strictEqual( instanceOf( arr, Int16Array ), 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=uint16)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( 0 ); - arr = filledarrayBy( 'uint16' ); - - t.strictEqual( instanceOf( arr, Uint16Array ), 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=int8)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( 0 ); - arr = filledarrayBy( 'int8' ); - - t.strictEqual( instanceOf( arr, Int8Array ), 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=uint8)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( 0 ); - arr = filledarrayBy( 'uint8' ); - - t.strictEqual( instanceOf( arr, Uint8Array ), 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=uint8c)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( 0 ); - arr = filledarrayBy( 'uint8c' ); - - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), 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=generic)', function test( t ) { - var expected; - var arr; - - expected = []; - arr = filledarrayBy( 'generic' ); - - t.strictEqual( instanceOf( arr, Array ), 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 (default, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, length=0)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array(); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 0, clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, clbk, ctx ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (default, length; thisArg=function)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, clbk, context ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this(); // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } - - function context() { - ctx.count += 1; - } -}); - -tape( 'the function returns a filled array (dtype=float64, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, 'float64', clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, length; thisArg=function)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, 'float64', clbk, context ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this(); // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } - - function context() { - ctx.count += 1; - } -}); - -tape( 'the function returns a filled array (dtype=float32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, 'float32', clbk ); - - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex128, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = filledarrayBy( 5, 'complex128', clbk ); - - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = filledarrayBy( 5, 'complex64', clbk ); - - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int32Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int32', clbk ); - - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint32Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint32', clbk ); - - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int16Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int16', clbk ); - - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint16', clbk ); - - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int8Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int8', clbk ); - - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint8', clbk ); - - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint8c', clbk ); - - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = [ 1, 1, 1, 1, 1 ]; - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'generic', clbk ); - - t.strictEqual( instanceOf( arr, Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex128, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = [ 1.0, 2.0 ]; - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = [ 1.0, 2.0 ]; - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int32', clbk ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, typed array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, typed array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex128, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = new Float64Array( [ 1.0, 2.0 ] ); - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = new Float64Array( [ 1.0, 2.0 ] ); - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (default, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex128, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer, byteoffset; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer, byteoffset; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, 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; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 48 ); - out = filledarrayBy( buf, 16, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 24 ); - out = filledarrayBy( buf, 8, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int32', clbk ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint8c', clbk ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, 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; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 64 ); - out = filledarrayBy( buf, 16, 2, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset, length)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 1, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 1, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled array (default, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, iterator; thisArg)', opts, function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - ctx = { - 'count': 0 - }; - indices = []; - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, iterator; thisArg)', opts, function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - ctx = { - 'count': 0 - }; - indices = []; - out = filledarrayBy( arr, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex128, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = iterConstant( new Complex128( 3.0, 3.0 ), { - 'iter': 2 - }); - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = iterConstant( new Complex64( 3.0, 3.0 ), { - 'iter': 2 - }); - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); From 8b590f74aaa04b5258f28f495d6540fcf4f5e967 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 12 Apr 2024 04:04:03 +0000 Subject: [PATCH 057/117] Transform error messages --- lib/main.js | 38 +++++++++++++++++++------------------- package.json | 2 +- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/lib/main.js b/lib/main.js index 0f134bb..06bc8b6 100644 --- a/lib/main.js +++ b/lib/main.js @@ -33,7 +33,7 @@ var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-supp var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); var iterLength = require( '@stdlib/iter-length' ); var defaults = require( '@stdlib/array-defaults' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -264,18 +264,18 @@ function filledarrayBy() { if ( isString( dtype ) ) { // Invoking this function with arguments `f( dtype, clbk[, thisArg] )` is not allowed (otherwise, we'd need to also allow `f( clbk[, thisArg] )`)... if ( nargs > 1 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format('00h05') ); } ctor = ctors( dtype ); if ( ctor === null ) { - throw new TypeError( format( 'invalid argument. Must provide a recognized data type. Value: `%s`.', dtype ) ); + throw new TypeError( format( '00h2Y', dtype ) ); } // Return an empty array having the specified dtype: return new ctor( 0 ); } // For all other supported invocations, we need at least two arguments... if ( nargs < 2 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format('00h05') ); } // At this point, we need to do some argument juggling... nargs -= 1; // henceforth, the number of available arguments is `nargs+1` @@ -290,7 +290,7 @@ function filledarrayBy() { // Check if we were provided only a callback and a "this" context.. if ( nargs === 0 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format('00h05') ); } } else { // "this" context is left undefined... @@ -303,12 +303,12 @@ function filledarrayBy() { nargs -= 1; clbk = arguments[ nargs ]; if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '00h2b', clbk ) ); } } // If were were only provided 2 arguments and the last argument was not a function, we've been provided an insufficient number of arguments... else { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format('00h05') ); } // Now that we've processed the callback arguments, let's continue working backward to see if we've been provided a `dtype` argument... nargs -= 1; @@ -320,7 +320,7 @@ function filledarrayBy() { } ctor = ctors( dtype ); if ( ctor === null ) { - throw new TypeError( format( 'invalid argument. Must provide a recognized data type. Value: `%s`.', dtype ) ); + throw new TypeError( format( '00h2Y', dtype ) ); } // At this point, we've resolved the output array data type, and now we can actually create the output array... if ( dtype === 'generic' ) { @@ -335,26 +335,26 @@ function filledarrayBy() { return filledArray( len, clbk, thisArg ); } if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format('00h04') ); } if ( isObject( arg ) ) { if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2Z', arg ) ); } if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } arg = arg[ ITERATOR_SYMBOL ](); if ( !isFunction( arg.next ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } return filledArrayIterator( arg, clbk, thisArg ); } - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } else if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format('00h04') ); } - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } if ( nargs === 0 ) { // length || array-like || ArrayBuffer || iterable arg = arguments[ 0 ]; @@ -366,18 +366,18 @@ function filledarrayBy() { arr = new ctor( arg ); } else if ( isObject( arg ) ) { if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2Z', arg ) ); } if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } arg = arg[ ITERATOR_SYMBOL ](); if ( !isFunction( arg.next ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } arr = new ctor( iterLength( arg ) ); } else { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } } else if ( nargs === 1 ) { arr = new ctor( arguments[0], arguments[1] ); // (ArrayBuffer, byteOffset) diff --git a/package.json b/package.json index 8efaed0..fe41e9b 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "@stdlib/assert-is-string": "^0.2.1", "@stdlib/blas-ext-base-gfill-by": "^0.2.1", "@stdlib/iter-length": "^0.2.1", - "@stdlib/string-format": "^0.2.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1", "@stdlib/symbol-iterator": "^0.2.1", "@stdlib/types": "^0.3.2", "@stdlib/error-tools-fmtprodmsg": "^0.2.1" From 12b38251417a8829c87503ad852bc960f52fa4c7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 12 Apr 2024 09:36:07 +0000 Subject: [PATCH 058/117] Remove files --- index.d.ts | 426 ----- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5273 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index e1b94a1..0000000 --- a/index.d.ts +++ /dev/null @@ -1,426 +0,0 @@ -/* -* @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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, RealOrComplexTypedArray, DataType } from '@stdlib/types/array'; -import { IterableIterator } from '@stdlib/types/iter'; - -/** -* Array or typed array. -*/ -type ArrayOrTypedArray = Array | RealOrComplexTypedArray; - -/** -* Nullary callback function. -* -* @returns fill value -*/ -type Nullary = () => any; - -/** -* Unary callback function. -* -* @param i - current array index -* @returns fill value -*/ -type Unary = ( i: number ) => any; - -/** -* Callback function. -* -* @param i - current array index -* @returns fill value -*/ -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 -* -* @example -* var arr = filledarrayBy(); -* // returns -* -* @example -* var arr = filledarrayBy( 'float32' ); -* // returns -*/ -declare function filledarrayBy( dtype?: DataType ): ArrayOrTypedArray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Creates a filled array according to a provided callback function and having a specified `length`. -* -* @param length - array length -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* -* var arr = filledarrayBy( 5, constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( length: number, clbk: Callback, thisArg?: any ): ArrayOrTypedArray; - -/** -* 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 -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* -* var arr = filledarrayBy( 5, 'float64', constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( length: number, dtype: DataType, clbk: Callback, thisArg?: any ): ArrayOrTypedArray; - -/** -* Creates a filled array from another `array` according to a provided callback function. -* -* @param array - typed array or array-like object -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* -* 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; - -/** -* 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 -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* -* 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; - -/** -* Creates a filled array from an iterable according to a callback function. -* -* @param iterable - iterable -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var iterConstant = require( '@stdlib/iter-constant' ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarrayBy( it, constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( iterable: IterableIterator, callback: Callback, thisArg?: any ): ArrayOrTypedArray; - -/** -* 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 -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var iterConstant = require( '@stdlib/iter-constant' ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* 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; - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; - -/** -* 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. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; - -/** -* 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. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; - -/** -* 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. -* -* @param buffer - `ArrayBuffer` -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; - - -// EXPORTS // - -export = filledarrayBy; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 56b3976..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.1-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-ctors@v0.2.1-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill-by@v0.2.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled-by@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.2.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.1-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@v0.2.1-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.2.1-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";var j=d(),a=p.get("dtypes.default");function v(){var d,p,v,c,g,y,b,u;if(0===(p=arguments.length))return new(g=o(a))(0);if(r(v=arguments[0])){if(p>1)throw new TypeError(w("00h05"));if(null===(g=o(v)))throw new TypeError(w("00h2Y",v));return new g(0)}if(p<2)throw new TypeError(w("00h05"));if(n(arguments[p-=1]))if(n(arguments[p-1])){if(d=arguments[p],c=arguments[p-=1],0===p)throw new TypeError(w("00h05"))}else c=arguments[p];else{if(!(p>=2))throw new TypeError(w("00h05"));if(d=arguments[p],!n(c=arguments[p-=1]))throw new TypeError(w("00h2b",c))}if((p-=1)>=0&&r(arguments[p])?(v=arguments[p],p-=1):v=a,null===(g=o(v)))throw new TypeError(w("00h2Y",v));if("generic"===v){if(u=arguments[0],0===p){if(e(u)?b=u:t(u)&&(b=u.length),void 0!==b)return l(b,c,d);if(s(u))throw new Error(w("00h04"));if(i(u)){if(!1===j)throw new TypeError(w("00h2Z",u));if(!n(u[m]))throw new TypeError(w("00h2a",u));if(u=u[m](),!n(u.next))throw new TypeError(w("00h2a",u));return function(r,e,t){var s,i;for(s=[],i=-1;!r.next().done;)i+=1,s.push(e.call(t,i));return s}(u,c,d)}throw new TypeError(w("00h2a",u))}if(s(u))throw new Error(w("00h04"));throw new TypeError(w("00h2a",u))}if(0===p)if(t(u=arguments[0]))y=new g(u.length);else if(s(u))y=new g(u);else if(e(u))y=new g(u);else{if(!i(u))throw new TypeError(w("00h2a",u));if(!1===j)throw new TypeError(w("00h2Z",u));if(!n(u[m]))throw new TypeError(w("00h2a",u));if(u=u[m](),!n(u.next))throw new TypeError(w("00h2a",u));y=new g(f(u))}else y=1===p?new g(arguments[0],arguments[1]):new g(arguments[0],arguments[1],arguments[2]);return y.length>0&&(/^complex/.test(v)?function(r,e,t){var s;for(s=0;s\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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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( format('00h05') );\n\t\t}\n\t\tctor = ctors( dtype );\n\t\tif ( ctor === null ) {\n\t\t\tthrow new TypeError( format( '00h2Y', 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( format('00h05') );\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( format('00h05') );\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( '00h2b', 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( format('00h05') );\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( '00h2Y', 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( format('00h04') );\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( '00h2Z', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00h2a', 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( '00h2a', 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( '00h2a', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format('00h04') );\n\t\t}\n\t\tthrow new TypeError( format( '00h2a', 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( '00h2Z', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00h2a', 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( '00h2a', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00h2a', 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\nexport default filledarrayBy;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","DEFAULT_DTYPE","defaults","get","filledarrayBy","thisArg","nargs","dtype","clbk","ctor","arr","len","arg","arguments","length","ctors","isString","TypeError","format","isFunction","isNonNegativeInteger","isCollection","filledArray","isArrayBuffer","Error","isObject","ITERATOR_SYMBOL","next","it","i","done","push","call","filledArrayIterator","iterLength","test","set","filledAccessors","gfillBy","value","aidx"],"mappings":";;q0CAwCA,IAAIA,EAAsBC,IACtBC,EAAgBC,EAASC,IAAK,kBA2MlC,SAASC,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAKJ,GAAe,KAHfN,EAAQO,UAAUC,QAKjB,OAAO,IADPL,EAAOM,EAAOd,IACG,GAIlB,GAAKe,EADLT,EAAQM,UAAW,IACM,CAExB,GAAKP,EAAQ,EACZ,MAAM,IAAIW,UAAWC,EAAO,UAG7B,GAAc,QADdT,EAAOM,EAAOR,IAEb,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,OAAO,IAAIE,EAAM,EACjB,CAED,GAAKH,EAAQ,EACZ,MAAM,IAAIW,UAAWC,EAAO,UAM7B,GAAKC,EAAYN,UAHjBP,GAAS,IAKR,GAAKa,EAAYN,UAAWP,EAAM,KAMjC,GALAD,EAAUQ,UAAWP,GAErBE,EAAOK,UADPP,GAAS,GAIM,IAAVA,EACJ,MAAM,IAAIW,UAAWC,EAAO,eAI7BV,EAAOK,UAAWP,OAIf,MAAKA,GAAS,GAUlB,MAAM,IAAIW,UAAWC,EAAO,UAN5B,GAHAb,EAAUQ,UAAWP,IAGfa,EADNX,EAAOK,UADPP,GAAS,IAGR,MAAM,IAAIW,UAAWC,EAAQ,QAASV,GAMvC,CAUD,IARAF,GAAS,IACK,GAAKU,EAAUH,UAAWP,KACvCC,EAAQM,UAAWP,GACnBA,GAAS,GAETC,EAAQN,EAGK,QADdQ,EAAOM,EAAOR,IAEb,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,GAAe,YAAVA,EAAsB,CAE1B,GADAK,EAAMC,UAAW,GACF,IAAVP,EAAc,CAMlB,GALKc,EAAsBR,GAC1BD,EAAMC,EACKS,EAAcT,KACzBD,EAAMC,EAAIE,aAEE,IAARH,EACJ,OAAOW,EAAaX,EAAKH,EAAMH,GAEhC,GAAKkB,EAAeX,GACnB,MAAM,IAAIY,MAAON,EAAO,UAEzB,GAAKO,EAAUb,GAAQ,CACtB,IAA6B,IAAxBb,EACJ,MAAM,IAAIkB,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAYP,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLP,EAAYP,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvC,OAvSJ,SAA8BgB,EAAIpB,EAAMH,GACvC,IAAIK,EACAmB,EAKJ,IAFAnB,EAAM,GACNmB,GAAK,GAEAD,EAAGD,OACAG,MAGPD,GAAK,EACLnB,EAAIqB,KAAMvB,EAAKwB,KAAM3B,EAASwB,IAE/B,OAAOnB,CACR,CAuRWuB,CAAqBrB,EAAKJ,EAAMH,EACvC,CACD,MAAM,IAAIY,UAAWC,EAAQ,QAASN,GACzC,CAAS,GAAKW,EAAeX,GAC1B,MAAM,IAAIY,MAAON,EAAO,UAEzB,MAAM,IAAID,UAAWC,EAAQ,QAASN,GACtC,CACD,GAAe,IAAVN,EAEJ,GAAKe,EADLT,EAAMC,UAAW,IAEhBH,EAAM,IAAID,EAAMG,EAAIE,aACd,GAAKS,EAAeX,GAC1BF,EAAM,IAAID,EAAMG,QACV,GAAKQ,EAAsBR,GACjCF,EAAM,IAAID,EAAMG,OACV,KAAKa,EAAUb,GAarB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAZtC,IAA6B,IAAxBb,EACJ,MAAM,IAAIkB,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAYP,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLP,EAAYP,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvCF,EAAM,IAAID,EAAMyB,EAAYtB,GAG5B,MAEDF,EADqB,IAAVJ,EACL,IAAIG,EAAMI,UAAU,GAAIA,UAAU,IAElC,IAAIJ,EAAMI,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKH,EAAII,OAAS,IACZ,WAAWqB,KAAM5B,GAjTxB,SAA0BG,EAAKF,EAAMH,GACpC,IAAIwB,EACJ,IAAMA,EAAI,EAAGA,EAAInB,EAAII,OAAQe,IAC5BnB,EAAI0B,IAAK5B,EAAKwB,KAAM3B,EAASwB,GAAKA,EAGpC,CA4SGQ,CAAiB3B,EAAKF,EAAMH,GAE5BiC,EAAS5B,EAAII,OAAQJ,EAAK,GAe5B,SAAmB6B,EAAOC,GACzB,OAAOhC,EAAKwB,KAAM3B,EAASmC,EAC3B,KAdM9B,CAeR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 0fbbd35..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 5c96f45641f4f4e7efb8e2a81259f40587d367ae Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 12 Apr 2024 09:36:24 +0000 Subject: [PATCH 059/117] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 ---- .github/workflows/publish.yml | 249 -- .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 134 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 47 +- SECURITY.md | 5 - benchmark/benchmark.js | 319 -- benchmark/benchmark.length.complex128.js | 98 - benchmark/benchmark.length.complex64.js | 98 - benchmark/benchmark.length.float32.js | 97 - benchmark/benchmark.length.float64.js | 97 - benchmark/benchmark.length.generic.js | 97 - benchmark/benchmark.length.int16.js | 97 - benchmark/benchmark.length.int32.js | 97 - benchmark/benchmark.length.int8.js | 97 - benchmark/benchmark.length.uint16.js | 97 - benchmark/benchmark.length.uint32.js | 97 - benchmark/benchmark.length.uint8.js | 97 - benchmark/benchmark.length.uint8c.js | 97 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 174 - docs/types/test.ts | 606 --- examples/index.js | 37 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 192 - lib/main.js | 414 -- package.json | 92 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 4248 ------------------ 54 files changed, 4869 insertions(+), 10551 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.length.complex128.js delete mode 100644 benchmark/benchmark.length.complex64.js delete mode 100644 benchmark/benchmark.length.float32.js delete mode 100644 benchmark/benchmark.length.float64.js delete mode 100644 benchmark/benchmark.length.generic.js delete mode 100644 benchmark/benchmark.length.int16.js delete mode 100644 benchmark/benchmark.length.int32.js delete mode 100644 benchmark/benchmark.length.int8.js delete mode 100644 benchmark/benchmark.length.uint16.js delete mode 100644 benchmark/benchmark.length.uint32.js delete mode 100644 benchmark/benchmark.length.uint8.js delete mode 100644 benchmark/benchmark.length.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 8be0b82..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index f988046..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index b2c1f9c..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '42 6 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index ec90164..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -293,7 +284,7 @@ for ( i = 0; i < dt.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -364,9 +355,9 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/filled]: https://github.com/stdlib-js/array-filled +[@stdlib/array/filled]: https://github.com/stdlib-js/array-filled/tree/esm -[@stdlib/array/typed]: https://github.com/stdlib-js/array-typed +[@stdlib/array/typed]: https://github.com/stdlib-js/array-typed/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 67ba493..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,319 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); -var isArray = require( '@stdlib/assert-is-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var pkg = require( './../package.json' ).name; -var filledarrayBy = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 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=float64', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'float64', 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=float32', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'float32', 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; - var i; - - clbk = constantFunction( new Complex128( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'complex128', 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=complex64', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( new Complex64( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'complex64', 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=int32', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int32', 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=uint32', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint32', 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=int16', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int16', 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=uint16', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint16', 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=int8', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int8', 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=uint8', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint8', 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=uint8c', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint8c', 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=generic', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'generic', clbk ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.length.complex128.js b/benchmark/benchmark.length.complex128.js deleted file mode 100644 index 27f6c66..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 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 Complex128 = require( '@stdlib/complex-float64' ); -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( new Complex128( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'complex128', 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=complex128,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.complex64.js b/benchmark/benchmark.length.complex64.js deleted file mode 100644 index c094ae9..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 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 Complex64 = require( '@stdlib/complex-float32' ); -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( new Complex64( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'complex64', 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=complex64,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.float32.js b/benchmark/benchmark.length.float32.js deleted file mode 100644 index d2b2ba7..0000000 --- a/benchmark/benchmark.length.float32.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'float32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=float32,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.float64.js b/benchmark/benchmark.length.float64.js deleted file mode 100644 index 65064e3..0000000 --- a/benchmark/benchmark.length.float64.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'float64', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=float64,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.generic.js b/benchmark/benchmark.length.generic.js deleted file mode 100644 index eb87dfa..0000000 --- a/benchmark/benchmark.length.generic.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isArray = require( '@stdlib/assert-is-array' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'generic', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isArray( 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=generic,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int16.js b/benchmark/benchmark.length.int16.js deleted file mode 100644 index 914ff7c..0000000 --- a/benchmark/benchmark.length.int16.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int16', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=int16,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int32.js b/benchmark/benchmark.length.int32.js deleted file mode 100644 index cc0f678..0000000 --- a/benchmark/benchmark.length.int32.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=int32,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int8.js b/benchmark/benchmark.length.int8.js deleted file mode 100644 index 77553b0..0000000 --- a/benchmark/benchmark.length.int8.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int8', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=int8,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint16.js b/benchmark/benchmark.length.uint16.js deleted file mode 100644 index c68efdd..0000000 --- a/benchmark/benchmark.length.uint16.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint16', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint16,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint32.js b/benchmark/benchmark.length.uint32.js deleted file mode 100644 index 27c1742..0000000 --- a/benchmark/benchmark.length.uint32.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint32,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint8.js b/benchmark/benchmark.length.uint8.js deleted file mode 100644 index 2a26be4..0000000 --- a/benchmark/benchmark.length.uint8.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint8', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint8,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint8c.js b/benchmark/benchmark.length.uint8c.js deleted file mode 100644 index dd6e8c2..0000000 --- a/benchmark/benchmark.length.uint8c.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint8c', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint8c,len='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index c138144..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by" -%% click B href "https://github.com/stdlib-js/array-filled-by/tree/main" -%% click C href "https://github.com/stdlib-js/array-filled-by/tree/production" -%% click D href "https://github.com/stdlib-js/array-filled-by/tree/esm" -%% click E href "https://github.com/stdlib-js/array-filled-by/tree/deno" -%% click F href "https://github.com/stdlib-js/array-filled-by/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by -[production-url]: https://github.com/stdlib-js/array-filled-by/tree/production -[deno-url]: https://github.com/stdlib-js/array-filled-by/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-filled-by/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-filled-by/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-filled-by/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-filled-by/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-filled-by/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 188fc9b..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import filledarrayBy from '../docs/types/index'; -export = filledarrayBy; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 468e99c..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"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 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 00888a2..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "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,EAAQ,UAAU,OAGbA,IAAU,EACd,OAAAE,EAAOrB,EAAOS,CAAc,EACrB,IAAIY,EAAM,CAAE,EAIpB,GADAD,EAAQ,UAAW,CAAE,EAChB1B,EAAU0B,CAAM,EAAI,CAExB,GAAKD,EAAQ,EACZ,MAAM,IAAI,UAAW,2FAA4F,EAGlH,GADAE,EAAOrB,EAAOoB,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWd,EAAQ,sEAAuEa,CAAM,CAAE,EAG7G,OAAO,IAAIC,EAAM,CAAE,CACpB,CAEA,GAAKF,EAAQ,EACZ,MAAM,IAAI,UAAW,2FAA4F,EAMlH,GAHAA,GAAS,EAGJpB,EAAY,UAAWoB,CAAM,CAAE,EAEnC,GAAKpB,EAAY,UAAWoB,EAAM,CAAE,CAAE,GAMrC,GALAN,EAAU,UAAWM,CAAM,EAC3BA,GAAS,EACTP,EAAO,UAAWO,CAAM,EAGnBA,IAAU,EACd,MAAM,IAAI,UAAW,2FAA4F,OAIlHP,EAAO,UAAWO,CAAM,UAIhBA,GAAS,GAIlB,GAHAN,EAAU,UAAWM,CAAM,EAC3BA,GAAS,EACTP,EAAO,UAAWO,CAAM,EACnB,CAACpB,EAAYa,CAAK,EACtB,MAAM,IAAI,UAAWL,EAAQ,uEAAwEK,CAAK,CAAE,MAK7G,OAAM,IAAI,UAAW,2FAA4F,EAWlH,GARAO,GAAS,EACJA,GAAS,GAAKzB,EAAU,UAAWyB,CAAM,CAAE,GAC/CC,EAAQ,UAAWD,CAAM,EACzBA,GAAS,GAETC,EAAQX,EAETY,EAAOrB,EAAOoB,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWd,EAAQ,sEAAuEa,CAAM,CAAE,EAG7G,GAAKA,IAAU,UAAY,CAE1B,GADAG,EAAM,UAAW,CAAE,EACdJ,IAAU,EAAI,CAMlB,GALKxB,EAAsB4B,CAAI,EAC9BD,EAAMC,EACK3B,EAAc2B,CAAI,IAC7BD,EAAMC,EAAI,QAEND,IAAQ,OACZ,OAAOpB,EAAaoB,EAAKV,EAAMC,CAAQ,EAExC,GAAKhB,EAAe0B,CAAI,EACvB,MAAM,IAAI,MAAO,mFAAoF,EAEtG,GAAKzB,EAAUyB,CAAI,EAAI,CACtB,GAAKf,IAAwB,GAC5B,MAAM,IAAI,UAAWD,EAAQ,sIAAuIgB,CAAI,CAAE,EAE3K,GAAK,CAACxB,EAAYwB,EAAKnB,CAAgB,CAAE,EACxC,MAAM,IAAI,UAAWG,EAAQ,wGAAyGgB,CAAI,CAAE,EAG7I,GADAA,EAAMA,EAAKnB,CAAgB,EAAE,EACxB,CAACL,EAAYwB,EAAI,IAAK,EAC1B,MAAM,IAAI,UAAWhB,EAAQ,wGAAyGgB,CAAI,CAAE,EAE7I,OAAOb,EAAqBa,EAAKX,EAAMC,CAAQ,CAChD,CACA,MAAM,IAAI,UAAWN,EAAQ,wGAAyGgB,CAAI,CAAE,CAC7I,SAAY1B,EAAe0B,CAAI,EAC9B,MAAM,IAAI,MAAO,mFAAoF,EAEtG,MAAM,IAAI,UAAWhB,EAAQ,wGAAyGgB,CAAI,CAAE,CAC7I,CACA,GAAKJ,IAAU,EAEd,GADAI,EAAM,UAAW,CAAE,EACd3B,EAAc2B,CAAI,EACtBT,EAAM,IAAIO,EAAME,EAAI,MAAO,UAChB1B,EAAe0B,CAAI,EAC9BT,EAAM,IAAIO,EAAME,CAAI,UACT5B,EAAsB4B,CAAI,EACrCT,EAAM,IAAIO,EAAME,CAAI,UACTzB,EAAUyB,CAAI,EAAI,CAC7B,GAAKf,IAAwB,GAC5B,MAAM,IAAI,UAAWD,EAAQ,sIAAuIgB,CAAI,CAAE,EAE3K,GAAK,CAACxB,EAAYwB,EAAKnB,CAAgB,CAAE,EACxC,MAAM,IAAI,UAAWG,EAAQ,wGAAyGgB,CAAI,CAAE,EAG7I,GADAA,EAAMA,EAAKnB,CAAgB,EAAE,EACxB,CAACL,EAAYwB,EAAI,IAAK,EAC1B,MAAM,IAAI,UAAWhB,EAAQ,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"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 5a68984..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,174 +0,0 @@ - -{{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) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr = {{alias}}() - - > arr = {{alias}}( 'float32' ) - - - -{{alias}}( length[, dtype], clbk[, thisArg] ) - Returns a filled array according to a provided callback function and having - a specified length. - - Parameters - ---------- - length: integer - Array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > function clbk() { return 1.0; }; - > var arr = {{alias}}( 5, clbk ) - [ 1.0, 1.0, 1.0, 1.0, 1.0 ] - > arr = {{alias}}( 5, 'int32', clbk ) - [ 1, 1, 1, 1, 1 ] - - -{{alias}}( array[, dtype], clbk[, thisArg] ) - Creates a filled array from another array (or array-like object) according - to a provided callback function. - - Parameters - ---------- - array: ArrayLikeObject - Array from which to generate another array. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias}}( [ 0.5, 0.5, 0.5 ], {{alias:@stdlib/utils/constant-function}}( 2.0 ) ) - [ 2.0, 2.0, 2.0 ] - > var arr2 = {{alias}}( arr1, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( iterable[, dtype], clbk[, thisArg] ) - Creates a filled array from an iterable according to a provided callback - function. - - Parameters - ---------- - iterable: Iterable - Iterable from which to generate an array. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias:@stdlib/iter/constant}}( 3.0, {'iter': 3} ); - > var arr2 = {{alias}}( arr1, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( buffer[, byteOffset[, length]][, dtype], clbk[, thisArg] ) - Returns a filled typed array view of an ArrayBuffer according to a provided - callback function. - - The 'generic' array data type is *not* supported. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( buf, 0, 4, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0, 1.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 394ac49..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,606 +0,0 @@ -/* -* @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. -*/ - -/// - -import { IterableIterator } from '@stdlib/types/iter'; -import filledarrayBy = require( './index' ); - - -/** -* Returns an iterator protocol-compliant object. -* -* @returns iterator protocol-compliant object -*/ -function iterator(): IterableIterator { - const obj: IterableIterator = { - [Symbol.iterator]: iterator, - 'next': next - }; - return obj; -} - -/** -* Implements the iterator protocol `next` method. -* -* @returns iterator protocol-compliant object -*/ -function next(): any { - return { - 'value': 1.0, - 'done': false - }; -} - -/** -* Callback function. -* -* @param i - current array index -* @returns return value -*/ -function clbk( i: number ): number { - return i; -} - - -// TESTS // - -// The function returns an array or typed array... -{ - filledarrayBy(); // $ExpectType ArrayOrTypedArray - filledarrayBy( 'float32' ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( 10, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( 10, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( 10, 'int32', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( 10, 'int32', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const x = new Float64Array( 10 ); - filledarrayBy( x, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( x, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( x, 'uint8', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( x, 'uint8', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const y = [ 2.0, 2.0, 2.0 ]; - filledarrayBy( y, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( y, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( y, 'float64', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( y, 'float64', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const it = iterator(); - filledarrayBy( it, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( it, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( it, 'uint8c', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( it, 'uint8c', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const buf = new ArrayBuffer( 32 ); - filledarrayBy( buf, clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 'uint32', clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 'uint32', clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 8, clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 8, clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 8, 'uint16', clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 8, 'uint16', clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 8, 2, clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 8, 2, clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 8, 2, 'int16', clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 8, 2, 'int16', clbk, {} ); // $ExpectType RealOrComplexTypedArray -} - -// The compiler throws an error if a callback function argument is not a function... -{ - filledarrayBy( 'float64', '5' ); // $ExpectError - filledarrayBy( 'float64', 1.0 ); // $ExpectError - filledarrayBy( 'float64', false ); // $ExpectError - filledarrayBy( 'float64', true ); // $ExpectError - filledarrayBy( 'float64', null ); // $ExpectError - filledarrayBy( 'float64', undefined ); // $ExpectError - filledarrayBy( 'float64', [] ); // $ExpectError - filledarrayBy( 'float64', {} ); // $ExpectError - - filledarrayBy( 'float64', '5', {} ); // $ExpectError - filledarrayBy( 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( 'float64', false, {} ); // $ExpectError - filledarrayBy( 'float64', true, {} ); // $ExpectError - filledarrayBy( 'float64', null, {} ); // $ExpectError - filledarrayBy( 'float64', undefined, {} ); // $ExpectError - filledarrayBy( 'float64', [], {} ); // $ExpectError - filledarrayBy( 'float64', {}, {} ); // $ExpectError - - filledarrayBy( 10, '5' ); // $ExpectError - filledarrayBy( 10, 1.0 ); // $ExpectError - filledarrayBy( 10, false ); // $ExpectError - filledarrayBy( 10, true ); // $ExpectError - filledarrayBy( 10, null ); // $ExpectError - filledarrayBy( 10, undefined ); // $ExpectError - filledarrayBy( 10, [] ); // $ExpectError - filledarrayBy( 10, {} ); // $ExpectError - - filledarrayBy( 10, '5', {} ); // $ExpectError - filledarrayBy( 10, 1.0, {} ); // $ExpectError - filledarrayBy( 10, false, {} ); // $ExpectError - filledarrayBy( 10, true, {} ); // $ExpectError - filledarrayBy( 10, null, {} ); // $ExpectError - filledarrayBy( 10, undefined, {} ); // $ExpectError - filledarrayBy( 10, [], {} ); // $ExpectError - filledarrayBy( 10, {}, {} ); // $ExpectError - - filledarrayBy( 10, 'float64', '5' ); // $ExpectError - filledarrayBy( 10, 'float64', 1.0 ); // $ExpectError - filledarrayBy( 10, 'float64', false ); // $ExpectError - filledarrayBy( 10, 'float64', true ); // $ExpectError - filledarrayBy( 10, 'float64', null ); // $ExpectError - filledarrayBy( 10, 'float64', undefined ); // $ExpectError - filledarrayBy( 10, 'float64', [] ); // $ExpectError - filledarrayBy( 10, 'float64', {} ); // $ExpectError - - filledarrayBy( 10, 'float64', '5', {} ); // $ExpectError - filledarrayBy( 10, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( 10, 'float64', false, {} ); // $ExpectError - filledarrayBy( 10, 'float64', true, {} ); // $ExpectError - filledarrayBy( 10, 'float64', null, {} ); // $ExpectError - filledarrayBy( 10, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( 10, 'float64', [], {} ); // $ExpectError - filledarrayBy( 10, 'float64', {}, {} ); // $ExpectError - - const x = new Float64Array( 10 ); - filledarrayBy( x, '5' ); // $ExpectError - filledarrayBy( x, 1.0 ); // $ExpectError - filledarrayBy( x, false ); // $ExpectError - filledarrayBy( x, true ); // $ExpectError - filledarrayBy( x, null ); // $ExpectError - filledarrayBy( x, undefined ); // $ExpectError - filledarrayBy( x, [] ); // $ExpectError - filledarrayBy( x, {} ); // $ExpectError - - filledarrayBy( x, '5', {} ); // $ExpectError - filledarrayBy( x, 1.0, {} ); // $ExpectError - filledarrayBy( x, false, {} ); // $ExpectError - filledarrayBy( x, true, {} ); // $ExpectError - filledarrayBy( x, null, {} ); // $ExpectError - filledarrayBy( x, undefined, {} ); // $ExpectError - filledarrayBy( x, [], {} ); // $ExpectError - filledarrayBy( x, {}, {} ); // $ExpectError - - filledarrayBy( x, 'float64', '5' ); // $ExpectError - filledarrayBy( x, 'float64', 1.0 ); // $ExpectError - filledarrayBy( x, 'float64', false ); // $ExpectError - filledarrayBy( x, 'float64', true ); // $ExpectError - filledarrayBy( x, 'float64', null ); // $ExpectError - filledarrayBy( x, 'float64', undefined ); // $ExpectError - filledarrayBy( x, 'float64', [] ); // $ExpectError - filledarrayBy( x, 'float64', {} ); // $ExpectError - - filledarrayBy( x, 'float64', '5', {} ); // $ExpectError - filledarrayBy( x, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( x, 'float64', false, {} ); // $ExpectError - filledarrayBy( x, 'float64', true, {} ); // $ExpectError - filledarrayBy( x, 'float64', null, {} ); // $ExpectError - filledarrayBy( x, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( x, 'float64', [], {} ); // $ExpectError - filledarrayBy( x, 'float64', {}, {} ); // $ExpectError - - const y = [ 2.0, 2.0, 2.0 ]; - filledarrayBy( y, '5' ); // $ExpectError - filledarrayBy( y, 1.0 ); // $ExpectError - filledarrayBy( y, false ); // $ExpectError - filledarrayBy( y, true ); // $ExpectError - filledarrayBy( y, null ); // $ExpectError - filledarrayBy( y, undefined ); // $ExpectError - filledarrayBy( y, [] ); // $ExpectError - filledarrayBy( y, {} ); // $ExpectError - - filledarrayBy( y, '5', {} ); // $ExpectError - filledarrayBy( y, 1.0, {} ); // $ExpectError - filledarrayBy( y, false, {} ); // $ExpectError - filledarrayBy( y, true, {} ); // $ExpectError - filledarrayBy( y, null, {} ); // $ExpectError - filledarrayBy( y, undefined, {} ); // $ExpectError - filledarrayBy( y, [], {} ); // $ExpectError - filledarrayBy( y, {}, {} ); // $ExpectError - - filledarrayBy( y, 'float64', '5' ); // $ExpectError - filledarrayBy( y, 'float64', 1.0 ); // $ExpectError - filledarrayBy( y, 'float64', false ); // $ExpectError - filledarrayBy( y, 'float64', true ); // $ExpectError - filledarrayBy( y, 'float64', null ); // $ExpectError - filledarrayBy( y, 'float64', undefined ); // $ExpectError - filledarrayBy( y, 'float64', [] ); // $ExpectError - filledarrayBy( y, 'float64', {} ); // $ExpectError - - filledarrayBy( y, 'float64', '5', {} ); // $ExpectError - filledarrayBy( y, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( y, 'float64', false, {} ); // $ExpectError - filledarrayBy( y, 'float64', true, {} ); // $ExpectError - filledarrayBy( y, 'float64', null, {} ); // $ExpectError - filledarrayBy( y, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( y, 'float64', [], {} ); // $ExpectError - filledarrayBy( y, 'float64', {}, {} ); // $ExpectError - - const it = iterator(); - filledarrayBy( it, '5' ); // $ExpectError - filledarrayBy( it, 1.0 ); // $ExpectError - filledarrayBy( it, false ); // $ExpectError - filledarrayBy( it, true ); // $ExpectError - filledarrayBy( it, null ); // $ExpectError - filledarrayBy( it, undefined ); // $ExpectError - filledarrayBy( it, [] ); // $ExpectError - filledarrayBy( it, {} ); // $ExpectError - - filledarrayBy( it, '5', {} ); // $ExpectError - filledarrayBy( it, 1.0, {} ); // $ExpectError - filledarrayBy( it, false, {} ); // $ExpectError - filledarrayBy( it, true, {} ); // $ExpectError - filledarrayBy( it, null, {} ); // $ExpectError - filledarrayBy( it, undefined, {} ); // $ExpectError - filledarrayBy( it, [], {} ); // $ExpectError - filledarrayBy( it, {}, {} ); // $ExpectError - - filledarrayBy( it, 'float64', '5' ); // $ExpectError - filledarrayBy( it, 'float64', 1.0 ); // $ExpectError - filledarrayBy( it, 'float64', false ); // $ExpectError - filledarrayBy( it, 'float64', true ); // $ExpectError - filledarrayBy( it, 'float64', null ); // $ExpectError - filledarrayBy( it, 'float64', undefined ); // $ExpectError - filledarrayBy( it, 'float64', [] ); // $ExpectError - filledarrayBy( it, 'float64', {} ); // $ExpectError - - filledarrayBy( it, 'float64', '5', {} ); // $ExpectError - filledarrayBy( it, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( it, 'float64', false, {} ); // $ExpectError - filledarrayBy( it, 'float64', true, {} ); // $ExpectError - filledarrayBy( it, 'float64', null, {} ); // $ExpectError - filledarrayBy( it, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( it, 'float64', [], {} ); // $ExpectError - filledarrayBy( it, 'float64', {}, {} ); // $ExpectError - - const buf = new ArrayBuffer( 32 ); - filledarrayBy( buf, '5' ); // $ExpectError - filledarrayBy( buf, 1.0 ); // $ExpectError - filledarrayBy( buf, false ); // $ExpectError - filledarrayBy( buf, true ); // $ExpectError - filledarrayBy( buf, null ); // $ExpectError - filledarrayBy( buf, undefined ); // $ExpectError - filledarrayBy( buf, [] ); // $ExpectError - filledarrayBy( buf, {} ); // $ExpectError - - filledarrayBy( buf, '5', {} ); // $ExpectError - filledarrayBy( buf, 1.0, {} ); // $ExpectError - filledarrayBy( buf, false, {} ); // $ExpectError - filledarrayBy( buf, true, {} ); // $ExpectError - filledarrayBy( buf, null, {} ); // $ExpectError - filledarrayBy( buf, undefined, {} ); // $ExpectError - filledarrayBy( buf, [], {} ); // $ExpectError - filledarrayBy( buf, {}, {} ); // $ExpectError - - filledarrayBy( buf, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 'float64', false ); // $ExpectError - filledarrayBy( buf, 'float64', true ); // $ExpectError - filledarrayBy( buf, 'float64', null ); // $ExpectError - filledarrayBy( buf, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 'float64', {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5' ); // $ExpectError - filledarrayBy( buf, 8, 1.0 ); // $ExpectError - filledarrayBy( buf, 8, false ); // $ExpectError - filledarrayBy( buf, 8, true ); // $ExpectError - filledarrayBy( buf, 8, null ); // $ExpectError - filledarrayBy( buf, 8, undefined ); // $ExpectError - filledarrayBy( buf, 8, [] ); // $ExpectError - filledarrayBy( buf, 8, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, false, {} ); // $ExpectError - filledarrayBy( buf, 8, true, {} ); // $ExpectError - filledarrayBy( buf, 8, null, {} ); // $ExpectError - filledarrayBy( buf, 8, undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, [], {} ); // $ExpectError - filledarrayBy( buf, 8, {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 8, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 'float64', false ); // $ExpectError - filledarrayBy( buf, 8, 'float64', true ); // $ExpectError - filledarrayBy( buf, 8, 'float64', null ); // $ExpectError - filledarrayBy( buf, 8, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 8, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 8, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 8, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, '5' ); // $ExpectError - filledarrayBy( buf, 8, 2, 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 2, false ); // $ExpectError - filledarrayBy( buf, 8, 2, true ); // $ExpectError - filledarrayBy( buf, 8, 2, null ); // $ExpectError - filledarrayBy( buf, 8, 2, undefined ); // $ExpectError - filledarrayBy( buf, 8, 2, [] ); // $ExpectError - filledarrayBy( buf, 8, 2, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, false, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, true, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, null, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, [], {} ); // $ExpectError - filledarrayBy( buf, 8, 2, {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', false ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', true ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', null ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', {}, {} ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid length, typed array, array-like object, `ArrayBuffer`, or iterable argument... -{ - filledarrayBy( false, clbk ); // $ExpectError - filledarrayBy( true, clbk ); // $ExpectError - filledarrayBy( null, clbk ); // $ExpectError - filledarrayBy( {}, clbk ); // $ExpectError - - filledarrayBy( false, clbk, {} ); // $ExpectError - filledarrayBy( true, clbk, {} ); // $ExpectError - filledarrayBy( null, clbk, {} ); // $ExpectError - filledarrayBy( {}, clbk, {} ); // $ExpectError - - filledarrayBy( false, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 'float64', clbk ); // $ExpectError - - filledarrayBy( false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, clbk ); // $ExpectError - filledarrayBy( 1.0, 8, clbk ); // $ExpectError - filledarrayBy( false, 8, clbk ); // $ExpectError - filledarrayBy( true, 8, clbk ); // $ExpectError - filledarrayBy( null, 8, clbk ); // $ExpectError - filledarrayBy( undefined, 8, clbk ); // $ExpectError - filledarrayBy( [], 8, clbk ); // $ExpectError - filledarrayBy( {}, 8, clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, clbk ); // $ExpectError - - filledarrayBy( '5', 8, clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, clbk, {} ); // $ExpectError - filledarrayBy( false, 8, clbk, {} ); // $ExpectError - filledarrayBy( true, 8, clbk, {} ); // $ExpectError - filledarrayBy( null, 8, clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, clbk, {} ); // $ExpectError - filledarrayBy( [], 8, clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 'float64', clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( false, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( [], 8, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 'float64', clbk ); // $ExpectError - - filledarrayBy( '5', 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 2, clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 2, clbk ); // $ExpectError - filledarrayBy( false, 8, 2, clbk ); // $ExpectError - filledarrayBy( true, 8, 2, clbk ); // $ExpectError - filledarrayBy( null, 8, 2, clbk ); // $ExpectError - filledarrayBy( undefined, 8, 2, clbk ); // $ExpectError - filledarrayBy( [], 8, 2, clbk ); // $ExpectError - filledarrayBy( {}, 8, 2, clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, clbk ); // $ExpectError - - filledarrayBy( '5', 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( false, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( [], 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, 'float64', clbk ); // $ExpectError - - filledarrayBy( '5', 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a byte offset argument which is not a number... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, false, clbk ); // $ExpectError - filledarrayBy( buf, true, clbk ); // $ExpectError - filledarrayBy( buf, null, clbk ); // $ExpectError - filledarrayBy( buf, [], clbk ); // $ExpectError - filledarrayBy( buf, {}, clbk ); // $ExpectError - - filledarrayBy( buf, false, clbk, {} ); // $ExpectError - filledarrayBy( buf, true, clbk, {} ); // $ExpectError - filledarrayBy( buf, null, clbk, {} ); // $ExpectError - filledarrayBy( buf, [], clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, clbk, {} ); // $ExpectError - - filledarrayBy( buf, '5', 'float64', clbk ); // $ExpectError - filledarrayBy( buf, false, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, true, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, null, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, [], 'float64', clbk ); // $ExpectError - filledarrayBy( buf, {}, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, '5', 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( buf, false, 2, clbk ); // $ExpectError - filledarrayBy( buf, true, 2, clbk ); // $ExpectError - filledarrayBy( buf, null, 2, clbk ); // $ExpectError - filledarrayBy( buf, [], 2, clbk ); // $ExpectError - filledarrayBy( buf, {}, 2, clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, clbk ); // $ExpectError - - filledarrayBy( buf, false, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, clbk, {} ); // $ExpectError - - filledarrayBy( buf, '5', 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, false, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, true, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, null, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, undefined, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, [], 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, {}, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, '5', 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, false, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, undefined, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a view length argument which is not a number... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, 8, false, clbk ); // $ExpectError - filledarrayBy( buf, 8, true, clbk ); // $ExpectError - filledarrayBy( buf, 8, null, clbk ); // $ExpectError - filledarrayBy( buf, 8, [], clbk ); // $ExpectError - filledarrayBy( buf, 8, {}, clbk ); // $ExpectError - - filledarrayBy( buf, 8, false, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, true, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, null, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, [], clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, {}, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, clbk, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5', 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, false, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, true, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, null, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, [], 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, {}, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, 8, '5', 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, [], 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, {}, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided too many arguments... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, 8, 2, 'float64', 1, clbk, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 997a381..0000000 --- a/examples/index.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ).factory; -var dtypes = require( '@stdlib/array-typed-real-dtypes' ); -var filledarrayBy = require( './../lib' ); - -// Create a pseudorandom number generator: -var rand = discreteUniform( 0, 100 ); - -// Get a list of array data types: -var dt = dtypes(); - -// Generate filled arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = filledarrayBy( 10, dt[ i ], rand ); - console.log( arr ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index b1fd829..e1b94a1 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, RealOrComplexTypedArray, DataType } from '@stdlib/types/array'; import { IterableIterator } from '@stdlib/types/iter'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..56b3976 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.1-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-ctors@v0.2.1-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill-by@v0.2.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled-by@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.2.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.1-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@v0.2.1-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.2.1-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";var j=d(),a=p.get("dtypes.default");function v(){var d,p,v,c,g,y,b,u;if(0===(p=arguments.length))return new(g=o(a))(0);if(r(v=arguments[0])){if(p>1)throw new TypeError(w("00h05"));if(null===(g=o(v)))throw new TypeError(w("00h2Y",v));return new g(0)}if(p<2)throw new TypeError(w("00h05"));if(n(arguments[p-=1]))if(n(arguments[p-1])){if(d=arguments[p],c=arguments[p-=1],0===p)throw new TypeError(w("00h05"))}else c=arguments[p];else{if(!(p>=2))throw new TypeError(w("00h05"));if(d=arguments[p],!n(c=arguments[p-=1]))throw new TypeError(w("00h2b",c))}if((p-=1)>=0&&r(arguments[p])?(v=arguments[p],p-=1):v=a,null===(g=o(v)))throw new TypeError(w("00h2Y",v));if("generic"===v){if(u=arguments[0],0===p){if(e(u)?b=u:t(u)&&(b=u.length),void 0!==b)return l(b,c,d);if(s(u))throw new Error(w("00h04"));if(i(u)){if(!1===j)throw new TypeError(w("00h2Z",u));if(!n(u[m]))throw new TypeError(w("00h2a",u));if(u=u[m](),!n(u.next))throw new TypeError(w("00h2a",u));return function(r,e,t){var s,i;for(s=[],i=-1;!r.next().done;)i+=1,s.push(e.call(t,i));return s}(u,c,d)}throw new TypeError(w("00h2a",u))}if(s(u))throw new Error(w("00h04"));throw new TypeError(w("00h2a",u))}if(0===p)if(t(u=arguments[0]))y=new g(u.length);else if(s(u))y=new g(u);else if(e(u))y=new g(u);else{if(!i(u))throw new TypeError(w("00h2a",u));if(!1===j)throw new TypeError(w("00h2Z",u));if(!n(u[m]))throw new TypeError(w("00h2a",u));if(u=u[m](),!n(u.next))throw new TypeError(w("00h2a",u));y=new g(f(u))}else y=1===p?new g(arguments[0],arguments[1]):new g(arguments[0],arguments[1],arguments[2]);return y.length>0&&(/^complex/.test(v)?function(r,e,t){var s;for(s=0;s\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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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( format('00h05') );\n\t\t}\n\t\tctor = ctors( dtype );\n\t\tif ( ctor === null ) {\n\t\t\tthrow new TypeError( format( '00h2Y', 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( format('00h05') );\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( format('00h05') );\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( '00h2b', 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( format('00h05') );\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( '00h2Y', 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( format('00h04') );\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( '00h2Z', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00h2a', 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( '00h2a', 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( '00h2a', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format('00h04') );\n\t\t}\n\t\tthrow new TypeError( format( '00h2a', 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( '00h2Z', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00h2a', 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( '00h2a', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00h2a', 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\nexport default filledarrayBy;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","DEFAULT_DTYPE","defaults","get","filledarrayBy","thisArg","nargs","dtype","clbk","ctor","arr","len","arg","arguments","length","ctors","isString","TypeError","format","isFunction","isNonNegativeInteger","isCollection","filledArray","isArrayBuffer","Error","isObject","ITERATOR_SYMBOL","next","it","i","done","push","call","filledArrayIterator","iterLength","test","set","filledAccessors","gfillBy","value","aidx"],"mappings":";;q0CAwCA,IAAIA,EAAsBC,IACtBC,EAAgBC,EAASC,IAAK,kBA2MlC,SAASC,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAKJ,GAAe,KAHfN,EAAQO,UAAUC,QAKjB,OAAO,IADPL,EAAOM,EAAOd,IACG,GAIlB,GAAKe,EADLT,EAAQM,UAAW,IACM,CAExB,GAAKP,EAAQ,EACZ,MAAM,IAAIW,UAAWC,EAAO,UAG7B,GAAc,QADdT,EAAOM,EAAOR,IAEb,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,OAAO,IAAIE,EAAM,EACjB,CAED,GAAKH,EAAQ,EACZ,MAAM,IAAIW,UAAWC,EAAO,UAM7B,GAAKC,EAAYN,UAHjBP,GAAS,IAKR,GAAKa,EAAYN,UAAWP,EAAM,KAMjC,GALAD,EAAUQ,UAAWP,GAErBE,EAAOK,UADPP,GAAS,GAIM,IAAVA,EACJ,MAAM,IAAIW,UAAWC,EAAO,eAI7BV,EAAOK,UAAWP,OAIf,MAAKA,GAAS,GAUlB,MAAM,IAAIW,UAAWC,EAAO,UAN5B,GAHAb,EAAUQ,UAAWP,IAGfa,EADNX,EAAOK,UADPP,GAAS,IAGR,MAAM,IAAIW,UAAWC,EAAQ,QAASV,GAMvC,CAUD,IARAF,GAAS,IACK,GAAKU,EAAUH,UAAWP,KACvCC,EAAQM,UAAWP,GACnBA,GAAS,GAETC,EAAQN,EAGK,QADdQ,EAAOM,EAAOR,IAEb,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,GAAe,YAAVA,EAAsB,CAE1B,GADAK,EAAMC,UAAW,GACF,IAAVP,EAAc,CAMlB,GALKc,EAAsBR,GAC1BD,EAAMC,EACKS,EAAcT,KACzBD,EAAMC,EAAIE,aAEE,IAARH,EACJ,OAAOW,EAAaX,EAAKH,EAAMH,GAEhC,GAAKkB,EAAeX,GACnB,MAAM,IAAIY,MAAON,EAAO,UAEzB,GAAKO,EAAUb,GAAQ,CACtB,IAA6B,IAAxBb,EACJ,MAAM,IAAIkB,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAYP,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLP,EAAYP,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvC,OAvSJ,SAA8BgB,EAAIpB,EAAMH,GACvC,IAAIK,EACAmB,EAKJ,IAFAnB,EAAM,GACNmB,GAAK,GAEAD,EAAGD,OACAG,MAGPD,GAAK,EACLnB,EAAIqB,KAAMvB,EAAKwB,KAAM3B,EAASwB,IAE/B,OAAOnB,CACR,CAuRWuB,CAAqBrB,EAAKJ,EAAMH,EACvC,CACD,MAAM,IAAIY,UAAWC,EAAQ,QAASN,GACzC,CAAS,GAAKW,EAAeX,GAC1B,MAAM,IAAIY,MAAON,EAAO,UAEzB,MAAM,IAAID,UAAWC,EAAQ,QAASN,GACtC,CACD,GAAe,IAAVN,EAEJ,GAAKe,EADLT,EAAMC,UAAW,IAEhBH,EAAM,IAAID,EAAMG,EAAIE,aACd,GAAKS,EAAeX,GAC1BF,EAAM,IAAID,EAAMG,QACV,GAAKQ,EAAsBR,GACjCF,EAAM,IAAID,EAAMG,OACV,KAAKa,EAAUb,GAarB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAZtC,IAA6B,IAAxBb,EACJ,MAAM,IAAIkB,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAYP,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLP,EAAYP,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvCF,EAAM,IAAID,EAAMyB,EAAYtB,GAG5B,MAEDF,EADqB,IAAVJ,EACL,IAAIG,EAAMI,UAAU,GAAIA,UAAU,IAElC,IAAIJ,EAAMI,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKH,EAAII,OAAS,IACZ,WAAWqB,KAAM5B,GAjTxB,SAA0BG,EAAKF,EAAMH,GACpC,IAAIwB,EACJ,IAAMA,EAAI,EAAGA,EAAInB,EAAII,OAAQe,IAC5BnB,EAAI0B,IAAK5B,EAAKwB,KAAM3B,EAASwB,GAAKA,EAGpC,CA4SGQ,CAAiB3B,EAAKF,EAAMH,GAE5BiC,EAAS5B,EAAII,OAAQJ,EAAK,GAe5B,SAAmB6B,EAAOC,GACzB,OAAOhC,EAAKwB,KAAM3B,EAASmC,EAC3B,KAdM9B,CAeR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d115cf0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,192 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -/** -* Create a filled array according to a provided callback function. -* -* @module @stdlib/array-filled-by -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* var arr = filledarrayBy(); -* // returns -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'generic', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( [ 0.5, 0.5 ], clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1; -* } -* -* var arr = filledarrayBy( [ 5, -3 ], 'int32', clbk ); -* // returns [ 1, 1 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk1() { -* return 10; -* } -* -* function clbk2() { -* return 1.0; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, clbk2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk1() { -* return 1.0; -* } -* -* function clbk2() { -* return 2; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, 'uint32', clbk2 ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 'float32', clbk ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, clbk ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, 'int32', clbk ); -* // returns [ 1, 1 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 06bc8b6..0000000 --- a/lib/main.js +++ /dev/null @@ -1,414 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var isCollection = require( '@stdlib/assert-is-collection' ); -var isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isObject = require( '@stdlib/assert-is-object' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var ctors = require( '@stdlib/array-ctors' ); -var gfillBy = require( '@stdlib/blas-ext-base-gfill-by' ); -var filledArray = require( '@stdlib/array-base-filled-by' ); -var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var iterLength = require( '@stdlib/iter-length' ); -var defaults = require( '@stdlib/array-defaults' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport(); -var DEFAULT_DTYPE = defaults.get( 'dtypes.default' ); - - -// FUNCTIONS // - -/** -* Creates a filled "generic" array from an iterator. -* -* @private -* @param {Iterable} it - iterator -* @param {Callback} clbk - callback function -* @param {*} thisArg - callback function execution context -* @returns {Array} filled array -*/ -function filledArrayIterator( it, clbk, thisArg ) { - var arr; - var i; - var v; - - arr = []; - i = -1; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - i += 1; - arr.push( clbk.call( thisArg, i ) ); - } - return arr; -} - -/** -* Fills an array exposing accessors for getting and setting array elements. -* -* @private -* @param {Collection} arr - input array -* @param {Callback} clbk - callback function -* @param {*} thisArg - callback function execution context -* @returns {Collection} input array -*/ -function filledAccessors( arr, clbk, thisArg ) { - var i; - for ( i = 0; i < arr.length; i++ ) { - arr.set( clbk.call( thisArg, i ), i ); - } - return arr; -} - - -// MAIN // - -/** -* Creates a filled array according to a provided callback function. -* -* @param {(NonNegativeInteger|TypedArray|ArrayLikeObject|ArrayBuffer|Iterable)} [arg] - a length, typed array, array-like object, buffer, or iterable -* @param {NonNegativeInteger} [byteOffset=0] - byte offset -* @param {NonNegativeInteger} [length] - view length -* @param {string} [dtype="float64"] - data type -* @param {Callback} [clbk] - callback to invoke -* @param {*} [thisArg] - callback execution context -* @throws {TypeError} must provide a recognized data type -* @throws {TypeError} must provide a length, typed array, array-like object, buffer, or iterable -* @throws {TypeError} callback argument must be a function. -* @throws {Error} creating a generic array from an `ArrayBuffer` is not supported -* @returns {(TypedArray|Array)} array or typed array -* -* @example -* var arr = filledarrayBy(); -* // returns -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'generic', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( [ 0.5, 0.5 ], clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1; -* } -* -* var arr = filledarrayBy( [ 5, -3 ], 'int32', clbk ); -* // returns [ 1, 1 ] -* -* @example -* function clbk1() { -* return 10; -* } -* -* function clbk2() { -* return 1.0; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, clbk2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk1() { -* return 1.0; -* } -* -* function clbk2() { -* return 2; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, 'uint32', clbk2 ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 'float32', clbk ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, clbk ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, 'int32', clbk ); -* // returns [ 1, 1 ] -*/ -function filledarrayBy() { - var thisArg; - var nargs; - var dtype; - var clbk; - var ctor; - var arr; - var len; - var arg; - - nargs = arguments.length; - - // If we weren't provided any arguments, return an empty array... - if ( nargs === 0 ) { - ctor = ctors( DEFAULT_DTYPE ); - return new ctor( 0 ); - } - // Check if we were provided a dtype as the first argument... - dtype = arguments[ 0 ]; - if ( isString( dtype ) ) { - // Invoking this function with arguments `f( dtype, clbk[, thisArg] )` is not allowed (otherwise, we'd need to also allow `f( clbk[, thisArg] )`)... - if ( nargs > 1 ) { - throw new TypeError( format('00h05') ); - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '00h2Y', dtype ) ); - } - // Return an empty array having the specified dtype: - return new ctor( 0 ); - } - // For all other supported invocations, we need at least two arguments... - if ( nargs < 2 ) { - throw new TypeError( format('00h05') ); - } - // At this point, we need to do some argument juggling... - nargs -= 1; // henceforth, the number of available arguments is `nargs+1` - - // Determine whether the last argument is a callback or "this" context... - if ( isFunction( arguments[ nargs ] ) ) { - // 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... - if ( isFunction( arguments[ nargs-1 ] ) ) { - thisArg = arguments[ nargs ]; - nargs -= 1; - clbk = arguments[ nargs ]; - - // Check if we were provided only a callback and a "this" context.. - if ( nargs === 0 ) { - throw new TypeError( format('00h05') ); - } - } else { - // "this" context is left undefined... - clbk = arguments[ nargs ]; - } - } - // 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... - else if ( nargs >= 2 ) { - thisArg = arguments[ nargs ]; - nargs -= 1; - clbk = arguments[ nargs ]; - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '00h2b', clbk ) ); - } - } - // If were were only provided 2 arguments and the last argument was not a function, we've been provided an insufficient number of arguments... - else { - throw new TypeError( format('00h05') ); - } - // Now that we've processed the callback arguments, let's continue working backward to see if we've been provided a `dtype` argument... - nargs -= 1; - if ( nargs >= 0 && isString( arguments[ nargs ] ) ) { - dtype = arguments[ nargs ]; - nargs -= 1; - } else { - dtype = DEFAULT_DTYPE; - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '00h2Y', dtype ) ); - } - // At this point, we've resolved the output array data type, and now we can actually create the output array... - if ( dtype === 'generic' ) { - arg = arguments[ 0 ]; - if ( nargs === 0 ) { - if ( isNonNegativeInteger( arg ) ) { - len = arg; - } else if ( isCollection( arg ) ) { - len = arg.length; - } - if ( len !== void 0 ) { - return filledArray( len, clbk, thisArg ); - } - if ( isArrayBuffer( arg ) ) { - throw new Error( format('00h04') ); - } - if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( '00h2Z', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00h2a', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00h2a', arg ) ); - } - return filledArrayIterator( arg, clbk, thisArg ); - } - throw new TypeError( format( '00h2a', arg ) ); - } else if ( isArrayBuffer( arg ) ) { - throw new Error( format('00h04') ); - } - throw new TypeError( format( '00h2a', arg ) ); - } - if ( nargs === 0 ) { // length || array-like || ArrayBuffer || iterable - arg = arguments[ 0 ]; - if ( isCollection( arg ) ) { - arr = new ctor( arg.length ); - } else if ( isArrayBuffer( arg ) ) { - arr = new ctor( arg ); - } else if ( isNonNegativeInteger( arg ) ) { - arr = new ctor( arg ); - } else if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( '00h2Z', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00h2a', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00h2a', arg ) ); - } - arr = new ctor( iterLength( arg ) ); - } else { - throw new TypeError( format( '00h2a', arg ) ); - } - } else if ( nargs === 1 ) { - arr = new ctor( arguments[0], arguments[1] ); // (ArrayBuffer, byteOffset) - } else { - arr = new ctor( arguments[0], arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset, length) - } - if ( arr.length > 0 ) { - if ( /^complex/.test( dtype ) ) { - filledAccessors( arr, clbk, thisArg ); - } else { - gfillBy( arr.length, arr, 1, callback ); - } - } - return arr; - - /** - * Callback which wraps a provided callback and is invoked for each array element. - * - * @private - * @param {*} value - element value - * @param {NonNegativeInteger} aidx - array index - * @param {NonNegativeInteger} sidx - strided index - * @param {Collection} array - input array/collection - * @returns {*} callback return value - */ - function callback( value, aidx ) { - return clbk.call( thisArg, aidx ); - } -} - - -// EXPORTS // - -module.exports = filledarrayBy; diff --git a/package.json b/package.json index fe41e9b..b16be36 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Create a filled array according to a provided callback function.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,71 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-filled-by": "^0.2.1", - "@stdlib/array-ctors": "^0.2.1", - "@stdlib/array-defaults": "^0.2.1", - "@stdlib/assert-has-iterator-symbol-support": "^0.2.1", - "@stdlib/assert-is-arraybuffer": "^0.2.1", - "@stdlib/assert-is-collection": "^0.2.1", - "@stdlib/assert-is-function": "^0.2.1", - "@stdlib/assert-is-nonnegative-integer": "^0.2.1", - "@stdlib/assert-is-object": "^0.2.1", - "@stdlib/assert-is-string": "^0.2.1", - "@stdlib/blas-ext-base-gfill-by": "^0.2.1", - "@stdlib/iter-length": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1", - "@stdlib/symbol-iterator": "^0.2.1", - "@stdlib/types": "^0.3.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/array-buffer": "^0.2.1", - "@stdlib/array-complex128": "^0.2.1", - "@stdlib/array-complex64": "^0.2.1", - "@stdlib/array-float32": "^0.2.1", - "@stdlib/array-float64": "^0.2.1", - "@stdlib/array-int16": "^0.2.1", - "@stdlib/array-int32": "^0.2.1", - "@stdlib/array-int8": "^0.2.1", - "@stdlib/array-typed-real-dtypes": "^0.2.1", - "@stdlib/array-uint16": "^0.2.1", - "@stdlib/array-uint32": "^0.2.1", - "@stdlib/array-uint8": "^0.2.1", - "@stdlib/array-uint8c": "^0.2.1", - "@stdlib/assert-instance-of": "^0.2.1", - "@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": "^0.2.1", - "@stdlib/complex-float64": "^0.2.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-complex128": "^0.2.1", - "@stdlib/strided-base-reinterpret-complex64": "^0.2.0", - "@stdlib/utils-constant-function": "^0.2.1", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.1" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..0fbbd35 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index b55aa4a..0000000 --- a/test/test.js +++ /dev/null @@ -1,4248 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 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. -*/ - -/* eslint-disable max-len */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -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 ArrayBuffer = require( '@stdlib/array-buffer' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var iterConstant = require( '@stdlib/iter-constant' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var filledarrayBy = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': !hasIteratorSymbolSupport() -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof filledarrayBy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if only provided callback arguments', function test( t ) { - t.throws( clbk1, TypeError, 'throws an error' ); - t.throws( clbk2, TypeError, 'throws an error' ); - t.throws( clbk3, TypeError, 'throws an error' ); - t.end(); - - function clbk1() { - filledarrayBy( constantFunction( 1.0 ) ); - } - - function clbk2() { - filledarrayBy( constantFunction( 1.0 ), {} ); - } - - function clbk3() { - filledarrayBy( constantFunction( 1.0 ), constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (only argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (typed array; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (array-like object)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (array-like object; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 8 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 8 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, 1, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (iterator)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( iterConstant( 1.0 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (iterator; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( iterConstant( 1.0 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if only provided data type and callback arguments', function test( t ) { - t.throws( clbk1, TypeError, 'throws an error' ); - t.throws( clbk2, TypeError, 'throws an error' ); - t.throws( clbk3, TypeError, 'throws an error' ); - t.end(); - - function clbk1() { - filledarrayBy( 'float64', constantFunction( 1.0 ) ); - } - - function clbk2() { - filledarrayBy( 'float64', constantFunction( 1.0 ), {} ); - } - - function clbk3() { - filledarrayBy( 'float64', constantFunction( 1.0 ), constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (array-like object)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (array-like object; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, 1, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, 1, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (no iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (no iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (non-function iterator symbol property)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (non-function iterator symbol property; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (`next` property is not a function)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ) ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (`next` property is not a function; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ), {} ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (no iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (no iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (non-function iterator symbol property)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (non-function iterator symbol property; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (`next` property is not a function)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ) ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (`next` property is not a function; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ), {} ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 1, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 1, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function returns a filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - arr = filledarrayBy(); - - t.strictEqual( instanceOf( arr, Float64Array ), 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=float64)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - arr = filledarrayBy( 'float64' ); - - t.strictEqual( instanceOf( arr, Float64Array ), 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=float32)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( 0 ); - arr = filledarrayBy( 'float32' ); - - t.strictEqual( instanceOf( arr, Float32Array ), 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; - - expected = new Complex128Array( 0 ); - arr = filledarrayBy( 'complex128' ); - - t.strictEqual( instanceOf( arr, Complex128Array ), 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=complex64)', function test( t ) { - var expected; - var arr; - - expected = new Complex64Array( 0 ); - arr = filledarrayBy( 'complex64' ); - - t.strictEqual( instanceOf( arr, Complex64Array ), 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=int32)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( 0 ); - arr = filledarrayBy( 'int32' ); - - t.strictEqual( instanceOf( arr, Int32Array ), 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=uint32)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( 0 ); - arr = filledarrayBy( 'uint32' ); - - t.strictEqual( instanceOf( arr, Uint32Array ), 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=int16)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( 0 ); - arr = filledarrayBy( 'int16' ); - - t.strictEqual( instanceOf( arr, Int16Array ), 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=uint16)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( 0 ); - arr = filledarrayBy( 'uint16' ); - - t.strictEqual( instanceOf( arr, Uint16Array ), 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=int8)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( 0 ); - arr = filledarrayBy( 'int8' ); - - t.strictEqual( instanceOf( arr, Int8Array ), 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=uint8)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( 0 ); - arr = filledarrayBy( 'uint8' ); - - t.strictEqual( instanceOf( arr, Uint8Array ), 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=uint8c)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( 0 ); - arr = filledarrayBy( 'uint8c' ); - - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), 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=generic)', function test( t ) { - var expected; - var arr; - - expected = []; - arr = filledarrayBy( 'generic' ); - - t.strictEqual( instanceOf( arr, Array ), 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 (default, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, length=0)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array(); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 0, clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, clbk, ctx ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (default, length; thisArg=function)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, clbk, context ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this(); // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } - - function context() { - ctx.count += 1; - } -}); - -tape( 'the function returns a filled array (dtype=float64, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, 'float64', clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, length; thisArg=function)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, 'float64', clbk, context ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this(); // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } - - function context() { - ctx.count += 1; - } -}); - -tape( 'the function returns a filled array (dtype=float32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, 'float32', clbk ); - - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex128, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = filledarrayBy( 5, 'complex128', clbk ); - - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = filledarrayBy( 5, 'complex64', clbk ); - - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int32Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int32', clbk ); - - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint32Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint32', clbk ); - - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int16Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int16', clbk ); - - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint16', clbk ); - - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int8Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int8', clbk ); - - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint8', clbk ); - - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint8c', clbk ); - - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = [ 1, 1, 1, 1, 1 ]; - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'generic', clbk ); - - t.strictEqual( instanceOf( arr, Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex128, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = [ 1.0, 2.0 ]; - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = [ 1.0, 2.0 ]; - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int32', clbk ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, typed array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, typed array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex128, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = new Float64Array( [ 1.0, 2.0 ] ); - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = new Float64Array( [ 1.0, 2.0 ] ); - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (default, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex128, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer, byteoffset; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer, byteoffset; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, 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; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 48 ); - out = filledarrayBy( buf, 16, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 24 ); - out = filledarrayBy( buf, 8, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int32', clbk ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint8c', clbk ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, 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; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 64 ); - out = filledarrayBy( buf, 16, 2, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset, length)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 1, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 1, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled array (default, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, iterator; thisArg)', opts, function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - ctx = { - 'count': 0 - }; - indices = []; - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, iterator; thisArg)', opts, function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - ctx = { - 'count': 0 - }; - indices = []; - out = filledarrayBy( arr, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex128, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = iterConstant( new Complex128( 3.0, 3.0 ), { - 'iter': 2 - }); - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = iterConstant( new Complex64( 3.0, 3.0 ), { - 'iter': 2 - }); - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); From f5a36f83b2aef5f549e013fa5a5698a11870f94d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 25 May 2024 08:53:50 +0000 Subject: [PATCH 060/117] Transform error messages --- lib/main.js | 38 +++++++++++++++++++------------------- package.json | 2 +- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/lib/main.js b/lib/main.js index 0f134bb..06bc8b6 100644 --- a/lib/main.js +++ b/lib/main.js @@ -33,7 +33,7 @@ var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-supp var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); var iterLength = require( '@stdlib/iter-length' ); var defaults = require( '@stdlib/array-defaults' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -264,18 +264,18 @@ function filledarrayBy() { if ( isString( dtype ) ) { // Invoking this function with arguments `f( dtype, clbk[, thisArg] )` is not allowed (otherwise, we'd need to also allow `f( clbk[, thisArg] )`)... if ( nargs > 1 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format('00h05') ); } ctor = ctors( dtype ); if ( ctor === null ) { - throw new TypeError( format( 'invalid argument. Must provide a recognized data type. Value: `%s`.', dtype ) ); + throw new TypeError( format( '00h2Y', dtype ) ); } // Return an empty array having the specified dtype: return new ctor( 0 ); } // For all other supported invocations, we need at least two arguments... if ( nargs < 2 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format('00h05') ); } // At this point, we need to do some argument juggling... nargs -= 1; // henceforth, the number of available arguments is `nargs+1` @@ -290,7 +290,7 @@ function filledarrayBy() { // Check if we were provided only a callback and a "this" context.. if ( nargs === 0 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format('00h05') ); } } else { // "this" context is left undefined... @@ -303,12 +303,12 @@ function filledarrayBy() { nargs -= 1; clbk = arguments[ nargs ]; if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '00h2b', clbk ) ); } } // If were were only provided 2 arguments and the last argument was not a function, we've been provided an insufficient number of arguments... else { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format('00h05') ); } // Now that we've processed the callback arguments, let's continue working backward to see if we've been provided a `dtype` argument... nargs -= 1; @@ -320,7 +320,7 @@ function filledarrayBy() { } ctor = ctors( dtype ); if ( ctor === null ) { - throw new TypeError( format( 'invalid argument. Must provide a recognized data type. Value: `%s`.', dtype ) ); + throw new TypeError( format( '00h2Y', dtype ) ); } // At this point, we've resolved the output array data type, and now we can actually create the output array... if ( dtype === 'generic' ) { @@ -335,26 +335,26 @@ function filledarrayBy() { return filledArray( len, clbk, thisArg ); } if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format('00h04') ); } if ( isObject( arg ) ) { if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2Z', arg ) ); } if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } arg = arg[ ITERATOR_SYMBOL ](); if ( !isFunction( arg.next ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } return filledArrayIterator( arg, clbk, thisArg ); } - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } else if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format('00h04') ); } - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } if ( nargs === 0 ) { // length || array-like || ArrayBuffer || iterable arg = arguments[ 0 ]; @@ -366,18 +366,18 @@ function filledarrayBy() { arr = new ctor( arg ); } else if ( isObject( arg ) ) { if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2Z', arg ) ); } if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } arg = arg[ ITERATOR_SYMBOL ](); if ( !isFunction( arg.next ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } arr = new ctor( iterLength( arg ) ); } else { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } } else if ( nargs === 1 ) { arr = new ctor( arguments[0], arguments[1] ); // (ArrayBuffer, byteOffset) diff --git a/package.json b/package.json index 4d10db8..4e7e4b8 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "@stdlib/assert-is-string": "^0.2.1", "@stdlib/blas-ext-base-gfill-by": "^0.2.1", "@stdlib/iter-length": "^0.2.1", - "@stdlib/string-format": "^0.2.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1", "@stdlib/symbol-iterator": "^0.2.1", "@stdlib/types": "^0.3.2", "@stdlib/error-tools-fmtprodmsg": "^0.2.1" From 62ee42e8c3419272a995babc07ada8268dcc5c67 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 25 May 2024 09:00:20 +0000 Subject: [PATCH 061/117] Remove files --- index.d.ts | 426 ----- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5273 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index e1b94a1..0000000 --- a/index.d.ts +++ /dev/null @@ -1,426 +0,0 @@ -/* -* @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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, RealOrComplexTypedArray, DataType } from '@stdlib/types/array'; -import { IterableIterator } from '@stdlib/types/iter'; - -/** -* Array or typed array. -*/ -type ArrayOrTypedArray = Array | RealOrComplexTypedArray; - -/** -* Nullary callback function. -* -* @returns fill value -*/ -type Nullary = () => any; - -/** -* Unary callback function. -* -* @param i - current array index -* @returns fill value -*/ -type Unary = ( i: number ) => any; - -/** -* Callback function. -* -* @param i - current array index -* @returns fill value -*/ -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 -* -* @example -* var arr = filledarrayBy(); -* // returns -* -* @example -* var arr = filledarrayBy( 'float32' ); -* // returns -*/ -declare function filledarrayBy( dtype?: DataType ): ArrayOrTypedArray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Creates a filled array according to a provided callback function and having a specified `length`. -* -* @param length - array length -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* -* var arr = filledarrayBy( 5, constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( length: number, clbk: Callback, thisArg?: any ): ArrayOrTypedArray; - -/** -* 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 -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* -* var arr = filledarrayBy( 5, 'float64', constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( length: number, dtype: DataType, clbk: Callback, thisArg?: any ): ArrayOrTypedArray; - -/** -* Creates a filled array from another `array` according to a provided callback function. -* -* @param array - typed array or array-like object -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* -* 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; - -/** -* 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 -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* -* 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; - -/** -* Creates a filled array from an iterable according to a callback function. -* -* @param iterable - iterable -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var iterConstant = require( '@stdlib/iter-constant' ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarrayBy( it, constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( iterable: IterableIterator, callback: Callback, thisArg?: any ): ArrayOrTypedArray; - -/** -* 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 -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var iterConstant = require( '@stdlib/iter-constant' ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* 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; - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; - -/** -* 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. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; - -/** -* 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. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; - -/** -* 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. -* -* @param buffer - `ArrayBuffer` -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; - - -// EXPORTS // - -export = filledarrayBy; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 56b3976..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.1-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-ctors@v0.2.1-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill-by@v0.2.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled-by@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.2.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.1-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@v0.2.1-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.2.1-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";var j=d(),a=p.get("dtypes.default");function v(){var d,p,v,c,g,y,b,u;if(0===(p=arguments.length))return new(g=o(a))(0);if(r(v=arguments[0])){if(p>1)throw new TypeError(w("00h05"));if(null===(g=o(v)))throw new TypeError(w("00h2Y",v));return new g(0)}if(p<2)throw new TypeError(w("00h05"));if(n(arguments[p-=1]))if(n(arguments[p-1])){if(d=arguments[p],c=arguments[p-=1],0===p)throw new TypeError(w("00h05"))}else c=arguments[p];else{if(!(p>=2))throw new TypeError(w("00h05"));if(d=arguments[p],!n(c=arguments[p-=1]))throw new TypeError(w("00h2b",c))}if((p-=1)>=0&&r(arguments[p])?(v=arguments[p],p-=1):v=a,null===(g=o(v)))throw new TypeError(w("00h2Y",v));if("generic"===v){if(u=arguments[0],0===p){if(e(u)?b=u:t(u)&&(b=u.length),void 0!==b)return l(b,c,d);if(s(u))throw new Error(w("00h04"));if(i(u)){if(!1===j)throw new TypeError(w("00h2Z",u));if(!n(u[m]))throw new TypeError(w("00h2a",u));if(u=u[m](),!n(u.next))throw new TypeError(w("00h2a",u));return function(r,e,t){var s,i;for(s=[],i=-1;!r.next().done;)i+=1,s.push(e.call(t,i));return s}(u,c,d)}throw new TypeError(w("00h2a",u))}if(s(u))throw new Error(w("00h04"));throw new TypeError(w("00h2a",u))}if(0===p)if(t(u=arguments[0]))y=new g(u.length);else if(s(u))y=new g(u);else if(e(u))y=new g(u);else{if(!i(u))throw new TypeError(w("00h2a",u));if(!1===j)throw new TypeError(w("00h2Z",u));if(!n(u[m]))throw new TypeError(w("00h2a",u));if(u=u[m](),!n(u.next))throw new TypeError(w("00h2a",u));y=new g(f(u))}else y=1===p?new g(arguments[0],arguments[1]):new g(arguments[0],arguments[1],arguments[2]);return y.length>0&&(/^complex/.test(v)?function(r,e,t){var s;for(s=0;s\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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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( format('00h05') );\n\t\t}\n\t\tctor = ctors( dtype );\n\t\tif ( ctor === null ) {\n\t\t\tthrow new TypeError( format( '00h2Y', 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( format('00h05') );\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( format('00h05') );\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( '00h2b', 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( format('00h05') );\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( '00h2Y', 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( format('00h04') );\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( '00h2Z', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00h2a', 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( '00h2a', 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( '00h2a', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format('00h04') );\n\t\t}\n\t\tthrow new TypeError( format( '00h2a', 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( '00h2Z', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00h2a', 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( '00h2a', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00h2a', 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\nexport default filledarrayBy;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","DEFAULT_DTYPE","defaults","get","filledarrayBy","thisArg","nargs","dtype","clbk","ctor","arr","len","arg","arguments","length","ctors","isString","TypeError","format","isFunction","isNonNegativeInteger","isCollection","filledArray","isArrayBuffer","Error","isObject","ITERATOR_SYMBOL","next","it","i","done","push","call","filledArrayIterator","iterLength","test","set","filledAccessors","gfillBy","value","aidx"],"mappings":";;q0CAwCA,IAAIA,EAAsBC,IACtBC,EAAgBC,EAASC,IAAK,kBA2MlC,SAASC,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAKJ,GAAe,KAHfN,EAAQO,UAAUC,QAKjB,OAAO,IADPL,EAAOM,EAAOd,IACG,GAIlB,GAAKe,EADLT,EAAQM,UAAW,IACM,CAExB,GAAKP,EAAQ,EACZ,MAAM,IAAIW,UAAWC,EAAO,UAG7B,GAAc,QADdT,EAAOM,EAAOR,IAEb,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,OAAO,IAAIE,EAAM,EACjB,CAED,GAAKH,EAAQ,EACZ,MAAM,IAAIW,UAAWC,EAAO,UAM7B,GAAKC,EAAYN,UAHjBP,GAAS,IAKR,GAAKa,EAAYN,UAAWP,EAAM,KAMjC,GALAD,EAAUQ,UAAWP,GAErBE,EAAOK,UADPP,GAAS,GAIM,IAAVA,EACJ,MAAM,IAAIW,UAAWC,EAAO,eAI7BV,EAAOK,UAAWP,OAIf,MAAKA,GAAS,GAUlB,MAAM,IAAIW,UAAWC,EAAO,UAN5B,GAHAb,EAAUQ,UAAWP,IAGfa,EADNX,EAAOK,UADPP,GAAS,IAGR,MAAM,IAAIW,UAAWC,EAAQ,QAASV,GAMvC,CAUD,IARAF,GAAS,IACK,GAAKU,EAAUH,UAAWP,KACvCC,EAAQM,UAAWP,GACnBA,GAAS,GAETC,EAAQN,EAGK,QADdQ,EAAOM,EAAOR,IAEb,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,GAAe,YAAVA,EAAsB,CAE1B,GADAK,EAAMC,UAAW,GACF,IAAVP,EAAc,CAMlB,GALKc,EAAsBR,GAC1BD,EAAMC,EACKS,EAAcT,KACzBD,EAAMC,EAAIE,aAEE,IAARH,EACJ,OAAOW,EAAaX,EAAKH,EAAMH,GAEhC,GAAKkB,EAAeX,GACnB,MAAM,IAAIY,MAAON,EAAO,UAEzB,GAAKO,EAAUb,GAAQ,CACtB,IAA6B,IAAxBb,EACJ,MAAM,IAAIkB,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAYP,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLP,EAAYP,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvC,OAvSJ,SAA8BgB,EAAIpB,EAAMH,GACvC,IAAIK,EACAmB,EAKJ,IAFAnB,EAAM,GACNmB,GAAK,GAEAD,EAAGD,OACAG,MAGPD,GAAK,EACLnB,EAAIqB,KAAMvB,EAAKwB,KAAM3B,EAASwB,IAE/B,OAAOnB,CACR,CAuRWuB,CAAqBrB,EAAKJ,EAAMH,EACvC,CACD,MAAM,IAAIY,UAAWC,EAAQ,QAASN,GACzC,CAAS,GAAKW,EAAeX,GAC1B,MAAM,IAAIY,MAAON,EAAO,UAEzB,MAAM,IAAID,UAAWC,EAAQ,QAASN,GACtC,CACD,GAAe,IAAVN,EAEJ,GAAKe,EADLT,EAAMC,UAAW,IAEhBH,EAAM,IAAID,EAAMG,EAAIE,aACd,GAAKS,EAAeX,GAC1BF,EAAM,IAAID,EAAMG,QACV,GAAKQ,EAAsBR,GACjCF,EAAM,IAAID,EAAMG,OACV,KAAKa,EAAUb,GAarB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAZtC,IAA6B,IAAxBb,EACJ,MAAM,IAAIkB,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAYP,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLP,EAAYP,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvCF,EAAM,IAAID,EAAMyB,EAAYtB,GAG5B,MAEDF,EADqB,IAAVJ,EACL,IAAIG,EAAMI,UAAU,GAAIA,UAAU,IAElC,IAAIJ,EAAMI,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKH,EAAII,OAAS,IACZ,WAAWqB,KAAM5B,GAjTxB,SAA0BG,EAAKF,EAAMH,GACpC,IAAIwB,EACJ,IAAMA,EAAI,EAAGA,EAAInB,EAAII,OAAQe,IAC5BnB,EAAI0B,IAAK5B,EAAKwB,KAAM3B,EAASwB,GAAKA,EAGpC,CA4SGQ,CAAiB3B,EAAKF,EAAMH,GAE5BiC,EAAS5B,EAAII,OAAQJ,EAAK,GAe5B,SAAmB6B,EAAOC,GACzB,OAAOhC,EAAKwB,KAAM3B,EAASmC,EAC3B,KAdM9B,CAeR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 0fbbd35..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 461f48244a9af7d1f770affa749775da6334aa46 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 25 May 2024 09:00:37 +0000 Subject: [PATCH 062/117] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 248 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 188 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 47 +- SECURITY.md | 5 - benchmark/benchmark.js | 319 -- benchmark/benchmark.length.complex128.js | 98 - benchmark/benchmark.length.complex64.js | 98 - benchmark/benchmark.length.float32.js | 97 - benchmark/benchmark.length.float64.js | 97 - benchmark/benchmark.length.generic.js | 97 - benchmark/benchmark.length.int16.js | 97 - benchmark/benchmark.length.int32.js | 97 - benchmark/benchmark.length.int8.js | 97 - benchmark/benchmark.length.uint16.js | 97 - benchmark/benchmark.length.uint32.js | 97 - benchmark/benchmark.length.uint8.js | 97 - benchmark/benchmark.length.uint8c.js | 97 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 174 - docs/types/test.ts | 606 --- examples/index.js | 37 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 192 - lib/main.js | 414 -- package.json | 92 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 4248 ------------------ 54 files changed, 4869 insertions(+), 10558 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.length.complex128.js delete mode 100644 benchmark/benchmark.length.complex64.js delete mode 100644 benchmark/benchmark.length.float32.js delete mode 100644 benchmark/benchmark.length.float64.js delete mode 100644 benchmark/benchmark.length.generic.js delete mode 100644 benchmark/benchmark.length.int16.js delete mode 100644 benchmark/benchmark.length.int32.js delete mode 100644 benchmark/benchmark.length.int8.js delete mode 100644 benchmark/benchmark.length.uint16.js delete mode 100644 benchmark/benchmark.length.uint32.js delete mode 100644 benchmark/benchmark.length.uint8.js delete mode 100644 benchmark/benchmark.length.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 8be0b82..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index f988046..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index b2c1f9c..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '42 6 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f92a6c5..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -293,7 +284,7 @@ for ( i = 0; i < dt.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -364,9 +355,9 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/filled]: https://github.com/stdlib-js/array-filled +[@stdlib/array/filled]: https://github.com/stdlib-js/array-filled/tree/esm -[@stdlib/array/typed]: https://github.com/stdlib-js/array-typed +[@stdlib/array/typed]: https://github.com/stdlib-js/array-typed/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 571faf0..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,319 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); -var isArray = require( '@stdlib/assert-is-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var Complex64 = require( '@stdlib/complex-float32-ctor' ); -var Complex128 = require( '@stdlib/complex-float64-ctor' ); -var pkg = require( './../package.json' ).name; -var filledarrayBy = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 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=float64', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'float64', 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=float32', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'float32', 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; - var i; - - clbk = constantFunction( new Complex128( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'complex128', 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=complex64', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( new Complex64( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'complex64', 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=int32', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int32', 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=uint32', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint32', 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=int16', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int16', 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=uint16', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint16', 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=int8', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int8', 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=uint8', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint8', 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=uint8c', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint8c', 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=generic', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'generic', clbk ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.length.complex128.js b/benchmark/benchmark.length.complex128.js deleted file mode 100644 index 122bc7c..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 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 Complex128 = require( '@stdlib/complex-float64-ctor' ); -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( new Complex128( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'complex128', 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=complex128,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.complex64.js b/benchmark/benchmark.length.complex64.js deleted file mode 100644 index e7a2d74..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 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 Complex64 = require( '@stdlib/complex-float32-ctor' ); -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( new Complex64( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'complex64', 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=complex64,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.float32.js b/benchmark/benchmark.length.float32.js deleted file mode 100644 index d2b2ba7..0000000 --- a/benchmark/benchmark.length.float32.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'float32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=float32,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.float64.js b/benchmark/benchmark.length.float64.js deleted file mode 100644 index 65064e3..0000000 --- a/benchmark/benchmark.length.float64.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'float64', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=float64,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.generic.js b/benchmark/benchmark.length.generic.js deleted file mode 100644 index eb87dfa..0000000 --- a/benchmark/benchmark.length.generic.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isArray = require( '@stdlib/assert-is-array' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'generic', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isArray( 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=generic,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int16.js b/benchmark/benchmark.length.int16.js deleted file mode 100644 index 914ff7c..0000000 --- a/benchmark/benchmark.length.int16.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int16', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=int16,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int32.js b/benchmark/benchmark.length.int32.js deleted file mode 100644 index cc0f678..0000000 --- a/benchmark/benchmark.length.int32.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=int32,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int8.js b/benchmark/benchmark.length.int8.js deleted file mode 100644 index 77553b0..0000000 --- a/benchmark/benchmark.length.int8.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int8', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=int8,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint16.js b/benchmark/benchmark.length.uint16.js deleted file mode 100644 index c68efdd..0000000 --- a/benchmark/benchmark.length.uint16.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint16', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint16,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint32.js b/benchmark/benchmark.length.uint32.js deleted file mode 100644 index 27c1742..0000000 --- a/benchmark/benchmark.length.uint32.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint32,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint8.js b/benchmark/benchmark.length.uint8.js deleted file mode 100644 index 2a26be4..0000000 --- a/benchmark/benchmark.length.uint8.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint8', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint8,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint8c.js b/benchmark/benchmark.length.uint8c.js deleted file mode 100644 index dd6e8c2..0000000 --- a/benchmark/benchmark.length.uint8c.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint8c', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint8c,len='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index c138144..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by" -%% click B href "https://github.com/stdlib-js/array-filled-by/tree/main" -%% click C href "https://github.com/stdlib-js/array-filled-by/tree/production" -%% click D href "https://github.com/stdlib-js/array-filled-by/tree/esm" -%% click E href "https://github.com/stdlib-js/array-filled-by/tree/deno" -%% click F href "https://github.com/stdlib-js/array-filled-by/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by -[production-url]: https://github.com/stdlib-js/array-filled-by/tree/production -[deno-url]: https://github.com/stdlib-js/array-filled-by/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-filled-by/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-filled-by/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-filled-by/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-filled-by/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-filled-by/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 188fc9b..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import filledarrayBy from '../docs/types/index'; -export = filledarrayBy; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 468e99c..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"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 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 00888a2..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "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,EAAQ,UAAU,OAGbA,IAAU,EACd,OAAAE,EAAOrB,EAAOS,CAAc,EACrB,IAAIY,EAAM,CAAE,EAIpB,GADAD,EAAQ,UAAW,CAAE,EAChB1B,EAAU0B,CAAM,EAAI,CAExB,GAAKD,EAAQ,EACZ,MAAM,IAAI,UAAW,2FAA4F,EAGlH,GADAE,EAAOrB,EAAOoB,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWd,EAAQ,sEAAuEa,CAAM,CAAE,EAG7G,OAAO,IAAIC,EAAM,CAAE,CACpB,CAEA,GAAKF,EAAQ,EACZ,MAAM,IAAI,UAAW,2FAA4F,EAMlH,GAHAA,GAAS,EAGJpB,EAAY,UAAWoB,CAAM,CAAE,EAEnC,GAAKpB,EAAY,UAAWoB,EAAM,CAAE,CAAE,GAMrC,GALAN,EAAU,UAAWM,CAAM,EAC3BA,GAAS,EACTP,EAAO,UAAWO,CAAM,EAGnBA,IAAU,EACd,MAAM,IAAI,UAAW,2FAA4F,OAIlHP,EAAO,UAAWO,CAAM,UAIhBA,GAAS,GAIlB,GAHAN,EAAU,UAAWM,CAAM,EAC3BA,GAAS,EACTP,EAAO,UAAWO,CAAM,EACnB,CAACpB,EAAYa,CAAK,EACtB,MAAM,IAAI,UAAWL,EAAQ,uEAAwEK,CAAK,CAAE,MAK7G,OAAM,IAAI,UAAW,2FAA4F,EAWlH,GARAO,GAAS,EACJA,GAAS,GAAKzB,EAAU,UAAWyB,CAAM,CAAE,GAC/CC,EAAQ,UAAWD,CAAM,EACzBA,GAAS,GAETC,EAAQX,EAETY,EAAOrB,EAAOoB,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWd,EAAQ,sEAAuEa,CAAM,CAAE,EAG7G,GAAKA,IAAU,UAAY,CAE1B,GADAG,EAAM,UAAW,CAAE,EACdJ,IAAU,EAAI,CAMlB,GALKxB,EAAsB4B,CAAI,EAC9BD,EAAMC,EACK3B,EAAc2B,CAAI,IAC7BD,EAAMC,EAAI,QAEND,IAAQ,OACZ,OAAOpB,EAAaoB,EAAKV,EAAMC,CAAQ,EAExC,GAAKhB,EAAe0B,CAAI,EACvB,MAAM,IAAI,MAAO,mFAAoF,EAEtG,GAAKzB,EAAUyB,CAAI,EAAI,CACtB,GAAKf,IAAwB,GAC5B,MAAM,IAAI,UAAWD,EAAQ,sIAAuIgB,CAAI,CAAE,EAE3K,GAAK,CAACxB,EAAYwB,EAAKnB,CAAgB,CAAE,EACxC,MAAM,IAAI,UAAWG,EAAQ,wGAAyGgB,CAAI,CAAE,EAG7I,GADAA,EAAMA,EAAKnB,CAAgB,EAAE,EACxB,CAACL,EAAYwB,EAAI,IAAK,EAC1B,MAAM,IAAI,UAAWhB,EAAQ,wGAAyGgB,CAAI,CAAE,EAE7I,OAAOb,EAAqBa,EAAKX,EAAMC,CAAQ,CAChD,CACA,MAAM,IAAI,UAAWN,EAAQ,wGAAyGgB,CAAI,CAAE,CAC7I,SAAY1B,EAAe0B,CAAI,EAC9B,MAAM,IAAI,MAAO,mFAAoF,EAEtG,MAAM,IAAI,UAAWhB,EAAQ,wGAAyGgB,CAAI,CAAE,CAC7I,CACA,GAAKJ,IAAU,EAEd,GADAI,EAAM,UAAW,CAAE,EACd3B,EAAc2B,CAAI,EACtBT,EAAM,IAAIO,EAAME,EAAI,MAAO,UAChB1B,EAAe0B,CAAI,EAC9BT,EAAM,IAAIO,EAAME,CAAI,UACT5B,EAAsB4B,CAAI,EACrCT,EAAM,IAAIO,EAAME,CAAI,UACTzB,EAAUyB,CAAI,EAAI,CAC7B,GAAKf,IAAwB,GAC5B,MAAM,IAAI,UAAWD,EAAQ,sIAAuIgB,CAAI,CAAE,EAE3K,GAAK,CAACxB,EAAYwB,EAAKnB,CAAgB,CAAE,EACxC,MAAM,IAAI,UAAWG,EAAQ,wGAAyGgB,CAAI,CAAE,EAG7I,GADAA,EAAMA,EAAKnB,CAAgB,EAAE,EACxB,CAACL,EAAYwB,EAAI,IAAK,EAC1B,MAAM,IAAI,UAAWhB,EAAQ,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"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 5a68984..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,174 +0,0 @@ - -{{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) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr = {{alias}}() - - > arr = {{alias}}( 'float32' ) - - - -{{alias}}( length[, dtype], clbk[, thisArg] ) - Returns a filled array according to a provided callback function and having - a specified length. - - Parameters - ---------- - length: integer - Array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > function clbk() { return 1.0; }; - > var arr = {{alias}}( 5, clbk ) - [ 1.0, 1.0, 1.0, 1.0, 1.0 ] - > arr = {{alias}}( 5, 'int32', clbk ) - [ 1, 1, 1, 1, 1 ] - - -{{alias}}( array[, dtype], clbk[, thisArg] ) - Creates a filled array from another array (or array-like object) according - to a provided callback function. - - Parameters - ---------- - array: ArrayLikeObject - Array from which to generate another array. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias}}( [ 0.5, 0.5, 0.5 ], {{alias:@stdlib/utils/constant-function}}( 2.0 ) ) - [ 2.0, 2.0, 2.0 ] - > var arr2 = {{alias}}( arr1, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( iterable[, dtype], clbk[, thisArg] ) - Creates a filled array from an iterable according to a provided callback - function. - - Parameters - ---------- - iterable: Iterable - Iterable from which to generate an array. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias:@stdlib/iter/constant}}( 3.0, {'iter': 3} ); - > var arr2 = {{alias}}( arr1, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( buffer[, byteOffset[, length]][, dtype], clbk[, thisArg] ) - Returns a filled typed array view of an ArrayBuffer according to a provided - callback function. - - The 'generic' array data type is *not* supported. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( buf, 0, 4, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0, 1.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 394ac49..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,606 +0,0 @@ -/* -* @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. -*/ - -/// - -import { IterableIterator } from '@stdlib/types/iter'; -import filledarrayBy = require( './index' ); - - -/** -* Returns an iterator protocol-compliant object. -* -* @returns iterator protocol-compliant object -*/ -function iterator(): IterableIterator { - const obj: IterableIterator = { - [Symbol.iterator]: iterator, - 'next': next - }; - return obj; -} - -/** -* Implements the iterator protocol `next` method. -* -* @returns iterator protocol-compliant object -*/ -function next(): any { - return { - 'value': 1.0, - 'done': false - }; -} - -/** -* Callback function. -* -* @param i - current array index -* @returns return value -*/ -function clbk( i: number ): number { - return i; -} - - -// TESTS // - -// The function returns an array or typed array... -{ - filledarrayBy(); // $ExpectType ArrayOrTypedArray - filledarrayBy( 'float32' ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( 10, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( 10, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( 10, 'int32', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( 10, 'int32', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const x = new Float64Array( 10 ); - filledarrayBy( x, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( x, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( x, 'uint8', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( x, 'uint8', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const y = [ 2.0, 2.0, 2.0 ]; - filledarrayBy( y, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( y, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( y, 'float64', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( y, 'float64', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const it = iterator(); - filledarrayBy( it, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( it, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( it, 'uint8c', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( it, 'uint8c', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const buf = new ArrayBuffer( 32 ); - filledarrayBy( buf, clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 'uint32', clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 'uint32', clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 8, clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 8, clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 8, 'uint16', clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 8, 'uint16', clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 8, 2, clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 8, 2, clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 8, 2, 'int16', clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 8, 2, 'int16', clbk, {} ); // $ExpectType RealOrComplexTypedArray -} - -// The compiler throws an error if a callback function argument is not a function... -{ - filledarrayBy( 'float64', '5' ); // $ExpectError - filledarrayBy( 'float64', 1.0 ); // $ExpectError - filledarrayBy( 'float64', false ); // $ExpectError - filledarrayBy( 'float64', true ); // $ExpectError - filledarrayBy( 'float64', null ); // $ExpectError - filledarrayBy( 'float64', undefined ); // $ExpectError - filledarrayBy( 'float64', [] ); // $ExpectError - filledarrayBy( 'float64', {} ); // $ExpectError - - filledarrayBy( 'float64', '5', {} ); // $ExpectError - filledarrayBy( 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( 'float64', false, {} ); // $ExpectError - filledarrayBy( 'float64', true, {} ); // $ExpectError - filledarrayBy( 'float64', null, {} ); // $ExpectError - filledarrayBy( 'float64', undefined, {} ); // $ExpectError - filledarrayBy( 'float64', [], {} ); // $ExpectError - filledarrayBy( 'float64', {}, {} ); // $ExpectError - - filledarrayBy( 10, '5' ); // $ExpectError - filledarrayBy( 10, 1.0 ); // $ExpectError - filledarrayBy( 10, false ); // $ExpectError - filledarrayBy( 10, true ); // $ExpectError - filledarrayBy( 10, null ); // $ExpectError - filledarrayBy( 10, undefined ); // $ExpectError - filledarrayBy( 10, [] ); // $ExpectError - filledarrayBy( 10, {} ); // $ExpectError - - filledarrayBy( 10, '5', {} ); // $ExpectError - filledarrayBy( 10, 1.0, {} ); // $ExpectError - filledarrayBy( 10, false, {} ); // $ExpectError - filledarrayBy( 10, true, {} ); // $ExpectError - filledarrayBy( 10, null, {} ); // $ExpectError - filledarrayBy( 10, undefined, {} ); // $ExpectError - filledarrayBy( 10, [], {} ); // $ExpectError - filledarrayBy( 10, {}, {} ); // $ExpectError - - filledarrayBy( 10, 'float64', '5' ); // $ExpectError - filledarrayBy( 10, 'float64', 1.0 ); // $ExpectError - filledarrayBy( 10, 'float64', false ); // $ExpectError - filledarrayBy( 10, 'float64', true ); // $ExpectError - filledarrayBy( 10, 'float64', null ); // $ExpectError - filledarrayBy( 10, 'float64', undefined ); // $ExpectError - filledarrayBy( 10, 'float64', [] ); // $ExpectError - filledarrayBy( 10, 'float64', {} ); // $ExpectError - - filledarrayBy( 10, 'float64', '5', {} ); // $ExpectError - filledarrayBy( 10, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( 10, 'float64', false, {} ); // $ExpectError - filledarrayBy( 10, 'float64', true, {} ); // $ExpectError - filledarrayBy( 10, 'float64', null, {} ); // $ExpectError - filledarrayBy( 10, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( 10, 'float64', [], {} ); // $ExpectError - filledarrayBy( 10, 'float64', {}, {} ); // $ExpectError - - const x = new Float64Array( 10 ); - filledarrayBy( x, '5' ); // $ExpectError - filledarrayBy( x, 1.0 ); // $ExpectError - filledarrayBy( x, false ); // $ExpectError - filledarrayBy( x, true ); // $ExpectError - filledarrayBy( x, null ); // $ExpectError - filledarrayBy( x, undefined ); // $ExpectError - filledarrayBy( x, [] ); // $ExpectError - filledarrayBy( x, {} ); // $ExpectError - - filledarrayBy( x, '5', {} ); // $ExpectError - filledarrayBy( x, 1.0, {} ); // $ExpectError - filledarrayBy( x, false, {} ); // $ExpectError - filledarrayBy( x, true, {} ); // $ExpectError - filledarrayBy( x, null, {} ); // $ExpectError - filledarrayBy( x, undefined, {} ); // $ExpectError - filledarrayBy( x, [], {} ); // $ExpectError - filledarrayBy( x, {}, {} ); // $ExpectError - - filledarrayBy( x, 'float64', '5' ); // $ExpectError - filledarrayBy( x, 'float64', 1.0 ); // $ExpectError - filledarrayBy( x, 'float64', false ); // $ExpectError - filledarrayBy( x, 'float64', true ); // $ExpectError - filledarrayBy( x, 'float64', null ); // $ExpectError - filledarrayBy( x, 'float64', undefined ); // $ExpectError - filledarrayBy( x, 'float64', [] ); // $ExpectError - filledarrayBy( x, 'float64', {} ); // $ExpectError - - filledarrayBy( x, 'float64', '5', {} ); // $ExpectError - filledarrayBy( x, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( x, 'float64', false, {} ); // $ExpectError - filledarrayBy( x, 'float64', true, {} ); // $ExpectError - filledarrayBy( x, 'float64', null, {} ); // $ExpectError - filledarrayBy( x, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( x, 'float64', [], {} ); // $ExpectError - filledarrayBy( x, 'float64', {}, {} ); // $ExpectError - - const y = [ 2.0, 2.0, 2.0 ]; - filledarrayBy( y, '5' ); // $ExpectError - filledarrayBy( y, 1.0 ); // $ExpectError - filledarrayBy( y, false ); // $ExpectError - filledarrayBy( y, true ); // $ExpectError - filledarrayBy( y, null ); // $ExpectError - filledarrayBy( y, undefined ); // $ExpectError - filledarrayBy( y, [] ); // $ExpectError - filledarrayBy( y, {} ); // $ExpectError - - filledarrayBy( y, '5', {} ); // $ExpectError - filledarrayBy( y, 1.0, {} ); // $ExpectError - filledarrayBy( y, false, {} ); // $ExpectError - filledarrayBy( y, true, {} ); // $ExpectError - filledarrayBy( y, null, {} ); // $ExpectError - filledarrayBy( y, undefined, {} ); // $ExpectError - filledarrayBy( y, [], {} ); // $ExpectError - filledarrayBy( y, {}, {} ); // $ExpectError - - filledarrayBy( y, 'float64', '5' ); // $ExpectError - filledarrayBy( y, 'float64', 1.0 ); // $ExpectError - filledarrayBy( y, 'float64', false ); // $ExpectError - filledarrayBy( y, 'float64', true ); // $ExpectError - filledarrayBy( y, 'float64', null ); // $ExpectError - filledarrayBy( y, 'float64', undefined ); // $ExpectError - filledarrayBy( y, 'float64', [] ); // $ExpectError - filledarrayBy( y, 'float64', {} ); // $ExpectError - - filledarrayBy( y, 'float64', '5', {} ); // $ExpectError - filledarrayBy( y, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( y, 'float64', false, {} ); // $ExpectError - filledarrayBy( y, 'float64', true, {} ); // $ExpectError - filledarrayBy( y, 'float64', null, {} ); // $ExpectError - filledarrayBy( y, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( y, 'float64', [], {} ); // $ExpectError - filledarrayBy( y, 'float64', {}, {} ); // $ExpectError - - const it = iterator(); - filledarrayBy( it, '5' ); // $ExpectError - filledarrayBy( it, 1.0 ); // $ExpectError - filledarrayBy( it, false ); // $ExpectError - filledarrayBy( it, true ); // $ExpectError - filledarrayBy( it, null ); // $ExpectError - filledarrayBy( it, undefined ); // $ExpectError - filledarrayBy( it, [] ); // $ExpectError - filledarrayBy( it, {} ); // $ExpectError - - filledarrayBy( it, '5', {} ); // $ExpectError - filledarrayBy( it, 1.0, {} ); // $ExpectError - filledarrayBy( it, false, {} ); // $ExpectError - filledarrayBy( it, true, {} ); // $ExpectError - filledarrayBy( it, null, {} ); // $ExpectError - filledarrayBy( it, undefined, {} ); // $ExpectError - filledarrayBy( it, [], {} ); // $ExpectError - filledarrayBy( it, {}, {} ); // $ExpectError - - filledarrayBy( it, 'float64', '5' ); // $ExpectError - filledarrayBy( it, 'float64', 1.0 ); // $ExpectError - filledarrayBy( it, 'float64', false ); // $ExpectError - filledarrayBy( it, 'float64', true ); // $ExpectError - filledarrayBy( it, 'float64', null ); // $ExpectError - filledarrayBy( it, 'float64', undefined ); // $ExpectError - filledarrayBy( it, 'float64', [] ); // $ExpectError - filledarrayBy( it, 'float64', {} ); // $ExpectError - - filledarrayBy( it, 'float64', '5', {} ); // $ExpectError - filledarrayBy( it, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( it, 'float64', false, {} ); // $ExpectError - filledarrayBy( it, 'float64', true, {} ); // $ExpectError - filledarrayBy( it, 'float64', null, {} ); // $ExpectError - filledarrayBy( it, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( it, 'float64', [], {} ); // $ExpectError - filledarrayBy( it, 'float64', {}, {} ); // $ExpectError - - const buf = new ArrayBuffer( 32 ); - filledarrayBy( buf, '5' ); // $ExpectError - filledarrayBy( buf, 1.0 ); // $ExpectError - filledarrayBy( buf, false ); // $ExpectError - filledarrayBy( buf, true ); // $ExpectError - filledarrayBy( buf, null ); // $ExpectError - filledarrayBy( buf, undefined ); // $ExpectError - filledarrayBy( buf, [] ); // $ExpectError - filledarrayBy( buf, {} ); // $ExpectError - - filledarrayBy( buf, '5', {} ); // $ExpectError - filledarrayBy( buf, 1.0, {} ); // $ExpectError - filledarrayBy( buf, false, {} ); // $ExpectError - filledarrayBy( buf, true, {} ); // $ExpectError - filledarrayBy( buf, null, {} ); // $ExpectError - filledarrayBy( buf, undefined, {} ); // $ExpectError - filledarrayBy( buf, [], {} ); // $ExpectError - filledarrayBy( buf, {}, {} ); // $ExpectError - - filledarrayBy( buf, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 'float64', false ); // $ExpectError - filledarrayBy( buf, 'float64', true ); // $ExpectError - filledarrayBy( buf, 'float64', null ); // $ExpectError - filledarrayBy( buf, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 'float64', {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5' ); // $ExpectError - filledarrayBy( buf, 8, 1.0 ); // $ExpectError - filledarrayBy( buf, 8, false ); // $ExpectError - filledarrayBy( buf, 8, true ); // $ExpectError - filledarrayBy( buf, 8, null ); // $ExpectError - filledarrayBy( buf, 8, undefined ); // $ExpectError - filledarrayBy( buf, 8, [] ); // $ExpectError - filledarrayBy( buf, 8, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, false, {} ); // $ExpectError - filledarrayBy( buf, 8, true, {} ); // $ExpectError - filledarrayBy( buf, 8, null, {} ); // $ExpectError - filledarrayBy( buf, 8, undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, [], {} ); // $ExpectError - filledarrayBy( buf, 8, {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 8, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 'float64', false ); // $ExpectError - filledarrayBy( buf, 8, 'float64', true ); // $ExpectError - filledarrayBy( buf, 8, 'float64', null ); // $ExpectError - filledarrayBy( buf, 8, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 8, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 8, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 8, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, '5' ); // $ExpectError - filledarrayBy( buf, 8, 2, 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 2, false ); // $ExpectError - filledarrayBy( buf, 8, 2, true ); // $ExpectError - filledarrayBy( buf, 8, 2, null ); // $ExpectError - filledarrayBy( buf, 8, 2, undefined ); // $ExpectError - filledarrayBy( buf, 8, 2, [] ); // $ExpectError - filledarrayBy( buf, 8, 2, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, false, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, true, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, null, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, [], {} ); // $ExpectError - filledarrayBy( buf, 8, 2, {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', false ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', true ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', null ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', {}, {} ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid length, typed array, array-like object, `ArrayBuffer`, or iterable argument... -{ - filledarrayBy( false, clbk ); // $ExpectError - filledarrayBy( true, clbk ); // $ExpectError - filledarrayBy( null, clbk ); // $ExpectError - filledarrayBy( {}, clbk ); // $ExpectError - - filledarrayBy( false, clbk, {} ); // $ExpectError - filledarrayBy( true, clbk, {} ); // $ExpectError - filledarrayBy( null, clbk, {} ); // $ExpectError - filledarrayBy( {}, clbk, {} ); // $ExpectError - - filledarrayBy( false, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 'float64', clbk ); // $ExpectError - - filledarrayBy( false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, clbk ); // $ExpectError - filledarrayBy( 1.0, 8, clbk ); // $ExpectError - filledarrayBy( false, 8, clbk ); // $ExpectError - filledarrayBy( true, 8, clbk ); // $ExpectError - filledarrayBy( null, 8, clbk ); // $ExpectError - filledarrayBy( undefined, 8, clbk ); // $ExpectError - filledarrayBy( [], 8, clbk ); // $ExpectError - filledarrayBy( {}, 8, clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, clbk ); // $ExpectError - - filledarrayBy( '5', 8, clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, clbk, {} ); // $ExpectError - filledarrayBy( false, 8, clbk, {} ); // $ExpectError - filledarrayBy( true, 8, clbk, {} ); // $ExpectError - filledarrayBy( null, 8, clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, clbk, {} ); // $ExpectError - filledarrayBy( [], 8, clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 'float64', clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( false, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( [], 8, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 'float64', clbk ); // $ExpectError - - filledarrayBy( '5', 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 2, clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 2, clbk ); // $ExpectError - filledarrayBy( false, 8, 2, clbk ); // $ExpectError - filledarrayBy( true, 8, 2, clbk ); // $ExpectError - filledarrayBy( null, 8, 2, clbk ); // $ExpectError - filledarrayBy( undefined, 8, 2, clbk ); // $ExpectError - filledarrayBy( [], 8, 2, clbk ); // $ExpectError - filledarrayBy( {}, 8, 2, clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, clbk ); // $ExpectError - - filledarrayBy( '5', 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( false, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( [], 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, 'float64', clbk ); // $ExpectError - - filledarrayBy( '5', 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a byte offset argument which is not a number... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, false, clbk ); // $ExpectError - filledarrayBy( buf, true, clbk ); // $ExpectError - filledarrayBy( buf, null, clbk ); // $ExpectError - filledarrayBy( buf, [], clbk ); // $ExpectError - filledarrayBy( buf, {}, clbk ); // $ExpectError - - filledarrayBy( buf, false, clbk, {} ); // $ExpectError - filledarrayBy( buf, true, clbk, {} ); // $ExpectError - filledarrayBy( buf, null, clbk, {} ); // $ExpectError - filledarrayBy( buf, [], clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, clbk, {} ); // $ExpectError - - filledarrayBy( buf, '5', 'float64', clbk ); // $ExpectError - filledarrayBy( buf, false, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, true, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, null, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, [], 'float64', clbk ); // $ExpectError - filledarrayBy( buf, {}, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, '5', 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( buf, false, 2, clbk ); // $ExpectError - filledarrayBy( buf, true, 2, clbk ); // $ExpectError - filledarrayBy( buf, null, 2, clbk ); // $ExpectError - filledarrayBy( buf, [], 2, clbk ); // $ExpectError - filledarrayBy( buf, {}, 2, clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, clbk ); // $ExpectError - - filledarrayBy( buf, false, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, clbk, {} ); // $ExpectError - - filledarrayBy( buf, '5', 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, false, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, true, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, null, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, undefined, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, [], 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, {}, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, '5', 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, false, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, undefined, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a view length argument which is not a number... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, 8, false, clbk ); // $ExpectError - filledarrayBy( buf, 8, true, clbk ); // $ExpectError - filledarrayBy( buf, 8, null, clbk ); // $ExpectError - filledarrayBy( buf, 8, [], clbk ); // $ExpectError - filledarrayBy( buf, 8, {}, clbk ); // $ExpectError - - filledarrayBy( buf, 8, false, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, true, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, null, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, [], clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, {}, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, clbk, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5', 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, false, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, true, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, null, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, [], 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, {}, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, 8, '5', 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, [], 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, {}, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided too many arguments... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, 8, 2, 'float64', 1, clbk, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 997a381..0000000 --- a/examples/index.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ).factory; -var dtypes = require( '@stdlib/array-typed-real-dtypes' ); -var filledarrayBy = require( './../lib' ); - -// Create a pseudorandom number generator: -var rand = discreteUniform( 0, 100 ); - -// Get a list of array data types: -var dt = dtypes(); - -// Generate filled arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = filledarrayBy( 10, dt[ i ], rand ); - console.log( arr ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index b1fd829..e1b94a1 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, RealOrComplexTypedArray, DataType } from '@stdlib/types/array'; import { IterableIterator } from '@stdlib/types/iter'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..56b3976 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.1-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-ctors@v0.2.1-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill-by@v0.2.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled-by@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.2.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.1-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@v0.2.1-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.2.1-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";var j=d(),a=p.get("dtypes.default");function v(){var d,p,v,c,g,y,b,u;if(0===(p=arguments.length))return new(g=o(a))(0);if(r(v=arguments[0])){if(p>1)throw new TypeError(w("00h05"));if(null===(g=o(v)))throw new TypeError(w("00h2Y",v));return new g(0)}if(p<2)throw new TypeError(w("00h05"));if(n(arguments[p-=1]))if(n(arguments[p-1])){if(d=arguments[p],c=arguments[p-=1],0===p)throw new TypeError(w("00h05"))}else c=arguments[p];else{if(!(p>=2))throw new TypeError(w("00h05"));if(d=arguments[p],!n(c=arguments[p-=1]))throw new TypeError(w("00h2b",c))}if((p-=1)>=0&&r(arguments[p])?(v=arguments[p],p-=1):v=a,null===(g=o(v)))throw new TypeError(w("00h2Y",v));if("generic"===v){if(u=arguments[0],0===p){if(e(u)?b=u:t(u)&&(b=u.length),void 0!==b)return l(b,c,d);if(s(u))throw new Error(w("00h04"));if(i(u)){if(!1===j)throw new TypeError(w("00h2Z",u));if(!n(u[m]))throw new TypeError(w("00h2a",u));if(u=u[m](),!n(u.next))throw new TypeError(w("00h2a",u));return function(r,e,t){var s,i;for(s=[],i=-1;!r.next().done;)i+=1,s.push(e.call(t,i));return s}(u,c,d)}throw new TypeError(w("00h2a",u))}if(s(u))throw new Error(w("00h04"));throw new TypeError(w("00h2a",u))}if(0===p)if(t(u=arguments[0]))y=new g(u.length);else if(s(u))y=new g(u);else if(e(u))y=new g(u);else{if(!i(u))throw new TypeError(w("00h2a",u));if(!1===j)throw new TypeError(w("00h2Z",u));if(!n(u[m]))throw new TypeError(w("00h2a",u));if(u=u[m](),!n(u.next))throw new TypeError(w("00h2a",u));y=new g(f(u))}else y=1===p?new g(arguments[0],arguments[1]):new g(arguments[0],arguments[1],arguments[2]);return y.length>0&&(/^complex/.test(v)?function(r,e,t){var s;for(s=0;s\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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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( format('00h05') );\n\t\t}\n\t\tctor = ctors( dtype );\n\t\tif ( ctor === null ) {\n\t\t\tthrow new TypeError( format( '00h2Y', 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( format('00h05') );\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( format('00h05') );\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( '00h2b', 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( format('00h05') );\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( '00h2Y', 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( format('00h04') );\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( '00h2Z', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00h2a', 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( '00h2a', 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( '00h2a', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format('00h04') );\n\t\t}\n\t\tthrow new TypeError( format( '00h2a', 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( '00h2Z', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00h2a', 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( '00h2a', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00h2a', 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\nexport default filledarrayBy;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","DEFAULT_DTYPE","defaults","get","filledarrayBy","thisArg","nargs","dtype","clbk","ctor","arr","len","arg","arguments","length","ctors","isString","TypeError","format","isFunction","isNonNegativeInteger","isCollection","filledArray","isArrayBuffer","Error","isObject","ITERATOR_SYMBOL","next","it","i","done","push","call","filledArrayIterator","iterLength","test","set","filledAccessors","gfillBy","value","aidx"],"mappings":";;q0CAwCA,IAAIA,EAAsBC,IACtBC,EAAgBC,EAASC,IAAK,kBA2MlC,SAASC,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAKJ,GAAe,KAHfN,EAAQO,UAAUC,QAKjB,OAAO,IADPL,EAAOM,EAAOd,IACG,GAIlB,GAAKe,EADLT,EAAQM,UAAW,IACM,CAExB,GAAKP,EAAQ,EACZ,MAAM,IAAIW,UAAWC,EAAO,UAG7B,GAAc,QADdT,EAAOM,EAAOR,IAEb,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,OAAO,IAAIE,EAAM,EACjB,CAED,GAAKH,EAAQ,EACZ,MAAM,IAAIW,UAAWC,EAAO,UAM7B,GAAKC,EAAYN,UAHjBP,GAAS,IAKR,GAAKa,EAAYN,UAAWP,EAAM,KAMjC,GALAD,EAAUQ,UAAWP,GAErBE,EAAOK,UADPP,GAAS,GAIM,IAAVA,EACJ,MAAM,IAAIW,UAAWC,EAAO,eAI7BV,EAAOK,UAAWP,OAIf,MAAKA,GAAS,GAUlB,MAAM,IAAIW,UAAWC,EAAO,UAN5B,GAHAb,EAAUQ,UAAWP,IAGfa,EADNX,EAAOK,UADPP,GAAS,IAGR,MAAM,IAAIW,UAAWC,EAAQ,QAASV,GAMvC,CAUD,IARAF,GAAS,IACK,GAAKU,EAAUH,UAAWP,KACvCC,EAAQM,UAAWP,GACnBA,GAAS,GAETC,EAAQN,EAGK,QADdQ,EAAOM,EAAOR,IAEb,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,GAAe,YAAVA,EAAsB,CAE1B,GADAK,EAAMC,UAAW,GACF,IAAVP,EAAc,CAMlB,GALKc,EAAsBR,GAC1BD,EAAMC,EACKS,EAAcT,KACzBD,EAAMC,EAAIE,aAEE,IAARH,EACJ,OAAOW,EAAaX,EAAKH,EAAMH,GAEhC,GAAKkB,EAAeX,GACnB,MAAM,IAAIY,MAAON,EAAO,UAEzB,GAAKO,EAAUb,GAAQ,CACtB,IAA6B,IAAxBb,EACJ,MAAM,IAAIkB,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAYP,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLP,EAAYP,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvC,OAvSJ,SAA8BgB,EAAIpB,EAAMH,GACvC,IAAIK,EACAmB,EAKJ,IAFAnB,EAAM,GACNmB,GAAK,GAEAD,EAAGD,OACAG,MAGPD,GAAK,EACLnB,EAAIqB,KAAMvB,EAAKwB,KAAM3B,EAASwB,IAE/B,OAAOnB,CACR,CAuRWuB,CAAqBrB,EAAKJ,EAAMH,EACvC,CACD,MAAM,IAAIY,UAAWC,EAAQ,QAASN,GACzC,CAAS,GAAKW,EAAeX,GAC1B,MAAM,IAAIY,MAAON,EAAO,UAEzB,MAAM,IAAID,UAAWC,EAAQ,QAASN,GACtC,CACD,GAAe,IAAVN,EAEJ,GAAKe,EADLT,EAAMC,UAAW,IAEhBH,EAAM,IAAID,EAAMG,EAAIE,aACd,GAAKS,EAAeX,GAC1BF,EAAM,IAAID,EAAMG,QACV,GAAKQ,EAAsBR,GACjCF,EAAM,IAAID,EAAMG,OACV,KAAKa,EAAUb,GAarB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAZtC,IAA6B,IAAxBb,EACJ,MAAM,IAAIkB,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAYP,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLP,EAAYP,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvCF,EAAM,IAAID,EAAMyB,EAAYtB,GAG5B,MAEDF,EADqB,IAAVJ,EACL,IAAIG,EAAMI,UAAU,GAAIA,UAAU,IAElC,IAAIJ,EAAMI,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKH,EAAII,OAAS,IACZ,WAAWqB,KAAM5B,GAjTxB,SAA0BG,EAAKF,EAAMH,GACpC,IAAIwB,EACJ,IAAMA,EAAI,EAAGA,EAAInB,EAAII,OAAQe,IAC5BnB,EAAI0B,IAAK5B,EAAKwB,KAAM3B,EAASwB,GAAKA,EAGpC,CA4SGQ,CAAiB3B,EAAKF,EAAMH,GAE5BiC,EAAS5B,EAAII,OAAQJ,EAAK,GAe5B,SAAmB6B,EAAOC,GACzB,OAAOhC,EAAKwB,KAAM3B,EAASmC,EAC3B,KAdM9B,CAeR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d115cf0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,192 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -/** -* Create a filled array according to a provided callback function. -* -* @module @stdlib/array-filled-by -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* var arr = filledarrayBy(); -* // returns -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'generic', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( [ 0.5, 0.5 ], clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1; -* } -* -* var arr = filledarrayBy( [ 5, -3 ], 'int32', clbk ); -* // returns [ 1, 1 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk1() { -* return 10; -* } -* -* function clbk2() { -* return 1.0; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, clbk2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk1() { -* return 1.0; -* } -* -* function clbk2() { -* return 2; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, 'uint32', clbk2 ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 'float32', clbk ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, clbk ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, 'int32', clbk ); -* // returns [ 1, 1 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 06bc8b6..0000000 --- a/lib/main.js +++ /dev/null @@ -1,414 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var isCollection = require( '@stdlib/assert-is-collection' ); -var isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isObject = require( '@stdlib/assert-is-object' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var ctors = require( '@stdlib/array-ctors' ); -var gfillBy = require( '@stdlib/blas-ext-base-gfill-by' ); -var filledArray = require( '@stdlib/array-base-filled-by' ); -var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var iterLength = require( '@stdlib/iter-length' ); -var defaults = require( '@stdlib/array-defaults' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport(); -var DEFAULT_DTYPE = defaults.get( 'dtypes.default' ); - - -// FUNCTIONS // - -/** -* Creates a filled "generic" array from an iterator. -* -* @private -* @param {Iterable} it - iterator -* @param {Callback} clbk - callback function -* @param {*} thisArg - callback function execution context -* @returns {Array} filled array -*/ -function filledArrayIterator( it, clbk, thisArg ) { - var arr; - var i; - var v; - - arr = []; - i = -1; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - i += 1; - arr.push( clbk.call( thisArg, i ) ); - } - return arr; -} - -/** -* Fills an array exposing accessors for getting and setting array elements. -* -* @private -* @param {Collection} arr - input array -* @param {Callback} clbk - callback function -* @param {*} thisArg - callback function execution context -* @returns {Collection} input array -*/ -function filledAccessors( arr, clbk, thisArg ) { - var i; - for ( i = 0; i < arr.length; i++ ) { - arr.set( clbk.call( thisArg, i ), i ); - } - return arr; -} - - -// MAIN // - -/** -* Creates a filled array according to a provided callback function. -* -* @param {(NonNegativeInteger|TypedArray|ArrayLikeObject|ArrayBuffer|Iterable)} [arg] - a length, typed array, array-like object, buffer, or iterable -* @param {NonNegativeInteger} [byteOffset=0] - byte offset -* @param {NonNegativeInteger} [length] - view length -* @param {string} [dtype="float64"] - data type -* @param {Callback} [clbk] - callback to invoke -* @param {*} [thisArg] - callback execution context -* @throws {TypeError} must provide a recognized data type -* @throws {TypeError} must provide a length, typed array, array-like object, buffer, or iterable -* @throws {TypeError} callback argument must be a function. -* @throws {Error} creating a generic array from an `ArrayBuffer` is not supported -* @returns {(TypedArray|Array)} array or typed array -* -* @example -* var arr = filledarrayBy(); -* // returns -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'generic', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( [ 0.5, 0.5 ], clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1; -* } -* -* var arr = filledarrayBy( [ 5, -3 ], 'int32', clbk ); -* // returns [ 1, 1 ] -* -* @example -* function clbk1() { -* return 10; -* } -* -* function clbk2() { -* return 1.0; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, clbk2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk1() { -* return 1.0; -* } -* -* function clbk2() { -* return 2; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, 'uint32', clbk2 ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 'float32', clbk ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, clbk ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, 'int32', clbk ); -* // returns [ 1, 1 ] -*/ -function filledarrayBy() { - var thisArg; - var nargs; - var dtype; - var clbk; - var ctor; - var arr; - var len; - var arg; - - nargs = arguments.length; - - // If we weren't provided any arguments, return an empty array... - if ( nargs === 0 ) { - ctor = ctors( DEFAULT_DTYPE ); - return new ctor( 0 ); - } - // Check if we were provided a dtype as the first argument... - dtype = arguments[ 0 ]; - if ( isString( dtype ) ) { - // Invoking this function with arguments `f( dtype, clbk[, thisArg] )` is not allowed (otherwise, we'd need to also allow `f( clbk[, thisArg] )`)... - if ( nargs > 1 ) { - throw new TypeError( format('00h05') ); - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '00h2Y', dtype ) ); - } - // Return an empty array having the specified dtype: - return new ctor( 0 ); - } - // For all other supported invocations, we need at least two arguments... - if ( nargs < 2 ) { - throw new TypeError( format('00h05') ); - } - // At this point, we need to do some argument juggling... - nargs -= 1; // henceforth, the number of available arguments is `nargs+1` - - // Determine whether the last argument is a callback or "this" context... - if ( isFunction( arguments[ nargs ] ) ) { - // 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... - if ( isFunction( arguments[ nargs-1 ] ) ) { - thisArg = arguments[ nargs ]; - nargs -= 1; - clbk = arguments[ nargs ]; - - // Check if we were provided only a callback and a "this" context.. - if ( nargs === 0 ) { - throw new TypeError( format('00h05') ); - } - } else { - // "this" context is left undefined... - clbk = arguments[ nargs ]; - } - } - // 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... - else if ( nargs >= 2 ) { - thisArg = arguments[ nargs ]; - nargs -= 1; - clbk = arguments[ nargs ]; - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '00h2b', clbk ) ); - } - } - // If were were only provided 2 arguments and the last argument was not a function, we've been provided an insufficient number of arguments... - else { - throw new TypeError( format('00h05') ); - } - // Now that we've processed the callback arguments, let's continue working backward to see if we've been provided a `dtype` argument... - nargs -= 1; - if ( nargs >= 0 && isString( arguments[ nargs ] ) ) { - dtype = arguments[ nargs ]; - nargs -= 1; - } else { - dtype = DEFAULT_DTYPE; - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '00h2Y', dtype ) ); - } - // At this point, we've resolved the output array data type, and now we can actually create the output array... - if ( dtype === 'generic' ) { - arg = arguments[ 0 ]; - if ( nargs === 0 ) { - if ( isNonNegativeInteger( arg ) ) { - len = arg; - } else if ( isCollection( arg ) ) { - len = arg.length; - } - if ( len !== void 0 ) { - return filledArray( len, clbk, thisArg ); - } - if ( isArrayBuffer( arg ) ) { - throw new Error( format('00h04') ); - } - if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( '00h2Z', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00h2a', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00h2a', arg ) ); - } - return filledArrayIterator( arg, clbk, thisArg ); - } - throw new TypeError( format( '00h2a', arg ) ); - } else if ( isArrayBuffer( arg ) ) { - throw new Error( format('00h04') ); - } - throw new TypeError( format( '00h2a', arg ) ); - } - if ( nargs === 0 ) { // length || array-like || ArrayBuffer || iterable - arg = arguments[ 0 ]; - if ( isCollection( arg ) ) { - arr = new ctor( arg.length ); - } else if ( isArrayBuffer( arg ) ) { - arr = new ctor( arg ); - } else if ( isNonNegativeInteger( arg ) ) { - arr = new ctor( arg ); - } else if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( '00h2Z', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00h2a', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00h2a', arg ) ); - } - arr = new ctor( iterLength( arg ) ); - } else { - throw new TypeError( format( '00h2a', arg ) ); - } - } else if ( nargs === 1 ) { - arr = new ctor( arguments[0], arguments[1] ); // (ArrayBuffer, byteOffset) - } else { - arr = new ctor( arguments[0], arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset, length) - } - if ( arr.length > 0 ) { - if ( /^complex/.test( dtype ) ) { - filledAccessors( arr, clbk, thisArg ); - } else { - gfillBy( arr.length, arr, 1, callback ); - } - } - return arr; - - /** - * Callback which wraps a provided callback and is invoked for each array element. - * - * @private - * @param {*} value - element value - * @param {NonNegativeInteger} aidx - array index - * @param {NonNegativeInteger} sidx - strided index - * @param {Collection} array - input array/collection - * @returns {*} callback return value - */ - function callback( value, aidx ) { - return clbk.call( thisArg, aidx ); - } -} - - -// EXPORTS // - -module.exports = filledarrayBy; diff --git a/package.json b/package.json index 4e7e4b8..b16be36 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Create a filled array according to a provided callback function.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,71 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-filled-by": "^0.2.1", - "@stdlib/array-ctors": "^0.2.1", - "@stdlib/array-defaults": "^0.2.1", - "@stdlib/assert-has-iterator-symbol-support": "^0.2.1", - "@stdlib/assert-is-arraybuffer": "^0.2.1", - "@stdlib/assert-is-collection": "^0.2.1", - "@stdlib/assert-is-function": "^0.2.1", - "@stdlib/assert-is-nonnegative-integer": "^0.2.1", - "@stdlib/assert-is-object": "^0.2.1", - "@stdlib/assert-is-string": "^0.2.1", - "@stdlib/blas-ext-base-gfill-by": "^0.2.1", - "@stdlib/iter-length": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1", - "@stdlib/symbol-iterator": "^0.2.1", - "@stdlib/types": "^0.3.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/array-buffer": "^0.2.1", - "@stdlib/array-complex128": "^0.2.1", - "@stdlib/array-complex64": "^0.2.1", - "@stdlib/array-float32": "^0.2.1", - "@stdlib/array-float64": "^0.2.1", - "@stdlib/array-int16": "^0.2.1", - "@stdlib/array-int32": "^0.2.1", - "@stdlib/array-int8": "^0.2.1", - "@stdlib/array-typed-real-dtypes": "^0.2.1", - "@stdlib/array-uint16": "^0.2.1", - "@stdlib/array-uint32": "^0.2.1", - "@stdlib/array-uint8": "^0.2.1", - "@stdlib/array-uint8c": "^0.2.1", - "@stdlib/assert-instance-of": "^0.2.1", - "@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/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-complex128": "^0.2.1", - "@stdlib/strided-base-reinterpret-complex64": "^0.2.0", - "@stdlib/utils-constant-function": "^0.2.1", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.1" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..0fbbd35 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 59ff59f..0000000 --- a/test/test.js +++ /dev/null @@ -1,4248 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 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. -*/ - -/* eslint-disable max-len */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -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 ArrayBuffer = require( '@stdlib/array-buffer' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var Complex128 = require( '@stdlib/complex-float64-ctor' ); -var Complex64 = require( '@stdlib/complex-float32-ctor' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var iterConstant = require( '@stdlib/iter-constant' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var filledarrayBy = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': !hasIteratorSymbolSupport() -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof filledarrayBy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if only provided callback arguments', function test( t ) { - t.throws( clbk1, TypeError, 'throws an error' ); - t.throws( clbk2, TypeError, 'throws an error' ); - t.throws( clbk3, TypeError, 'throws an error' ); - t.end(); - - function clbk1() { - filledarrayBy( constantFunction( 1.0 ) ); - } - - function clbk2() { - filledarrayBy( constantFunction( 1.0 ), {} ); - } - - function clbk3() { - filledarrayBy( constantFunction( 1.0 ), constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (only argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (typed array; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (array-like object)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (array-like object; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 8 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 8 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, 1, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (iterator)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( iterConstant( 1.0 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (iterator; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( iterConstant( 1.0 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if only provided data type and callback arguments', function test( t ) { - t.throws( clbk1, TypeError, 'throws an error' ); - t.throws( clbk2, TypeError, 'throws an error' ); - t.throws( clbk3, TypeError, 'throws an error' ); - t.end(); - - function clbk1() { - filledarrayBy( 'float64', constantFunction( 1.0 ) ); - } - - function clbk2() { - filledarrayBy( 'float64', constantFunction( 1.0 ), {} ); - } - - function clbk3() { - filledarrayBy( 'float64', constantFunction( 1.0 ), constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (array-like object)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (array-like object; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, 1, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, 1, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (no iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (no iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (non-function iterator symbol property)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (non-function iterator symbol property; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (`next` property is not a function)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ) ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (`next` property is not a function; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ), {} ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (no iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (no iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (non-function iterator symbol property)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (non-function iterator symbol property; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (`next` property is not a function)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ) ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (`next` property is not a function; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ), {} ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 1, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 1, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function returns a filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - arr = filledarrayBy(); - - t.strictEqual( instanceOf( arr, Float64Array ), 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=float64)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - arr = filledarrayBy( 'float64' ); - - t.strictEqual( instanceOf( arr, Float64Array ), 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=float32)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( 0 ); - arr = filledarrayBy( 'float32' ); - - t.strictEqual( instanceOf( arr, Float32Array ), 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; - - expected = new Complex128Array( 0 ); - arr = filledarrayBy( 'complex128' ); - - t.strictEqual( instanceOf( arr, Complex128Array ), 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=complex64)', function test( t ) { - var expected; - var arr; - - expected = new Complex64Array( 0 ); - arr = filledarrayBy( 'complex64' ); - - t.strictEqual( instanceOf( arr, Complex64Array ), 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=int32)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( 0 ); - arr = filledarrayBy( 'int32' ); - - t.strictEqual( instanceOf( arr, Int32Array ), 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=uint32)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( 0 ); - arr = filledarrayBy( 'uint32' ); - - t.strictEqual( instanceOf( arr, Uint32Array ), 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=int16)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( 0 ); - arr = filledarrayBy( 'int16' ); - - t.strictEqual( instanceOf( arr, Int16Array ), 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=uint16)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( 0 ); - arr = filledarrayBy( 'uint16' ); - - t.strictEqual( instanceOf( arr, Uint16Array ), 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=int8)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( 0 ); - arr = filledarrayBy( 'int8' ); - - t.strictEqual( instanceOf( arr, Int8Array ), 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=uint8)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( 0 ); - arr = filledarrayBy( 'uint8' ); - - t.strictEqual( instanceOf( arr, Uint8Array ), 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=uint8c)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( 0 ); - arr = filledarrayBy( 'uint8c' ); - - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), 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=generic)', function test( t ) { - var expected; - var arr; - - expected = []; - arr = filledarrayBy( 'generic' ); - - t.strictEqual( instanceOf( arr, Array ), 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 (default, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, length=0)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array(); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 0, clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, clbk, ctx ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (default, length; thisArg=function)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, clbk, context ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this(); // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } - - function context() { - ctx.count += 1; - } -}); - -tape( 'the function returns a filled array (dtype=float64, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, 'float64', clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, length; thisArg=function)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, 'float64', clbk, context ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this(); // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } - - function context() { - ctx.count += 1; - } -}); - -tape( 'the function returns a filled array (dtype=float32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, 'float32', clbk ); - - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex128, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = filledarrayBy( 5, 'complex128', clbk ); - - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = filledarrayBy( 5, 'complex64', clbk ); - - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int32Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int32', clbk ); - - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint32Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint32', clbk ); - - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int16Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int16', clbk ); - - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint16', clbk ); - - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int8Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int8', clbk ); - - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint8', clbk ); - - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint8c', clbk ); - - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = [ 1, 1, 1, 1, 1 ]; - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'generic', clbk ); - - t.strictEqual( instanceOf( arr, Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex128, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = [ 1.0, 2.0 ]; - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = [ 1.0, 2.0 ]; - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int32', clbk ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, typed array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, typed array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex128, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = new Float64Array( [ 1.0, 2.0 ] ); - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = new Float64Array( [ 1.0, 2.0 ] ); - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (default, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex128, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer, byteoffset; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer, byteoffset; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, 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; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 48 ); - out = filledarrayBy( buf, 16, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 24 ); - out = filledarrayBy( buf, 8, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int32', clbk ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint8c', clbk ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, 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; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 64 ); - out = filledarrayBy( buf, 16, 2, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset, length)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 1, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 1, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled array (default, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, iterator; thisArg)', opts, function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - ctx = { - 'count': 0 - }; - indices = []; - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, iterator; thisArg)', opts, function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - ctx = { - 'count': 0 - }; - indices = []; - out = filledarrayBy( arr, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex128, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = iterConstant( new Complex128( 3.0, 3.0 ), { - 'iter': 2 - }); - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = iterConstant( new Complex64( 3.0, 3.0 ), { - 'iter': 2 - }); - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); From 55a5440c164597e2d9d74f8928ab3dbefcb1e01d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jul 2024 19:25:09 +0000 Subject: [PATCH 063/117] Transform error messages --- lib/main.js | 38 +++++++++++++++++++------------------- package.json | 2 +- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/lib/main.js b/lib/main.js index b322cfe..ed1aa9a 100644 --- a/lib/main.js +++ b/lib/main.js @@ -35,7 +35,7 @@ var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-supp var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); var iterLength = require( '@stdlib/iter-length' ); var defaults = require( '@stdlib/array-defaults' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -266,18 +266,18 @@ function filledarrayBy() { if ( isString( dtype ) ) { // Invoking this function with arguments `f( dtype, clbk[, thisArg] )` is not allowed (otherwise, we'd need to also allow `f( clbk[, thisArg] )`)... if ( nargs > 1 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format('00h05') ); } ctor = ctors( dtype ); if ( ctor === null ) { - throw new TypeError( format( 'invalid argument. Must provide a recognized data type. Value: `%s`.', dtype ) ); + throw new TypeError( format( '00h2Y', dtype ) ); } // Return an empty array having the specified dtype: return new ctor( 0 ); } // For all other supported invocations, we need at least two arguments... if ( nargs < 2 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format('00h05') ); } // At this point, we need to do some argument juggling... nargs -= 1; // henceforth, the number of available arguments is `nargs+1` @@ -292,7 +292,7 @@ function filledarrayBy() { // Check if we were provided only a callback and a "this" context.. if ( nargs === 0 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format('00h05') ); } } else { // "this" context is left undefined... @@ -305,12 +305,12 @@ function filledarrayBy() { nargs -= 1; clbk = arguments[ nargs ]; if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '00h2b', clbk ) ); } } // If were were only provided 2 arguments and the last argument was not a function, we've been provided an insufficient number of arguments... else { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format('00h05') ); } // Now that we've processed the callback arguments, let's continue working backward to see if we've been provided a `dtype` argument... nargs -= 1; @@ -322,7 +322,7 @@ function filledarrayBy() { } ctor = ctors( dtype ); if ( ctor === null ) { - throw new TypeError( format( 'invalid argument. Must provide a recognized data type. Value: `%s`.', dtype ) ); + throw new TypeError( format( '00h2Y', dtype ) ); } // At this point, we've resolved the output array data type, and now we can actually create the output array... if ( dtype === 'generic' ) { @@ -337,26 +337,26 @@ function filledarrayBy() { return filledArray( len, clbk, thisArg ); } if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format('00h04') ); } if ( isObject( arg ) ) { if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2Z', arg ) ); } if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } arg = arg[ ITERATOR_SYMBOL ](); if ( !isFunction( arg.next ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } return filledArrayIterator( arg, clbk, thisArg ); } - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } else if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format('00h04') ); } - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } if ( nargs === 0 ) { // length || array-like || ArrayBuffer || iterable arg = arguments[ 0 ]; @@ -368,18 +368,18 @@ function filledarrayBy() { arr = new ctor( arg ); } else if ( isObject( arg ) ) { if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2Z', arg ) ); } if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } arg = arg[ ITERATOR_SYMBOL ](); if ( !isFunction( arg.next ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } arr = new ctor( iterLength( arg ) ); } else { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } } else if ( nargs === 1 ) { arr = new ctor( arguments[0], arguments[1] ); // (ArrayBuffer, byteOffset) diff --git a/package.json b/package.json index 9d53835..032eb33 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "@stdlib/assert-is-string": "^0.2.1", "@stdlib/blas-ext-base-gfill-by": "^0.2.1", "@stdlib/iter-length": "^0.2.1", - "@stdlib/string-format": "^0.2.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1", "@stdlib/symbol-iterator": "^0.2.1", "@stdlib/types": "^0.3.2", "@stdlib/error-tools-fmtprodmsg": "^0.2.1" From de19c7e0347d761c323317bd880ee71f1f15a30f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jul 2024 19:27:11 +0000 Subject: [PATCH 064/117] Remove files --- index.d.ts | 426 ----- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5273 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index e1b94a1..0000000 --- a/index.d.ts +++ /dev/null @@ -1,426 +0,0 @@ -/* -* @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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, RealOrComplexTypedArray, DataType } from '@stdlib/types/array'; -import { IterableIterator } from '@stdlib/types/iter'; - -/** -* Array or typed array. -*/ -type ArrayOrTypedArray = Array | RealOrComplexTypedArray; - -/** -* Nullary callback function. -* -* @returns fill value -*/ -type Nullary = () => any; - -/** -* Unary callback function. -* -* @param i - current array index -* @returns fill value -*/ -type Unary = ( i: number ) => any; - -/** -* Callback function. -* -* @param i - current array index -* @returns fill value -*/ -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 -* -* @example -* var arr = filledarrayBy(); -* // returns -* -* @example -* var arr = filledarrayBy( 'float32' ); -* // returns -*/ -declare function filledarrayBy( dtype?: DataType ): ArrayOrTypedArray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Creates a filled array according to a provided callback function and having a specified `length`. -* -* @param length - array length -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* -* var arr = filledarrayBy( 5, constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( length: number, clbk: Callback, thisArg?: any ): ArrayOrTypedArray; - -/** -* 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 -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* -* var arr = filledarrayBy( 5, 'float64', constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( length: number, dtype: DataType, clbk: Callback, thisArg?: any ): ArrayOrTypedArray; - -/** -* Creates a filled array from another `array` according to a provided callback function. -* -* @param array - typed array or array-like object -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* -* 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; - -/** -* 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 -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* -* 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; - -/** -* Creates a filled array from an iterable according to a callback function. -* -* @param iterable - iterable -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var iterConstant = require( '@stdlib/iter-constant' ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarrayBy( it, constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( iterable: IterableIterator, callback: Callback, thisArg?: any ): ArrayOrTypedArray; - -/** -* 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 -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var iterConstant = require( '@stdlib/iter-constant' ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* 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; - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; - -/** -* 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. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; - -/** -* 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. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; - -/** -* 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. -* -* @param buffer - `ArrayBuffer` -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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; - - -// EXPORTS // - -export = filledarrayBy; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 56b3976..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.1-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-ctors@v0.2.1-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill-by@v0.2.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled-by@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.2.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.1-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@v0.2.1-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.2.1-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";var j=d(),a=p.get("dtypes.default");function v(){var d,p,v,c,g,y,b,u;if(0===(p=arguments.length))return new(g=o(a))(0);if(r(v=arguments[0])){if(p>1)throw new TypeError(w("00h05"));if(null===(g=o(v)))throw new TypeError(w("00h2Y",v));return new g(0)}if(p<2)throw new TypeError(w("00h05"));if(n(arguments[p-=1]))if(n(arguments[p-1])){if(d=arguments[p],c=arguments[p-=1],0===p)throw new TypeError(w("00h05"))}else c=arguments[p];else{if(!(p>=2))throw new TypeError(w("00h05"));if(d=arguments[p],!n(c=arguments[p-=1]))throw new TypeError(w("00h2b",c))}if((p-=1)>=0&&r(arguments[p])?(v=arguments[p],p-=1):v=a,null===(g=o(v)))throw new TypeError(w("00h2Y",v));if("generic"===v){if(u=arguments[0],0===p){if(e(u)?b=u:t(u)&&(b=u.length),void 0!==b)return l(b,c,d);if(s(u))throw new Error(w("00h04"));if(i(u)){if(!1===j)throw new TypeError(w("00h2Z",u));if(!n(u[m]))throw new TypeError(w("00h2a",u));if(u=u[m](),!n(u.next))throw new TypeError(w("00h2a",u));return function(r,e,t){var s,i;for(s=[],i=-1;!r.next().done;)i+=1,s.push(e.call(t,i));return s}(u,c,d)}throw new TypeError(w("00h2a",u))}if(s(u))throw new Error(w("00h04"));throw new TypeError(w("00h2a",u))}if(0===p)if(t(u=arguments[0]))y=new g(u.length);else if(s(u))y=new g(u);else if(e(u))y=new g(u);else{if(!i(u))throw new TypeError(w("00h2a",u));if(!1===j)throw new TypeError(w("00h2Z",u));if(!n(u[m]))throw new TypeError(w("00h2a",u));if(u=u[m](),!n(u.next))throw new TypeError(w("00h2a",u));y=new g(f(u))}else y=1===p?new g(arguments[0],arguments[1]):new g(arguments[0],arguments[1],arguments[2]);return y.length>0&&(/^complex/.test(v)?function(r,e,t){var s;for(s=0;s\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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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( format('00h05') );\n\t\t}\n\t\tctor = ctors( dtype );\n\t\tif ( ctor === null ) {\n\t\t\tthrow new TypeError( format( '00h2Y', 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( format('00h05') );\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( format('00h05') );\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( '00h2b', 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( format('00h05') );\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( '00h2Y', 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( format('00h04') );\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( '00h2Z', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00h2a', 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( '00h2a', 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( '00h2a', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format('00h04') );\n\t\t}\n\t\tthrow new TypeError( format( '00h2a', 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( '00h2Z', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00h2a', 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( '00h2a', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00h2a', 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\nexport default filledarrayBy;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","DEFAULT_DTYPE","defaults","get","filledarrayBy","thisArg","nargs","dtype","clbk","ctor","arr","len","arg","arguments","length","ctors","isString","TypeError","format","isFunction","isNonNegativeInteger","isCollection","filledArray","isArrayBuffer","Error","isObject","ITERATOR_SYMBOL","next","it","i","done","push","call","filledArrayIterator","iterLength","test","set","filledAccessors","gfillBy","value","aidx"],"mappings":";;q0CAwCA,IAAIA,EAAsBC,IACtBC,EAAgBC,EAASC,IAAK,kBA2MlC,SAASC,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAKJ,GAAe,KAHfN,EAAQO,UAAUC,QAKjB,OAAO,IADPL,EAAOM,EAAOd,IACG,GAIlB,GAAKe,EADLT,EAAQM,UAAW,IACM,CAExB,GAAKP,EAAQ,EACZ,MAAM,IAAIW,UAAWC,EAAO,UAG7B,GAAc,QADdT,EAAOM,EAAOR,IAEb,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,OAAO,IAAIE,EAAM,EACjB,CAED,GAAKH,EAAQ,EACZ,MAAM,IAAIW,UAAWC,EAAO,UAM7B,GAAKC,EAAYN,UAHjBP,GAAS,IAKR,GAAKa,EAAYN,UAAWP,EAAM,KAMjC,GALAD,EAAUQ,UAAWP,GAErBE,EAAOK,UADPP,GAAS,GAIM,IAAVA,EACJ,MAAM,IAAIW,UAAWC,EAAO,eAI7BV,EAAOK,UAAWP,OAIf,MAAKA,GAAS,GAUlB,MAAM,IAAIW,UAAWC,EAAO,UAN5B,GAHAb,EAAUQ,UAAWP,IAGfa,EADNX,EAAOK,UADPP,GAAS,IAGR,MAAM,IAAIW,UAAWC,EAAQ,QAASV,GAMvC,CAUD,IARAF,GAAS,IACK,GAAKU,EAAUH,UAAWP,KACvCC,EAAQM,UAAWP,GACnBA,GAAS,GAETC,EAAQN,EAGK,QADdQ,EAAOM,EAAOR,IAEb,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,GAAe,YAAVA,EAAsB,CAE1B,GADAK,EAAMC,UAAW,GACF,IAAVP,EAAc,CAMlB,GALKc,EAAsBR,GAC1BD,EAAMC,EACKS,EAAcT,KACzBD,EAAMC,EAAIE,aAEE,IAARH,EACJ,OAAOW,EAAaX,EAAKH,EAAMH,GAEhC,GAAKkB,EAAeX,GACnB,MAAM,IAAIY,MAAON,EAAO,UAEzB,GAAKO,EAAUb,GAAQ,CACtB,IAA6B,IAAxBb,EACJ,MAAM,IAAIkB,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAYP,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLP,EAAYP,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvC,OAvSJ,SAA8BgB,EAAIpB,EAAMH,GACvC,IAAIK,EACAmB,EAKJ,IAFAnB,EAAM,GACNmB,GAAK,GAEAD,EAAGD,OACAG,MAGPD,GAAK,EACLnB,EAAIqB,KAAMvB,EAAKwB,KAAM3B,EAASwB,IAE/B,OAAOnB,CACR,CAuRWuB,CAAqBrB,EAAKJ,EAAMH,EACvC,CACD,MAAM,IAAIY,UAAWC,EAAQ,QAASN,GACzC,CAAS,GAAKW,EAAeX,GAC1B,MAAM,IAAIY,MAAON,EAAO,UAEzB,MAAM,IAAID,UAAWC,EAAQ,QAASN,GACtC,CACD,GAAe,IAAVN,EAEJ,GAAKe,EADLT,EAAMC,UAAW,IAEhBH,EAAM,IAAID,EAAMG,EAAIE,aACd,GAAKS,EAAeX,GAC1BF,EAAM,IAAID,EAAMG,QACV,GAAKQ,EAAsBR,GACjCF,EAAM,IAAID,EAAMG,OACV,KAAKa,EAAUb,GAarB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAZtC,IAA6B,IAAxBb,EACJ,MAAM,IAAIkB,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAYP,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLP,EAAYP,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvCF,EAAM,IAAID,EAAMyB,EAAYtB,GAG5B,MAEDF,EADqB,IAAVJ,EACL,IAAIG,EAAMI,UAAU,GAAIA,UAAU,IAElC,IAAIJ,EAAMI,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKH,EAAII,OAAS,IACZ,WAAWqB,KAAM5B,GAjTxB,SAA0BG,EAAKF,EAAMH,GACpC,IAAIwB,EACJ,IAAMA,EAAI,EAAGA,EAAInB,EAAII,OAAQe,IAC5BnB,EAAI0B,IAAK5B,EAAKwB,KAAM3B,EAASwB,GAAKA,EAGpC,CA4SGQ,CAAiB3B,EAAKF,EAAMH,GAE5BiC,EAAS5B,EAAII,OAAQJ,EAAK,GAe5B,SAAmB6B,EAAOC,GACzB,OAAOhC,EAAKwB,KAAM3B,EAASmC,EAC3B,KAdM9B,CAeR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 0fbbd35..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 7eb482e2ed4cf7348cee1aea3f5444698d229058 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jul 2024 19:27:49 +0000 Subject: [PATCH 065/117] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 252 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 188 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 125 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 49 +- SECURITY.md | 5 - benchmark/benchmark.js | 341 -- benchmark/benchmark.length.bool.js | 97 - benchmark/benchmark.length.complex128.js | 98 - benchmark/benchmark.length.complex64.js | 98 - benchmark/benchmark.length.float32.js | 97 - benchmark/benchmark.length.float64.js | 97 - benchmark/benchmark.length.generic.js | 97 - benchmark/benchmark.length.int16.js | 97 - benchmark/benchmark.length.int32.js | 97 - benchmark/benchmark.length.int8.js | 97 - benchmark/benchmark.length.uint16.js | 97 - benchmark/benchmark.length.uint32.js | 97 - benchmark/benchmark.length.uint8.js | 97 - benchmark/benchmark.length.uint8c.js | 97 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 36 - dist/index.js.map | 7 - docs/repl.txt | 157 - docs/types/test.ts | 606 --- examples/index.js | 37 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 192 - lib/main.js | 416 -- package.json | 96 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 4397 ------------------- 55 files changed, 4870 insertions(+), 10971 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.length.bool.js delete mode 100644 benchmark/benchmark.length.complex128.js delete mode 100644 benchmark/benchmark.length.complex64.js delete mode 100644 benchmark/benchmark.length.float32.js delete mode 100644 benchmark/benchmark.length.float64.js delete mode 100644 benchmark/benchmark.length.generic.js delete mode 100644 benchmark/benchmark.length.int16.js delete mode 100644 benchmark/benchmark.length.int32.js delete mode 100644 benchmark/benchmark.length.int8.js delete mode 100644 benchmark/benchmark.length.uint16.js delete mode 100644 benchmark/benchmark.length.uint32.js delete mode 100644 benchmark/benchmark.length.uint8.js delete mode 100644 benchmark/benchmark.length.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 8be0b82..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index f988046..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index b2c1f9c..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '42 6 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f92a6c5..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -278,7 +269,7 @@ for ( i = 0; i < dt.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -347,13 +338,13 @@ 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/dtypes]: https://github.com/stdlib-js/array-dtypes/tree/esm -[@stdlib/array/filled]: https://github.com/stdlib-js/array-filled +[@stdlib/array/filled]: https://github.com/stdlib-js/array-filled/tree/esm -[@stdlib/array/typed]: https://github.com/stdlib-js/array-typed +[@stdlib/array/typed]: https://github.com/stdlib-js/array-typed/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 17cfb5a..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,341 +0,0 @@ -/** -* @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 isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); -var isArray = require( '@stdlib/assert-is-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var Complex64 = require( '@stdlib/complex-float32-ctor' ); -var Complex128 = require( '@stdlib/complex-float64-ctor' ); -var pkg = require( './../package.json' ).name; -var filledarrayBy = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 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=float64', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'float64', 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=float32', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'float32', 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=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; - var i; - - clbk = constantFunction( new Complex128( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'complex128', 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=complex64', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( new Complex64( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'complex64', 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=int32', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int32', 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=uint32', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint32', 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=int16', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int16', 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=uint16', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint16', 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=int8', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int8', 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=uint8', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint8', 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=uint8c', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint8c', 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=generic', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'generic', clbk ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.length.bool.js b/benchmark/benchmark.length.bool.js deleted file mode 100644 index 3cdd152..0000000 --- a/benchmark/benchmark.length.bool.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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/benchmark/benchmark.length.complex128.js b/benchmark/benchmark.length.complex128.js deleted file mode 100644 index 122bc7c..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 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 Complex128 = require( '@stdlib/complex-float64-ctor' ); -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( new Complex128( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'complex128', 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=complex128,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.complex64.js b/benchmark/benchmark.length.complex64.js deleted file mode 100644 index e7a2d74..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 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 Complex64 = require( '@stdlib/complex-float32-ctor' ); -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( new Complex64( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'complex64', 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=complex64,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.float32.js b/benchmark/benchmark.length.float32.js deleted file mode 100644 index d2b2ba7..0000000 --- a/benchmark/benchmark.length.float32.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'float32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=float32,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.float64.js b/benchmark/benchmark.length.float64.js deleted file mode 100644 index 65064e3..0000000 --- a/benchmark/benchmark.length.float64.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'float64', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=float64,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.generic.js b/benchmark/benchmark.length.generic.js deleted file mode 100644 index eb87dfa..0000000 --- a/benchmark/benchmark.length.generic.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isArray = require( '@stdlib/assert-is-array' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'generic', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isArray( 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=generic,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int16.js b/benchmark/benchmark.length.int16.js deleted file mode 100644 index 914ff7c..0000000 --- a/benchmark/benchmark.length.int16.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int16', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=int16,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int32.js b/benchmark/benchmark.length.int32.js deleted file mode 100644 index cc0f678..0000000 --- a/benchmark/benchmark.length.int32.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=int32,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int8.js b/benchmark/benchmark.length.int8.js deleted file mode 100644 index 77553b0..0000000 --- a/benchmark/benchmark.length.int8.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int8', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=int8,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint16.js b/benchmark/benchmark.length.uint16.js deleted file mode 100644 index c68efdd..0000000 --- a/benchmark/benchmark.length.uint16.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint16', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint16,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint32.js b/benchmark/benchmark.length.uint32.js deleted file mode 100644 index 27c1742..0000000 --- a/benchmark/benchmark.length.uint32.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint32,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint8.js b/benchmark/benchmark.length.uint8.js deleted file mode 100644 index 2a26be4..0000000 --- a/benchmark/benchmark.length.uint8.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint8', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint8,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint8c.js b/benchmark/benchmark.length.uint8c.js deleted file mode 100644 index dd6e8c2..0000000 --- a/benchmark/benchmark.length.uint8c.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint8c', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint8c,len='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index c138144..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by" -%% click B href "https://github.com/stdlib-js/array-filled-by/tree/main" -%% click C href "https://github.com/stdlib-js/array-filled-by/tree/production" -%% click D href "https://github.com/stdlib-js/array-filled-by/tree/esm" -%% click E href "https://github.com/stdlib-js/array-filled-by/tree/deno" -%% click F href "https://github.com/stdlib-js/array-filled-by/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by -[production-url]: https://github.com/stdlib-js/array-filled-by/tree/production -[deno-url]: https://github.com/stdlib-js/array-filled-by/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-filled-by/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-filled-by/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-filled-by/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-filled-by/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-filled-by/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 188fc9b..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import filledarrayBy from '../docs/types/index'; -export = filledarrayBy; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 65ae3db..0000000 --- a/dist/index.js +++ /dev/null @@ -1,36 +0,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 deleted file mode 100644 index e88f9aa..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "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,YACjDC,EAAuB,QAAS,uCAAwC,EAAE,YAC1EC,EAAoB,QAAS,+DAAgE,EAC7FC,EAAoB,QAAS,gDAAiD,EAC9EC,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,EAAQ,UAAU,OAGbA,IAAU,EACd,OAAAE,EAAOrB,EAAOS,CAAc,EACrB,IAAIY,EAAM,CAAE,EAIpB,GADAD,EAAQ,UAAW,CAAE,EAChB5B,EAAU4B,CAAM,EAAI,CAExB,GAAKD,EAAQ,EACZ,MAAM,IAAI,UAAW,2FAA4F,EAGlH,GADAE,EAAOrB,EAAOoB,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWd,EAAQ,sEAAuEa,CAAM,CAAE,EAG7G,OAAO,IAAIC,EAAM,CAAE,CACpB,CAEA,GAAKF,EAAQ,EACZ,MAAM,IAAI,UAAW,2FAA4F,EAMlH,GAHAA,GAAS,EAGJpB,EAAY,UAAWoB,CAAM,CAAE,EAEnC,GAAKpB,EAAY,UAAWoB,EAAM,CAAE,CAAE,GAMrC,GALAN,EAAU,UAAWM,CAAM,EAC3BA,GAAS,EACTP,EAAO,UAAWO,CAAM,EAGnBA,IAAU,EACd,MAAM,IAAI,UAAW,2FAA4F,OAIlHP,EAAO,UAAWO,CAAM,UAIhBA,GAAS,GAIlB,GAHAN,EAAU,UAAWM,CAAM,EAC3BA,GAAS,EACTP,EAAO,UAAWO,CAAM,EACnB,CAACpB,EAAYa,CAAK,EACtB,MAAM,IAAI,UAAWL,EAAQ,uEAAwEK,CAAK,CAAE,MAK7G,OAAM,IAAI,UAAW,2FAA4F,EAWlH,GARAO,GAAS,EACJA,GAAS,GAAK3B,EAAU,UAAW2B,CAAM,CAAE,GAC/CC,EAAQ,UAAWD,CAAM,EACzBA,GAAS,GAETC,EAAQX,EAETY,EAAOrB,EAAOoB,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWd,EAAQ,sEAAuEa,CAAM,CAAE,EAG7G,GAAKA,IAAU,UAAY,CAE1B,GADAG,EAAM,UAAW,CAAE,EACdJ,IAAU,EAAI,CAMlB,GALK1B,EAAsB8B,CAAI,EAC9BD,EAAMC,EACK3B,EAAc2B,CAAI,IAC7BD,EAAMC,EAAI,QAEND,IAAQ,OACZ,OAAOpB,EAAaoB,EAAKV,EAAMC,CAAQ,EAExC,GAAKhB,EAAe0B,CAAI,EACvB,MAAM,IAAI,MAAO,mFAAoF,EAEtG,GAAKzB,EAAUyB,CAAI,EAAI,CACtB,GAAKf,IAAwB,GAC5B,MAAM,IAAI,UAAWD,EAAQ,sIAAuIgB,CAAI,CAAE,EAE3K,GAAK,CAACxB,EAAYwB,EAAKnB,CAAgB,CAAE,EACxC,MAAM,IAAI,UAAWG,EAAQ,wGAAyGgB,CAAI,CAAE,EAG7I,GADAA,EAAMA,EAAKnB,CAAgB,EAAE,EACxB,CAACL,EAAYwB,EAAI,IAAK,EAC1B,MAAM,IAAI,UAAWhB,EAAQ,wGAAyGgB,CAAI,CAAE,EAE7I,OAAOb,EAAqBa,EAAKX,EAAMC,CAAQ,CAChD,CACA,MAAM,IAAI,UAAWN,EAAQ,wGAAyGgB,CAAI,CAAE,CAC7I,SAAY1B,EAAe0B,CAAI,EAC9B,MAAM,IAAI,MAAO,mFAAoF,EAEtG,MAAM,IAAI,UAAWhB,EAAQ,wGAAyGgB,CAAI,CAAE,CAC7I,CACA,GAAKJ,IAAU,EAEd,GADAI,EAAM,UAAW,CAAE,EACd3B,EAAc2B,CAAI,EACtBT,EAAM,IAAIO,EAAME,EAAI,MAAO,UAChB1B,EAAe0B,CAAI,EAC9BT,EAAM,IAAIO,EAAME,CAAI,UACT9B,EAAsB8B,CAAI,EACrCT,EAAM,IAAIO,EAAME,CAAI,UACTzB,EAAUyB,CAAI,EAAI,CAC7B,GAAKf,IAAwB,GAC5B,MAAM,IAAI,UAAWD,EAAQ,sIAAuIgB,CAAI,CAAE,EAE3K,GAAK,CAACxB,EAAYwB,EAAKnB,CAAgB,CAAE,EACxC,MAAM,IAAI,UAAWG,EAAQ,wGAAyGgB,CAAI,CAAE,EAG7I,GADAA,EAAMA,EAAKnB,CAAgB,EAAE,EACxB,CAACL,EAAYwB,EAAI,IAAK,EAC1B,MAAM,IAAI,UAAWhB,EAAQ,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,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 deleted file mode 100644 index 06f3146..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,157 +0,0 @@ - -{{alias}}( [dtype] ) - Creates a filled array. - - Parameters - ---------- - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr = {{alias}}() - - > arr = {{alias}}( 'float32' ) - - - -{{alias}}( length[, dtype], clbk[, thisArg] ) - Returns a filled array according to a provided callback function and having - a specified length. - - Parameters - ---------- - length: integer - Array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > function clbk() { return 1.0; }; - > var arr = {{alias}}( 5, clbk ) - [ 1.0, 1.0, 1.0, 1.0, 1.0 ] - > arr = {{alias}}( 5, 'int32', clbk ) - [ 1, 1, 1, 1, 1 ] - - -{{alias}}( array[, dtype], clbk[, thisArg] ) - Creates a filled array from another array (or array-like object) according - to a provided callback function. - - Parameters - ---------- - array: ArrayLikeObject - Array from which to generate another array. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias}}( [ 0.5, 0.5, 0.5 ], {{alias:@stdlib/utils/constant-function}}( 2.0 ) ) - [ 2.0, 2.0, 2.0 ] - > var arr2 = {{alias}}( arr1, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( iterable[, dtype], clbk[, thisArg] ) - Creates a filled array from an iterable according to a provided callback - function. - - Parameters - ---------- - iterable: Iterable - Iterable from which to generate an array. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias:@stdlib/iter/constant}}( 3.0, {'iter': 3} ); - > var arr2 = {{alias}}( arr1, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( buffer[, byteOffset[, length]][, dtype], clbk[, thisArg] ) - Returns a filled typed array view of an ArrayBuffer according to a provided - callback function. - - The 'generic' array data type is *not* supported. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( buf, 0, 4, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0, 1.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 394ac49..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,606 +0,0 @@ -/* -* @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. -*/ - -/// - -import { IterableIterator } from '@stdlib/types/iter'; -import filledarrayBy = require( './index' ); - - -/** -* Returns an iterator protocol-compliant object. -* -* @returns iterator protocol-compliant object -*/ -function iterator(): IterableIterator { - const obj: IterableIterator = { - [Symbol.iterator]: iterator, - 'next': next - }; - return obj; -} - -/** -* Implements the iterator protocol `next` method. -* -* @returns iterator protocol-compliant object -*/ -function next(): any { - return { - 'value': 1.0, - 'done': false - }; -} - -/** -* Callback function. -* -* @param i - current array index -* @returns return value -*/ -function clbk( i: number ): number { - return i; -} - - -// TESTS // - -// The function returns an array or typed array... -{ - filledarrayBy(); // $ExpectType ArrayOrTypedArray - filledarrayBy( 'float32' ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( 10, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( 10, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( 10, 'int32', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( 10, 'int32', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const x = new Float64Array( 10 ); - filledarrayBy( x, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( x, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( x, 'uint8', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( x, 'uint8', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const y = [ 2.0, 2.0, 2.0 ]; - filledarrayBy( y, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( y, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( y, 'float64', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( y, 'float64', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const it = iterator(); - filledarrayBy( it, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( it, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( it, 'uint8c', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( it, 'uint8c', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const buf = new ArrayBuffer( 32 ); - filledarrayBy( buf, clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 'uint32', clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 'uint32', clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 8, clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 8, clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 8, 'uint16', clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 8, 'uint16', clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 8, 2, clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 8, 2, clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 8, 2, 'int16', clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 8, 2, 'int16', clbk, {} ); // $ExpectType RealOrComplexTypedArray -} - -// The compiler throws an error if a callback function argument is not a function... -{ - filledarrayBy( 'float64', '5' ); // $ExpectError - filledarrayBy( 'float64', 1.0 ); // $ExpectError - filledarrayBy( 'float64', false ); // $ExpectError - filledarrayBy( 'float64', true ); // $ExpectError - filledarrayBy( 'float64', null ); // $ExpectError - filledarrayBy( 'float64', undefined ); // $ExpectError - filledarrayBy( 'float64', [] ); // $ExpectError - filledarrayBy( 'float64', {} ); // $ExpectError - - filledarrayBy( 'float64', '5', {} ); // $ExpectError - filledarrayBy( 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( 'float64', false, {} ); // $ExpectError - filledarrayBy( 'float64', true, {} ); // $ExpectError - filledarrayBy( 'float64', null, {} ); // $ExpectError - filledarrayBy( 'float64', undefined, {} ); // $ExpectError - filledarrayBy( 'float64', [], {} ); // $ExpectError - filledarrayBy( 'float64', {}, {} ); // $ExpectError - - filledarrayBy( 10, '5' ); // $ExpectError - filledarrayBy( 10, 1.0 ); // $ExpectError - filledarrayBy( 10, false ); // $ExpectError - filledarrayBy( 10, true ); // $ExpectError - filledarrayBy( 10, null ); // $ExpectError - filledarrayBy( 10, undefined ); // $ExpectError - filledarrayBy( 10, [] ); // $ExpectError - filledarrayBy( 10, {} ); // $ExpectError - - filledarrayBy( 10, '5', {} ); // $ExpectError - filledarrayBy( 10, 1.0, {} ); // $ExpectError - filledarrayBy( 10, false, {} ); // $ExpectError - filledarrayBy( 10, true, {} ); // $ExpectError - filledarrayBy( 10, null, {} ); // $ExpectError - filledarrayBy( 10, undefined, {} ); // $ExpectError - filledarrayBy( 10, [], {} ); // $ExpectError - filledarrayBy( 10, {}, {} ); // $ExpectError - - filledarrayBy( 10, 'float64', '5' ); // $ExpectError - filledarrayBy( 10, 'float64', 1.0 ); // $ExpectError - filledarrayBy( 10, 'float64', false ); // $ExpectError - filledarrayBy( 10, 'float64', true ); // $ExpectError - filledarrayBy( 10, 'float64', null ); // $ExpectError - filledarrayBy( 10, 'float64', undefined ); // $ExpectError - filledarrayBy( 10, 'float64', [] ); // $ExpectError - filledarrayBy( 10, 'float64', {} ); // $ExpectError - - filledarrayBy( 10, 'float64', '5', {} ); // $ExpectError - filledarrayBy( 10, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( 10, 'float64', false, {} ); // $ExpectError - filledarrayBy( 10, 'float64', true, {} ); // $ExpectError - filledarrayBy( 10, 'float64', null, {} ); // $ExpectError - filledarrayBy( 10, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( 10, 'float64', [], {} ); // $ExpectError - filledarrayBy( 10, 'float64', {}, {} ); // $ExpectError - - const x = new Float64Array( 10 ); - filledarrayBy( x, '5' ); // $ExpectError - filledarrayBy( x, 1.0 ); // $ExpectError - filledarrayBy( x, false ); // $ExpectError - filledarrayBy( x, true ); // $ExpectError - filledarrayBy( x, null ); // $ExpectError - filledarrayBy( x, undefined ); // $ExpectError - filledarrayBy( x, [] ); // $ExpectError - filledarrayBy( x, {} ); // $ExpectError - - filledarrayBy( x, '5', {} ); // $ExpectError - filledarrayBy( x, 1.0, {} ); // $ExpectError - filledarrayBy( x, false, {} ); // $ExpectError - filledarrayBy( x, true, {} ); // $ExpectError - filledarrayBy( x, null, {} ); // $ExpectError - filledarrayBy( x, undefined, {} ); // $ExpectError - filledarrayBy( x, [], {} ); // $ExpectError - filledarrayBy( x, {}, {} ); // $ExpectError - - filledarrayBy( x, 'float64', '5' ); // $ExpectError - filledarrayBy( x, 'float64', 1.0 ); // $ExpectError - filledarrayBy( x, 'float64', false ); // $ExpectError - filledarrayBy( x, 'float64', true ); // $ExpectError - filledarrayBy( x, 'float64', null ); // $ExpectError - filledarrayBy( x, 'float64', undefined ); // $ExpectError - filledarrayBy( x, 'float64', [] ); // $ExpectError - filledarrayBy( x, 'float64', {} ); // $ExpectError - - filledarrayBy( x, 'float64', '5', {} ); // $ExpectError - filledarrayBy( x, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( x, 'float64', false, {} ); // $ExpectError - filledarrayBy( x, 'float64', true, {} ); // $ExpectError - filledarrayBy( x, 'float64', null, {} ); // $ExpectError - filledarrayBy( x, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( x, 'float64', [], {} ); // $ExpectError - filledarrayBy( x, 'float64', {}, {} ); // $ExpectError - - const y = [ 2.0, 2.0, 2.0 ]; - filledarrayBy( y, '5' ); // $ExpectError - filledarrayBy( y, 1.0 ); // $ExpectError - filledarrayBy( y, false ); // $ExpectError - filledarrayBy( y, true ); // $ExpectError - filledarrayBy( y, null ); // $ExpectError - filledarrayBy( y, undefined ); // $ExpectError - filledarrayBy( y, [] ); // $ExpectError - filledarrayBy( y, {} ); // $ExpectError - - filledarrayBy( y, '5', {} ); // $ExpectError - filledarrayBy( y, 1.0, {} ); // $ExpectError - filledarrayBy( y, false, {} ); // $ExpectError - filledarrayBy( y, true, {} ); // $ExpectError - filledarrayBy( y, null, {} ); // $ExpectError - filledarrayBy( y, undefined, {} ); // $ExpectError - filledarrayBy( y, [], {} ); // $ExpectError - filledarrayBy( y, {}, {} ); // $ExpectError - - filledarrayBy( y, 'float64', '5' ); // $ExpectError - filledarrayBy( y, 'float64', 1.0 ); // $ExpectError - filledarrayBy( y, 'float64', false ); // $ExpectError - filledarrayBy( y, 'float64', true ); // $ExpectError - filledarrayBy( y, 'float64', null ); // $ExpectError - filledarrayBy( y, 'float64', undefined ); // $ExpectError - filledarrayBy( y, 'float64', [] ); // $ExpectError - filledarrayBy( y, 'float64', {} ); // $ExpectError - - filledarrayBy( y, 'float64', '5', {} ); // $ExpectError - filledarrayBy( y, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( y, 'float64', false, {} ); // $ExpectError - filledarrayBy( y, 'float64', true, {} ); // $ExpectError - filledarrayBy( y, 'float64', null, {} ); // $ExpectError - filledarrayBy( y, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( y, 'float64', [], {} ); // $ExpectError - filledarrayBy( y, 'float64', {}, {} ); // $ExpectError - - const it = iterator(); - filledarrayBy( it, '5' ); // $ExpectError - filledarrayBy( it, 1.0 ); // $ExpectError - filledarrayBy( it, false ); // $ExpectError - filledarrayBy( it, true ); // $ExpectError - filledarrayBy( it, null ); // $ExpectError - filledarrayBy( it, undefined ); // $ExpectError - filledarrayBy( it, [] ); // $ExpectError - filledarrayBy( it, {} ); // $ExpectError - - filledarrayBy( it, '5', {} ); // $ExpectError - filledarrayBy( it, 1.0, {} ); // $ExpectError - filledarrayBy( it, false, {} ); // $ExpectError - filledarrayBy( it, true, {} ); // $ExpectError - filledarrayBy( it, null, {} ); // $ExpectError - filledarrayBy( it, undefined, {} ); // $ExpectError - filledarrayBy( it, [], {} ); // $ExpectError - filledarrayBy( it, {}, {} ); // $ExpectError - - filledarrayBy( it, 'float64', '5' ); // $ExpectError - filledarrayBy( it, 'float64', 1.0 ); // $ExpectError - filledarrayBy( it, 'float64', false ); // $ExpectError - filledarrayBy( it, 'float64', true ); // $ExpectError - filledarrayBy( it, 'float64', null ); // $ExpectError - filledarrayBy( it, 'float64', undefined ); // $ExpectError - filledarrayBy( it, 'float64', [] ); // $ExpectError - filledarrayBy( it, 'float64', {} ); // $ExpectError - - filledarrayBy( it, 'float64', '5', {} ); // $ExpectError - filledarrayBy( it, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( it, 'float64', false, {} ); // $ExpectError - filledarrayBy( it, 'float64', true, {} ); // $ExpectError - filledarrayBy( it, 'float64', null, {} ); // $ExpectError - filledarrayBy( it, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( it, 'float64', [], {} ); // $ExpectError - filledarrayBy( it, 'float64', {}, {} ); // $ExpectError - - const buf = new ArrayBuffer( 32 ); - filledarrayBy( buf, '5' ); // $ExpectError - filledarrayBy( buf, 1.0 ); // $ExpectError - filledarrayBy( buf, false ); // $ExpectError - filledarrayBy( buf, true ); // $ExpectError - filledarrayBy( buf, null ); // $ExpectError - filledarrayBy( buf, undefined ); // $ExpectError - filledarrayBy( buf, [] ); // $ExpectError - filledarrayBy( buf, {} ); // $ExpectError - - filledarrayBy( buf, '5', {} ); // $ExpectError - filledarrayBy( buf, 1.0, {} ); // $ExpectError - filledarrayBy( buf, false, {} ); // $ExpectError - filledarrayBy( buf, true, {} ); // $ExpectError - filledarrayBy( buf, null, {} ); // $ExpectError - filledarrayBy( buf, undefined, {} ); // $ExpectError - filledarrayBy( buf, [], {} ); // $ExpectError - filledarrayBy( buf, {}, {} ); // $ExpectError - - filledarrayBy( buf, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 'float64', false ); // $ExpectError - filledarrayBy( buf, 'float64', true ); // $ExpectError - filledarrayBy( buf, 'float64', null ); // $ExpectError - filledarrayBy( buf, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 'float64', {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5' ); // $ExpectError - filledarrayBy( buf, 8, 1.0 ); // $ExpectError - filledarrayBy( buf, 8, false ); // $ExpectError - filledarrayBy( buf, 8, true ); // $ExpectError - filledarrayBy( buf, 8, null ); // $ExpectError - filledarrayBy( buf, 8, undefined ); // $ExpectError - filledarrayBy( buf, 8, [] ); // $ExpectError - filledarrayBy( buf, 8, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, false, {} ); // $ExpectError - filledarrayBy( buf, 8, true, {} ); // $ExpectError - filledarrayBy( buf, 8, null, {} ); // $ExpectError - filledarrayBy( buf, 8, undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, [], {} ); // $ExpectError - filledarrayBy( buf, 8, {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 8, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 'float64', false ); // $ExpectError - filledarrayBy( buf, 8, 'float64', true ); // $ExpectError - filledarrayBy( buf, 8, 'float64', null ); // $ExpectError - filledarrayBy( buf, 8, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 8, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 8, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 8, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, '5' ); // $ExpectError - filledarrayBy( buf, 8, 2, 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 2, false ); // $ExpectError - filledarrayBy( buf, 8, 2, true ); // $ExpectError - filledarrayBy( buf, 8, 2, null ); // $ExpectError - filledarrayBy( buf, 8, 2, undefined ); // $ExpectError - filledarrayBy( buf, 8, 2, [] ); // $ExpectError - filledarrayBy( buf, 8, 2, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, false, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, true, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, null, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, [], {} ); // $ExpectError - filledarrayBy( buf, 8, 2, {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', false ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', true ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', null ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', {}, {} ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid length, typed array, array-like object, `ArrayBuffer`, or iterable argument... -{ - filledarrayBy( false, clbk ); // $ExpectError - filledarrayBy( true, clbk ); // $ExpectError - filledarrayBy( null, clbk ); // $ExpectError - filledarrayBy( {}, clbk ); // $ExpectError - - filledarrayBy( false, clbk, {} ); // $ExpectError - filledarrayBy( true, clbk, {} ); // $ExpectError - filledarrayBy( null, clbk, {} ); // $ExpectError - filledarrayBy( {}, clbk, {} ); // $ExpectError - - filledarrayBy( false, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 'float64', clbk ); // $ExpectError - - filledarrayBy( false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, clbk ); // $ExpectError - filledarrayBy( 1.0, 8, clbk ); // $ExpectError - filledarrayBy( false, 8, clbk ); // $ExpectError - filledarrayBy( true, 8, clbk ); // $ExpectError - filledarrayBy( null, 8, clbk ); // $ExpectError - filledarrayBy( undefined, 8, clbk ); // $ExpectError - filledarrayBy( [], 8, clbk ); // $ExpectError - filledarrayBy( {}, 8, clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, clbk ); // $ExpectError - - filledarrayBy( '5', 8, clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, clbk, {} ); // $ExpectError - filledarrayBy( false, 8, clbk, {} ); // $ExpectError - filledarrayBy( true, 8, clbk, {} ); // $ExpectError - filledarrayBy( null, 8, clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, clbk, {} ); // $ExpectError - filledarrayBy( [], 8, clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 'float64', clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( false, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( [], 8, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 'float64', clbk ); // $ExpectError - - filledarrayBy( '5', 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 2, clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 2, clbk ); // $ExpectError - filledarrayBy( false, 8, 2, clbk ); // $ExpectError - filledarrayBy( true, 8, 2, clbk ); // $ExpectError - filledarrayBy( null, 8, 2, clbk ); // $ExpectError - filledarrayBy( undefined, 8, 2, clbk ); // $ExpectError - filledarrayBy( [], 8, 2, clbk ); // $ExpectError - filledarrayBy( {}, 8, 2, clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, clbk ); // $ExpectError - - filledarrayBy( '5', 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( false, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( [], 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, 'float64', clbk ); // $ExpectError - - filledarrayBy( '5', 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a byte offset argument which is not a number... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, false, clbk ); // $ExpectError - filledarrayBy( buf, true, clbk ); // $ExpectError - filledarrayBy( buf, null, clbk ); // $ExpectError - filledarrayBy( buf, [], clbk ); // $ExpectError - filledarrayBy( buf, {}, clbk ); // $ExpectError - - filledarrayBy( buf, false, clbk, {} ); // $ExpectError - filledarrayBy( buf, true, clbk, {} ); // $ExpectError - filledarrayBy( buf, null, clbk, {} ); // $ExpectError - filledarrayBy( buf, [], clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, clbk, {} ); // $ExpectError - - filledarrayBy( buf, '5', 'float64', clbk ); // $ExpectError - filledarrayBy( buf, false, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, true, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, null, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, [], 'float64', clbk ); // $ExpectError - filledarrayBy( buf, {}, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, '5', 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( buf, false, 2, clbk ); // $ExpectError - filledarrayBy( buf, true, 2, clbk ); // $ExpectError - filledarrayBy( buf, null, 2, clbk ); // $ExpectError - filledarrayBy( buf, [], 2, clbk ); // $ExpectError - filledarrayBy( buf, {}, 2, clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, clbk ); // $ExpectError - - filledarrayBy( buf, false, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, clbk, {} ); // $ExpectError - - filledarrayBy( buf, '5', 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, false, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, true, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, null, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, undefined, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, [], 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, {}, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, '5', 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, false, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, undefined, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a view length argument which is not a number... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, 8, false, clbk ); // $ExpectError - filledarrayBy( buf, 8, true, clbk ); // $ExpectError - filledarrayBy( buf, 8, null, clbk ); // $ExpectError - filledarrayBy( buf, 8, [], clbk ); // $ExpectError - filledarrayBy( buf, 8, {}, clbk ); // $ExpectError - - filledarrayBy( buf, 8, false, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, true, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, null, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, [], clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, {}, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, clbk, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5', 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, false, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, true, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, null, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, [], 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, {}, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, 8, '5', 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, [], 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, {}, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided too many arguments... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, 8, 2, 'float64', 1, clbk, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 997a381..0000000 --- a/examples/index.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ).factory; -var dtypes = require( '@stdlib/array-typed-real-dtypes' ); -var filledarrayBy = require( './../lib' ); - -// Create a pseudorandom number generator: -var rand = discreteUniform( 0, 100 ); - -// Get a list of array data types: -var dt = dtypes(); - -// Generate filled arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = filledarrayBy( 10, dt[ i ], rand ); - console.log( arr ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 5b42a1d..c8f0e9a 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, RealOrComplexTypedArray, BooleanArray, DataType } from '@stdlib/types/array'; import { IterableIterator } from '@stdlib/types/iter'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..c9e97c3 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.1-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@v0.0.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.1-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-ctors@v0.2.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill-by@v0.2.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled-by@v0.2.1-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.2.1-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@v0.2.1-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.2.1-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";var v=f(),g=j.get("dtypes.default");function c(){var f,j,c,b,y,x,u,E;if(0===(j=arguments.length))return new(y=d(g))(0);if(r(c=arguments[0])){if(j>1)throw new TypeError(w("00h05"));if(null===(y=d(c)))throw new TypeError(w("00h2Y",c));return new y(0)}if(j<2)throw new TypeError(w("00h05"));if(h(arguments[j-=1]))if(h(arguments[j-1])){if(f=arguments[j],b=arguments[j-=1],0===j)throw new TypeError(w("00h05"))}else b=arguments[j];else{if(!(j>=2))throw new TypeError(w("00h05"));if(f=arguments[j],!h(b=arguments[j-=1]))throw new TypeError(w("00h2b",b))}if((j-=1)>=0&&r(arguments[j])?(c=arguments[j],j-=1):c=g,null===(y=d(c)))throw new TypeError(w("00h2Y",c));if("generic"===c){if(E=arguments[0],0===j){if(e(E)?u=E:i(E)&&(u=E.length),void 0!==u)return m(u,b,f);if(n(E))throw new Error(w("00h04"));if(o(E)){if(!1===v)throw new TypeError(w("00h2Z",E));if(!h(E[p]))throw new TypeError(w("00h2a",E));if(E=E[p](),!h(E.next))throw new TypeError(w("00h2a",E));return function(r,e,t){var s,i;for(s=[],i=-1;!r.next().done;)i+=1,s.push(e.call(t,i));return s}(E,b,f)}throw new TypeError(w("00h2a",E))}if(n(E))throw new Error(w("00h04"));throw new TypeError(w("00h2a",E))}if(0===j)if(i(E=arguments[0]))x=new y(E.length);else if(n(E))x=new y(E);else if(e(E))x=new y(E);else{if(!o(E))throw new TypeError(w("00h2a",E));if(!1===v)throw new TypeError(w("00h2Z",E));if(!h(E[p]))throw new TypeError(w("00h2a",E));if(E=E[p](),!h(E.next))throw new TypeError(w("00h2a",E));x=new y(a(E))}else x=1===j?new y(arguments[0],arguments[1]):new y(arguments[0],arguments[1],arguments[2]);return x.length>0&&(t(c)||s(c)?function(r,e,t){var s;for(s=0;s\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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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( format('00h05') );\n\t\t}\n\t\tctor = ctors( dtype );\n\t\tif ( ctor === null ) {\n\t\t\tthrow new TypeError( format( '00h2Y', 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( format('00h05') );\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( format('00h05') );\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( '00h2b', 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( format('00h05') );\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( '00h2Y', 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( format('00h04') );\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( '00h2Z', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00h2a', 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( '00h2a', 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( '00h2a', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format('00h04') );\n\t\t}\n\t\tthrow new TypeError( format( '00h2a', 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( '00h2Z', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00h2a', 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( '00h2a', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00h2a', 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\nexport default filledarrayBy;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","DEFAULT_DTYPE","defaults","get","filledarrayBy","thisArg","nargs","dtype","clbk","ctor","arr","len","arg","arguments","length","ctors","isString","TypeError","format","isFunction","isNonNegativeInteger","isCollection","filledArray","isArrayBuffer","Error","isObject","ITERATOR_SYMBOL","next","it","i","done","push","call","filledArrayIterator","iterLength","isComplexDataType","isBooleanDataType","set","filledAccessors","gfillBy","value","aidx"],"mappings":";;sjDA0CA,IAAIA,EAAsBC,IACtBC,EAAgBC,EAASC,IAAK,kBA2MlC,SAASC,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAKJ,GAAe,KAHfN,EAAQO,UAAUC,QAKjB,OAAO,IADPL,EAAOM,EAAOd,IACG,GAIlB,GAAKe,EADLT,EAAQM,UAAW,IACM,CAExB,GAAKP,EAAQ,EACZ,MAAM,IAAIW,UAAWC,EAAO,UAG7B,GAAc,QADdT,EAAOM,EAAOR,IAEb,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,OAAO,IAAIE,EAAM,EACjB,CAED,GAAKH,EAAQ,EACZ,MAAM,IAAIW,UAAWC,EAAO,UAM7B,GAAKC,EAAYN,UAHjBP,GAAS,IAKR,GAAKa,EAAYN,UAAWP,EAAM,KAMjC,GALAD,EAAUQ,UAAWP,GAErBE,EAAOK,UADPP,GAAS,GAIM,IAAVA,EACJ,MAAM,IAAIW,UAAWC,EAAO,eAI7BV,EAAOK,UAAWP,OAIf,MAAKA,GAAS,GAUlB,MAAM,IAAIW,UAAWC,EAAO,UAN5B,GAHAb,EAAUQ,UAAWP,IAGfa,EADNX,EAAOK,UADPP,GAAS,IAGR,MAAM,IAAIW,UAAWC,EAAQ,QAASV,GAMvC,CAUD,IARAF,GAAS,IACK,GAAKU,EAAUH,UAAWP,KACvCC,EAAQM,UAAWP,GACnBA,GAAS,GAETC,EAAQN,EAGK,QADdQ,EAAOM,EAAOR,IAEb,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,GAAe,YAAVA,EAAsB,CAE1B,GADAK,EAAMC,UAAW,GACF,IAAVP,EAAc,CAMlB,GALKc,EAAsBR,GAC1BD,EAAMC,EACKS,EAAcT,KACzBD,EAAMC,EAAIE,aAEE,IAARH,EACJ,OAAOW,EAAaX,EAAKH,EAAMH,GAEhC,GAAKkB,EAAeX,GACnB,MAAM,IAAIY,MAAON,EAAO,UAEzB,GAAKO,EAAUb,GAAQ,CACtB,IAA6B,IAAxBb,EACJ,MAAM,IAAIkB,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAYP,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLP,EAAYP,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvC,OAvSJ,SAA8BgB,EAAIpB,EAAMH,GACvC,IAAIK,EACAmB,EAKJ,IAFAnB,EAAM,GACNmB,GAAK,GAEAD,EAAGD,OACAG,MAGPD,GAAK,EACLnB,EAAIqB,KAAMvB,EAAKwB,KAAM3B,EAASwB,IAE/B,OAAOnB,CACR,CAuRWuB,CAAqBrB,EAAKJ,EAAMH,EACvC,CACD,MAAM,IAAIY,UAAWC,EAAQ,QAASN,GACzC,CAAS,GAAKW,EAAeX,GAC1B,MAAM,IAAIY,MAAON,EAAO,UAEzB,MAAM,IAAID,UAAWC,EAAQ,QAASN,GACtC,CACD,GAAe,IAAVN,EAEJ,GAAKe,EADLT,EAAMC,UAAW,IAEhBH,EAAM,IAAID,EAAMG,EAAIE,aACd,GAAKS,EAAeX,GAC1BF,EAAM,IAAID,EAAMG,QACV,GAAKQ,EAAsBR,GACjCF,EAAM,IAAID,EAAMG,OACV,KAAKa,EAAUb,GAarB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAZtC,IAA6B,IAAxBb,EACJ,MAAM,IAAIkB,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAYP,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLP,EAAYP,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvCF,EAAM,IAAID,EAAMyB,EAAYtB,GAG5B,MAEDF,EADqB,IAAVJ,EACL,IAAIG,EAAMI,UAAU,GAAIA,UAAU,IAElC,IAAIJ,EAAMI,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKH,EAAII,OAAS,IACZqB,EAAmB5B,IAAW6B,EAAmB7B,GAjTxD,SAA0BG,EAAKF,EAAMH,GACpC,IAAIwB,EACJ,IAAMA,EAAI,EAAGA,EAAInB,EAAII,OAAQe,IAC5BnB,EAAI2B,IAAK7B,EAAKwB,KAAM3B,EAASwB,GAAKA,EAGpC,CA4SGS,CAAiB5B,EAAKF,EAAMH,GAE5BkC,EAAS7B,EAAII,OAAQJ,EAAK,GAe5B,SAAmB8B,EAAOC,GACzB,OAAOjC,EAAKwB,KAAM3B,EAASoC,EAC3B,KAdM/B,CAeR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d115cf0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,192 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -/** -* Create a filled array according to a provided callback function. -* -* @module @stdlib/array-filled-by -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* var arr = filledarrayBy(); -* // returns -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'generic', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( [ 0.5, 0.5 ], clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1; -* } -* -* var arr = filledarrayBy( [ 5, -3 ], 'int32', clbk ); -* // returns [ 1, 1 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk1() { -* return 10; -* } -* -* function clbk2() { -* return 1.0; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, clbk2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk1() { -* return 1.0; -* } -* -* function clbk2() { -* return 2; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, 'uint32', clbk2 ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 'float32', clbk ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, clbk ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, 'int32', clbk ); -* // returns [ 1, 1 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index ed1aa9a..0000000 --- a/lib/main.js +++ /dev/null @@ -1,416 +0,0 @@ -/** -* @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 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' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var ctors = require( '@stdlib/array-ctors' ); -var gfillBy = require( '@stdlib/blas-ext-base-gfill-by' ); -var filledArray = require( '@stdlib/array-base-filled-by' ); -var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var iterLength = require( '@stdlib/iter-length' ); -var defaults = require( '@stdlib/array-defaults' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport(); -var DEFAULT_DTYPE = defaults.get( 'dtypes.default' ); - - -// FUNCTIONS // - -/** -* Creates a filled "generic" array from an iterator. -* -* @private -* @param {Iterable} it - iterator -* @param {Callback} clbk - callback function -* @param {*} thisArg - callback function execution context -* @returns {Array} filled array -*/ -function filledArrayIterator( it, clbk, thisArg ) { - var arr; - var i; - var v; - - arr = []; - i = -1; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - i += 1; - arr.push( clbk.call( thisArg, i ) ); - } - return arr; -} - -/** -* Fills an array exposing accessors for getting and setting array elements. -* -* @private -* @param {Collection} arr - input array -* @param {Callback} clbk - callback function -* @param {*} thisArg - callback function execution context -* @returns {Collection} input array -*/ -function filledAccessors( arr, clbk, thisArg ) { - var i; - for ( i = 0; i < arr.length; i++ ) { - arr.set( clbk.call( thisArg, i ), i ); - } - return arr; -} - - -// MAIN // - -/** -* Creates a filled array according to a provided callback function. -* -* @param {(NonNegativeInteger|TypedArray|ArrayLikeObject|ArrayBuffer|Iterable)} [arg] - a length, typed array, array-like object, buffer, or iterable -* @param {NonNegativeInteger} [byteOffset=0] - byte offset -* @param {NonNegativeInteger} [length] - view length -* @param {string} [dtype="float64"] - data type -* @param {Callback} [clbk] - callback to invoke -* @param {*} [thisArg] - callback execution context -* @throws {TypeError} must provide a recognized data type -* @throws {TypeError} must provide a length, typed array, array-like object, buffer, or iterable -* @throws {TypeError} callback argument must be a function. -* @throws {Error} creating a generic array from an `ArrayBuffer` is not supported -* @returns {(TypedArray|Array)} array or typed array -* -* @example -* var arr = filledarrayBy(); -* // returns -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'generic', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( [ 0.5, 0.5 ], clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1; -* } -* -* var arr = filledarrayBy( [ 5, -3 ], 'int32', clbk ); -* // returns [ 1, 1 ] -* -* @example -* function clbk1() { -* return 10; -* } -* -* function clbk2() { -* return 1.0; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, clbk2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk1() { -* return 1.0; -* } -* -* function clbk2() { -* return 2; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, 'uint32', clbk2 ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 'float32', clbk ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, clbk ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, 'int32', clbk ); -* // returns [ 1, 1 ] -*/ -function filledarrayBy() { - var thisArg; - var nargs; - var dtype; - var clbk; - var ctor; - var arr; - var len; - var arg; - - nargs = arguments.length; - - // If we weren't provided any arguments, return an empty array... - if ( nargs === 0 ) { - ctor = ctors( DEFAULT_DTYPE ); - return new ctor( 0 ); - } - // Check if we were provided a dtype as the first argument... - dtype = arguments[ 0 ]; - if ( isString( dtype ) ) { - // Invoking this function with arguments `f( dtype, clbk[, thisArg] )` is not allowed (otherwise, we'd need to also allow `f( clbk[, thisArg] )`)... - if ( nargs > 1 ) { - throw new TypeError( format('00h05') ); - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '00h2Y', dtype ) ); - } - // Return an empty array having the specified dtype: - return new ctor( 0 ); - } - // For all other supported invocations, we need at least two arguments... - if ( nargs < 2 ) { - throw new TypeError( format('00h05') ); - } - // At this point, we need to do some argument juggling... - nargs -= 1; // henceforth, the number of available arguments is `nargs+1` - - // Determine whether the last argument is a callback or "this" context... - if ( isFunction( arguments[ nargs ] ) ) { - // 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... - if ( isFunction( arguments[ nargs-1 ] ) ) { - thisArg = arguments[ nargs ]; - nargs -= 1; - clbk = arguments[ nargs ]; - - // Check if we were provided only a callback and a "this" context.. - if ( nargs === 0 ) { - throw new TypeError( format('00h05') ); - } - } else { - // "this" context is left undefined... - clbk = arguments[ nargs ]; - } - } - // 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... - else if ( nargs >= 2 ) { - thisArg = arguments[ nargs ]; - nargs -= 1; - clbk = arguments[ nargs ]; - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '00h2b', clbk ) ); - } - } - // If were were only provided 2 arguments and the last argument was not a function, we've been provided an insufficient number of arguments... - else { - throw new TypeError( format('00h05') ); - } - // Now that we've processed the callback arguments, let's continue working backward to see if we've been provided a `dtype` argument... - nargs -= 1; - if ( nargs >= 0 && isString( arguments[ nargs ] ) ) { - dtype = arguments[ nargs ]; - nargs -= 1; - } else { - dtype = DEFAULT_DTYPE; - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '00h2Y', dtype ) ); - } - // At this point, we've resolved the output array data type, and now we can actually create the output array... - if ( dtype === 'generic' ) { - arg = arguments[ 0 ]; - if ( nargs === 0 ) { - if ( isNonNegativeInteger( arg ) ) { - len = arg; - } else if ( isCollection( arg ) ) { - len = arg.length; - } - if ( len !== void 0 ) { - return filledArray( len, clbk, thisArg ); - } - if ( isArrayBuffer( arg ) ) { - throw new Error( format('00h04') ); - } - if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( '00h2Z', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00h2a', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00h2a', arg ) ); - } - return filledArrayIterator( arg, clbk, thisArg ); - } - throw new TypeError( format( '00h2a', arg ) ); - } else if ( isArrayBuffer( arg ) ) { - throw new Error( format('00h04') ); - } - throw new TypeError( format( '00h2a', arg ) ); - } - if ( nargs === 0 ) { // length || array-like || ArrayBuffer || iterable - arg = arguments[ 0 ]; - if ( isCollection( arg ) ) { - arr = new ctor( arg.length ); - } else if ( isArrayBuffer( arg ) ) { - arr = new ctor( arg ); - } else if ( isNonNegativeInteger( arg ) ) { - arr = new ctor( arg ); - } else if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( '00h2Z', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00h2a', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00h2a', arg ) ); - } - arr = new ctor( iterLength( arg ) ); - } else { - throw new TypeError( format( '00h2a', arg ) ); - } - } else if ( nargs === 1 ) { - arr = new ctor( arguments[0], arguments[1] ); // (ArrayBuffer, byteOffset) - } else { - arr = new ctor( arguments[0], arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset, length) - } - if ( arr.length > 0 ) { - if ( isComplexDataType( dtype ) || isBooleanDataType( dtype ) ) { - filledAccessors( arr, clbk, thisArg ); - } else { - gfillBy( arr.length, arr, 1, callback ); - } - } - return arr; - - /** - * Callback which wraps a provided callback and is invoked for each array element. - * - * @private - * @param {*} value - element value - * @param {NonNegativeInteger} aidx - array index - * @param {NonNegativeInteger} sidx - strided index - * @param {Collection} array - input array/collection - * @returns {*} callback return value - */ - function callback( value, aidx ) { - return clbk.call( thisArg, aidx ); - } -} - - -// EXPORTS // - -module.exports = filledarrayBy; diff --git a/package.json b/package.json index 032eb33..b16be36 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Create a filled array according to a provided callback function.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,75 +13,6 @@ "bugs": { "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", - "@stdlib/assert-has-iterator-symbol-support": "^0.2.1", - "@stdlib/assert-is-arraybuffer": "^0.2.1", - "@stdlib/assert-is-collection": "^0.2.1", - "@stdlib/assert-is-function": "^0.2.1", - "@stdlib/assert-is-nonnegative-integer": "^0.2.1", - "@stdlib/assert-is-object": "^0.2.1", - "@stdlib/assert-is-string": "^0.2.1", - "@stdlib/blas-ext-base-gfill-by": "^0.2.1", - "@stdlib/iter-length": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1", - "@stdlib/symbol-iterator": "^0.2.1", - "@stdlib/types": "^0.3.2", - "@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", - "@stdlib/array-float32": "^0.2.1", - "@stdlib/array-float64": "^0.2.1", - "@stdlib/array-int16": "^0.2.1", - "@stdlib/array-int32": "^0.2.1", - "@stdlib/array-int8": "^0.2.1", - "@stdlib/array-typed-real-dtypes": "^0.2.1", - "@stdlib/array-uint16": "^0.2.1", - "@stdlib/array-uint32": "^0.2.1", - "@stdlib/array-uint8": "^0.2.1", - "@stdlib/array-uint8c": "^0.2.1", - "@stdlib/assert-instance-of": "^0.2.1", - "@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": "^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", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.1" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..9137267 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index ca0cf25..0000000 --- a/test/test.js +++ /dev/null @@ -1,4397 +0,0 @@ -/** -* @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. -*/ - -/* eslint-disable max-len */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -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' ); -var iterConstant = require( '@stdlib/iter-constant' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var filledarrayBy = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': !hasIteratorSymbolSupport() -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof filledarrayBy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if only provided callback arguments', function test( t ) { - t.throws( clbk1, TypeError, 'throws an error' ); - t.throws( clbk2, TypeError, 'throws an error' ); - t.throws( clbk3, TypeError, 'throws an error' ); - t.end(); - - function clbk1() { - filledarrayBy( constantFunction( 1.0 ) ); - } - - function clbk2() { - filledarrayBy( constantFunction( 1.0 ), {} ); - } - - function clbk3() { - filledarrayBy( constantFunction( 1.0 ), constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (only argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (typed array; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (array-like object)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (array-like object; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 8 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 8 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, 1, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (iterator)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( iterConstant( 1.0 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (iterator; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( iterConstant( 1.0 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if only provided data type and callback arguments', function test( t ) { - t.throws( clbk1, TypeError, 'throws an error' ); - t.throws( clbk2, TypeError, 'throws an error' ); - t.throws( clbk3, TypeError, 'throws an error' ); - t.end(); - - function clbk1() { - filledarrayBy( 'float64', constantFunction( 1.0 ) ); - } - - function clbk2() { - filledarrayBy( 'float64', constantFunction( 1.0 ), {} ); - } - - function clbk3() { - filledarrayBy( 'float64', constantFunction( 1.0 ), constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (array-like object)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (array-like object; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, 1, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, 1, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (no iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (no iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (non-function iterator symbol property)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (non-function iterator symbol property; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (`next` property is not a function)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ) ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (`next` property is not a function; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ), {} ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (no iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (no iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (non-function iterator symbol property)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (non-function iterator symbol property; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (`next` property is not a function)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ) ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (`next` property is not a function; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ), {} ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 1, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 1, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function returns a filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - arr = filledarrayBy(); - - t.strictEqual( instanceOf( arr, Float64Array ), 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=float64)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - arr = filledarrayBy( 'float64' ); - - t.strictEqual( instanceOf( arr, Float64Array ), 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=float32)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( 0 ); - arr = filledarrayBy( 'float32' ); - - t.strictEqual( instanceOf( arr, Float32Array ), 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=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; - - expected = new Complex128Array( 0 ); - arr = filledarrayBy( 'complex128' ); - - t.strictEqual( instanceOf( arr, Complex128Array ), 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=complex64)', function test( t ) { - var expected; - var arr; - - expected = new Complex64Array( 0 ); - arr = filledarrayBy( 'complex64' ); - - t.strictEqual( instanceOf( arr, Complex64Array ), 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=int32)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( 0 ); - arr = filledarrayBy( 'int32' ); - - t.strictEqual( instanceOf( arr, Int32Array ), 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=uint32)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( 0 ); - arr = filledarrayBy( 'uint32' ); - - t.strictEqual( instanceOf( arr, Uint32Array ), 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=int16)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( 0 ); - arr = filledarrayBy( 'int16' ); - - t.strictEqual( instanceOf( arr, Int16Array ), 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=uint16)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( 0 ); - arr = filledarrayBy( 'uint16' ); - - t.strictEqual( instanceOf( arr, Uint16Array ), 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=int8)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( 0 ); - arr = filledarrayBy( 'int8' ); - - t.strictEqual( instanceOf( arr, Int8Array ), 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=uint8)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( 0 ); - arr = filledarrayBy( 'uint8' ); - - t.strictEqual( instanceOf( arr, Uint8Array ), 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=uint8c)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( 0 ); - arr = filledarrayBy( 'uint8c' ); - - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), 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=generic)', function test( t ) { - var expected; - var arr; - - expected = []; - arr = filledarrayBy( 'generic' ); - - t.strictEqual( instanceOf( arr, Array ), 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 (default, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, length=0)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array(); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 0, clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, clbk, ctx ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (default, length; thisArg=function)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, clbk, context ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this(); // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } - - function context() { - ctx.count += 1; - } -}); - -tape( 'the function returns a filled array (dtype=float64, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, 'float64', clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, length; thisArg=function)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, 'float64', clbk, context ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this(); // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } - - function context() { - ctx.count += 1; - } -}); - -tape( 'the function returns a filled array (dtype=float32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, 'float32', clbk ); - - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - 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; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = filledarrayBy( 5, 'complex128', clbk ); - - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = filledarrayBy( 5, 'complex64', clbk ); - - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int32Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int32', clbk ); - - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint32Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint32', clbk ); - - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int16Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int16', clbk ); - - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint16', clbk ); - - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int8Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int8', clbk ); - - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint8', clbk ); - - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint8c', clbk ); - - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = [ 1, 1, 1, 1, 1 ]; - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'generic', clbk ); - - t.strictEqual( instanceOf( arr, Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - 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; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = [ 1.0, 2.0 ]; - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = [ 1.0, 2.0 ]; - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int32', clbk ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, typed array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, typed array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - 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; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = new Float64Array( [ 1.0, 2.0 ] ); - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = new Float64Array( [ 1.0, 2.0 ] ); - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (default, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - 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; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer, byteoffset; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer, byteoffset; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - 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; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 48 ); - out = filledarrayBy( buf, 16, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 24 ); - out = filledarrayBy( buf, 8, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int32', clbk ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint8c', clbk ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - 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; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 64 ); - out = filledarrayBy( buf, 16, 2, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset, length)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 1, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 1, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled array (default, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, iterator; thisArg)', opts, function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - ctx = { - 'count': 0 - }; - indices = []; - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, iterator; thisArg)', opts, function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - ctx = { - 'count': 0 - }; - indices = []; - out = filledarrayBy( arr, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - 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; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = iterConstant( new Complex128( 3.0, 3.0 ), { - 'iter': 2 - }); - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = iterConstant( new Complex64( 3.0, 3.0 ), { - 'iter': 2 - }); - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); From fc3fba1b0d8c8bf32237368cd7c5ff6164deb866 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 28 Sep 2024 18:02:31 +0000 Subject: [PATCH 066/117] Transform error messages --- lib/main.js | 38 +++++++++++++++++++------------------- package.json | 2 +- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/lib/main.js b/lib/main.js index b322cfe..ed1aa9a 100644 --- a/lib/main.js +++ b/lib/main.js @@ -35,7 +35,7 @@ var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-supp var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); var iterLength = require( '@stdlib/iter-length' ); var defaults = require( '@stdlib/array-defaults' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -266,18 +266,18 @@ function filledarrayBy() { if ( isString( dtype ) ) { // Invoking this function with arguments `f( dtype, clbk[, thisArg] )` is not allowed (otherwise, we'd need to also allow `f( clbk[, thisArg] )`)... if ( nargs > 1 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format('00h05') ); } ctor = ctors( dtype ); if ( ctor === null ) { - throw new TypeError( format( 'invalid argument. Must provide a recognized data type. Value: `%s`.', dtype ) ); + throw new TypeError( format( '00h2Y', dtype ) ); } // Return an empty array having the specified dtype: return new ctor( 0 ); } // For all other supported invocations, we need at least two arguments... if ( nargs < 2 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format('00h05') ); } // At this point, we need to do some argument juggling... nargs -= 1; // henceforth, the number of available arguments is `nargs+1` @@ -292,7 +292,7 @@ function filledarrayBy() { // Check if we were provided only a callback and a "this" context.. if ( nargs === 0 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format('00h05') ); } } else { // "this" context is left undefined... @@ -305,12 +305,12 @@ function filledarrayBy() { nargs -= 1; clbk = arguments[ nargs ]; if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '00h2b', clbk ) ); } } // If were were only provided 2 arguments and the last argument was not a function, we've been provided an insufficient number of arguments... else { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format('00h05') ); } // Now that we've processed the callback arguments, let's continue working backward to see if we've been provided a `dtype` argument... nargs -= 1; @@ -322,7 +322,7 @@ function filledarrayBy() { } ctor = ctors( dtype ); if ( ctor === null ) { - throw new TypeError( format( 'invalid argument. Must provide a recognized data type. Value: `%s`.', dtype ) ); + throw new TypeError( format( '00h2Y', dtype ) ); } // At this point, we've resolved the output array data type, and now we can actually create the output array... if ( dtype === 'generic' ) { @@ -337,26 +337,26 @@ function filledarrayBy() { return filledArray( len, clbk, thisArg ); } if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format('00h04') ); } if ( isObject( arg ) ) { if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2Z', arg ) ); } if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } arg = arg[ ITERATOR_SYMBOL ](); if ( !isFunction( arg.next ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } return filledArrayIterator( arg, clbk, thisArg ); } - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } else if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format('00h04') ); } - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } if ( nargs === 0 ) { // length || array-like || ArrayBuffer || iterable arg = arguments[ 0 ]; @@ -368,18 +368,18 @@ function filledarrayBy() { arr = new ctor( arg ); } else if ( isObject( arg ) ) { if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2Z', arg ) ); } if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } arg = arg[ ITERATOR_SYMBOL ](); if ( !isFunction( arg.next ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } arr = new ctor( iterLength( arg ) ); } else { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } } else if ( nargs === 1 ) { arr = new ctor( arguments[0], arguments[1] ); // (ArrayBuffer, byteOffset) diff --git a/package.json b/package.json index c089d32..d01aec1 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "@stdlib/assert-is-string": "^0.2.2", "@stdlib/blas-ext-base-gfill-by": "^0.2.1", "@stdlib/iter-length": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/symbol-iterator": "^0.2.2", "@stdlib/types": "^0.4.1", "@stdlib/error-tools-fmtprodmsg": "^0.2.2" From b1e7afa87dab438143a202f9f03b7e629d0792a4 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 28 Sep 2024 18:03:10 +0000 Subject: [PATCH 067/117] Remove files --- index.d.ts | 322 ---- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5169 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index c8f0e9a..0000000 --- a/index.d.ts +++ /dev/null @@ -1,322 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, RealOrComplexTypedArray, BooleanArray, DataType } from '@stdlib/types/array'; -import { IterableIterator } from '@stdlib/types/iter'; - -/** -* Array or typed array. -*/ -type ArrayOrTypedArray = Array | RealOrComplexTypedArray | BooleanArray; - -/** -* Nullary callback function. -* -* @returns fill value -*/ -type Nullary = () => any; - -/** -* Unary callback function. -* -* @param i - current array index -* @returns fill value -*/ -type Unary = ( i: number ) => any; - -/** -* Callback function. -* -* @param i - current array index -* @returns fill value -*/ -type Callback = Nullary | Unary; - -/** -* Creates a filled array according to a provided callback function and having a specified data type. -* -* @param dtype - data type -* @returns filled array -* -* @example -* var arr = filledarrayBy(); -* // returns -* -* @example -* var arr = filledarrayBy( 'float32' ); -* // returns -*/ -declare function filledarrayBy( dtype?: DataType ): ArrayOrTypedArray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Creates a filled array according to a provided callback function and having a specified `length`. -* -* @param length - array length -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* -* var arr = filledarrayBy( 5, constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( length: number, clbk: Callback, thisArg?: any ): ArrayOrTypedArray; - -/** -* Creates a filled array according to a provided callback function and having a specified `length`. -* -* @param length - array length -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* -* var arr = filledarrayBy( 5, 'float64', constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( length: number, dtype: DataType, clbk: Callback, thisArg?: any ): ArrayOrTypedArray; - -/** -* Creates a filled array from another `array` according to a provided callback function. -* -* @param array - typed array or array-like object -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* -* 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; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Creates a filled array from another `array` according to a provided callback function. -* -* @param array - typed array or array-like object -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* -* 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; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Creates a filled array from an iterable according to a callback function. -* -* @param iterable - iterable -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var iterConstant = require( '@stdlib/iter-constant' ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarrayBy( it, constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -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. -* -* @param iterable - iterable -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var iterConstant = require( '@stdlib/iter-constant' ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* 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; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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 | BooleanArray; - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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 | BooleanArray; - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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 | BooleanArray; - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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 | BooleanArray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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 | BooleanArray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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 | BooleanArray; // eslint-disable-line @typescript-eslint/unified-signatures - - -// EXPORTS // - -export = filledarrayBy; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index c9e97c3..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.1-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@v0.0.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.1-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-ctors@v0.2.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill-by@v0.2.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled-by@v0.2.1-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.2.1-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@v0.2.1-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.2.1-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";var v=f(),g=j.get("dtypes.default");function c(){var f,j,c,b,y,x,u,E;if(0===(j=arguments.length))return new(y=d(g))(0);if(r(c=arguments[0])){if(j>1)throw new TypeError(w("00h05"));if(null===(y=d(c)))throw new TypeError(w("00h2Y",c));return new y(0)}if(j<2)throw new TypeError(w("00h05"));if(h(arguments[j-=1]))if(h(arguments[j-1])){if(f=arguments[j],b=arguments[j-=1],0===j)throw new TypeError(w("00h05"))}else b=arguments[j];else{if(!(j>=2))throw new TypeError(w("00h05"));if(f=arguments[j],!h(b=arguments[j-=1]))throw new TypeError(w("00h2b",b))}if((j-=1)>=0&&r(arguments[j])?(c=arguments[j],j-=1):c=g,null===(y=d(c)))throw new TypeError(w("00h2Y",c));if("generic"===c){if(E=arguments[0],0===j){if(e(E)?u=E:i(E)&&(u=E.length),void 0!==u)return m(u,b,f);if(n(E))throw new Error(w("00h04"));if(o(E)){if(!1===v)throw new TypeError(w("00h2Z",E));if(!h(E[p]))throw new TypeError(w("00h2a",E));if(E=E[p](),!h(E.next))throw new TypeError(w("00h2a",E));return function(r,e,t){var s,i;for(s=[],i=-1;!r.next().done;)i+=1,s.push(e.call(t,i));return s}(E,b,f)}throw new TypeError(w("00h2a",E))}if(n(E))throw new Error(w("00h04"));throw new TypeError(w("00h2a",E))}if(0===j)if(i(E=arguments[0]))x=new y(E.length);else if(n(E))x=new y(E);else if(e(E))x=new y(E);else{if(!o(E))throw new TypeError(w("00h2a",E));if(!1===v)throw new TypeError(w("00h2Z",E));if(!h(E[p]))throw new TypeError(w("00h2a",E));if(E=E[p](),!h(E.next))throw new TypeError(w("00h2a",E));x=new y(a(E))}else x=1===j?new y(arguments[0],arguments[1]):new y(arguments[0],arguments[1],arguments[2]);return x.length>0&&(t(c)||s(c)?function(r,e,t){var s;for(s=0;s\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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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( format('00h05') );\n\t\t}\n\t\tctor = ctors( dtype );\n\t\tif ( ctor === null ) {\n\t\t\tthrow new TypeError( format( '00h2Y', 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( format('00h05') );\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( format('00h05') );\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( '00h2b', 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( format('00h05') );\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( '00h2Y', 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( format('00h04') );\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( '00h2Z', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00h2a', 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( '00h2a', 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( '00h2a', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format('00h04') );\n\t\t}\n\t\tthrow new TypeError( format( '00h2a', 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( '00h2Z', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00h2a', 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( '00h2a', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00h2a', 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\nexport default filledarrayBy;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","DEFAULT_DTYPE","defaults","get","filledarrayBy","thisArg","nargs","dtype","clbk","ctor","arr","len","arg","arguments","length","ctors","isString","TypeError","format","isFunction","isNonNegativeInteger","isCollection","filledArray","isArrayBuffer","Error","isObject","ITERATOR_SYMBOL","next","it","i","done","push","call","filledArrayIterator","iterLength","isComplexDataType","isBooleanDataType","set","filledAccessors","gfillBy","value","aidx"],"mappings":";;sjDA0CA,IAAIA,EAAsBC,IACtBC,EAAgBC,EAASC,IAAK,kBA2MlC,SAASC,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAKJ,GAAe,KAHfN,EAAQO,UAAUC,QAKjB,OAAO,IADPL,EAAOM,EAAOd,IACG,GAIlB,GAAKe,EADLT,EAAQM,UAAW,IACM,CAExB,GAAKP,EAAQ,EACZ,MAAM,IAAIW,UAAWC,EAAO,UAG7B,GAAc,QADdT,EAAOM,EAAOR,IAEb,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,OAAO,IAAIE,EAAM,EACjB,CAED,GAAKH,EAAQ,EACZ,MAAM,IAAIW,UAAWC,EAAO,UAM7B,GAAKC,EAAYN,UAHjBP,GAAS,IAKR,GAAKa,EAAYN,UAAWP,EAAM,KAMjC,GALAD,EAAUQ,UAAWP,GAErBE,EAAOK,UADPP,GAAS,GAIM,IAAVA,EACJ,MAAM,IAAIW,UAAWC,EAAO,eAI7BV,EAAOK,UAAWP,OAIf,MAAKA,GAAS,GAUlB,MAAM,IAAIW,UAAWC,EAAO,UAN5B,GAHAb,EAAUQ,UAAWP,IAGfa,EADNX,EAAOK,UADPP,GAAS,IAGR,MAAM,IAAIW,UAAWC,EAAQ,QAASV,GAMvC,CAUD,IARAF,GAAS,IACK,GAAKU,EAAUH,UAAWP,KACvCC,EAAQM,UAAWP,GACnBA,GAAS,GAETC,EAAQN,EAGK,QADdQ,EAAOM,EAAOR,IAEb,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,GAAe,YAAVA,EAAsB,CAE1B,GADAK,EAAMC,UAAW,GACF,IAAVP,EAAc,CAMlB,GALKc,EAAsBR,GAC1BD,EAAMC,EACKS,EAAcT,KACzBD,EAAMC,EAAIE,aAEE,IAARH,EACJ,OAAOW,EAAaX,EAAKH,EAAMH,GAEhC,GAAKkB,EAAeX,GACnB,MAAM,IAAIY,MAAON,EAAO,UAEzB,GAAKO,EAAUb,GAAQ,CACtB,IAA6B,IAAxBb,EACJ,MAAM,IAAIkB,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAYP,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLP,EAAYP,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvC,OAvSJ,SAA8BgB,EAAIpB,EAAMH,GACvC,IAAIK,EACAmB,EAKJ,IAFAnB,EAAM,GACNmB,GAAK,GAEAD,EAAGD,OACAG,MAGPD,GAAK,EACLnB,EAAIqB,KAAMvB,EAAKwB,KAAM3B,EAASwB,IAE/B,OAAOnB,CACR,CAuRWuB,CAAqBrB,EAAKJ,EAAMH,EACvC,CACD,MAAM,IAAIY,UAAWC,EAAQ,QAASN,GACzC,CAAS,GAAKW,EAAeX,GAC1B,MAAM,IAAIY,MAAON,EAAO,UAEzB,MAAM,IAAID,UAAWC,EAAQ,QAASN,GACtC,CACD,GAAe,IAAVN,EAEJ,GAAKe,EADLT,EAAMC,UAAW,IAEhBH,EAAM,IAAID,EAAMG,EAAIE,aACd,GAAKS,EAAeX,GAC1BF,EAAM,IAAID,EAAMG,QACV,GAAKQ,EAAsBR,GACjCF,EAAM,IAAID,EAAMG,OACV,KAAKa,EAAUb,GAarB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAZtC,IAA6B,IAAxBb,EACJ,MAAM,IAAIkB,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAYP,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLP,EAAYP,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvCF,EAAM,IAAID,EAAMyB,EAAYtB,GAG5B,MAEDF,EADqB,IAAVJ,EACL,IAAIG,EAAMI,UAAU,GAAIA,UAAU,IAElC,IAAIJ,EAAMI,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKH,EAAII,OAAS,IACZqB,EAAmB5B,IAAW6B,EAAmB7B,GAjTxD,SAA0BG,EAAKF,EAAMH,GACpC,IAAIwB,EACJ,IAAMA,EAAI,EAAGA,EAAInB,EAAII,OAAQe,IAC5BnB,EAAI2B,IAAK7B,EAAKwB,KAAM3B,EAASwB,GAAKA,EAGpC,CA4SGS,CAAiB5B,EAAKF,EAAMH,GAE5BkC,EAAS7B,EAAII,OAAQJ,EAAK,GAe5B,SAAmB8B,EAAOC,GACzB,OAAOjC,EAAKwB,KAAM3B,EAASoC,EAC3B,KAdM/B,CAeR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 9137267..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From fb7875176fba5c802da84c234d2aae614be74bd3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 28 Sep 2024 18:03:29 +0000 Subject: [PATCH 068/117] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 252 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 190 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 49 +- SECURITY.md | 5 - benchmark/benchmark.js | 341 -- benchmark/benchmark.length.bool.js | 97 - benchmark/benchmark.length.complex128.js | 98 - benchmark/benchmark.length.complex64.js | 98 - benchmark/benchmark.length.float32.js | 97 - benchmark/benchmark.length.float64.js | 97 - benchmark/benchmark.length.generic.js | 97 - benchmark/benchmark.length.int16.js | 97 - benchmark/benchmark.length.int32.js | 97 - benchmark/benchmark.length.int8.js | 97 - benchmark/benchmark.length.uint16.js | 97 - benchmark/benchmark.length.uint32.js | 97 - benchmark/benchmark.length.uint8.js | 97 - benchmark/benchmark.length.uint8c.js | 97 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 36 - dist/index.js.map | 7 - docs/repl.txt | 157 - docs/types/test.ts | 606 --- examples/index.js | 37 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 192 - lib/main.js | 416 -- package.json | 96 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 4397 ------------------- 55 files changed, 4870 insertions(+), 11038 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.length.bool.js delete mode 100644 benchmark/benchmark.length.complex128.js delete mode 100644 benchmark/benchmark.length.complex64.js delete mode 100644 benchmark/benchmark.length.float32.js delete mode 100644 benchmark/benchmark.length.float64.js delete mode 100644 benchmark/benchmark.length.generic.js delete mode 100644 benchmark/benchmark.length.int16.js delete mode 100644 benchmark/benchmark.length.int32.js delete mode 100644 benchmark/benchmark.length.int8.js delete mode 100644 benchmark/benchmark.length.uint16.js delete mode 100644 benchmark/benchmark.length.uint32.js delete mode 100644 benchmark/benchmark.length.uint8.js delete mode 100644 benchmark/benchmark.length.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 8be0b82..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index f988046..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index b2c1f9c..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '42 6 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -278,7 +269,7 @@ for ( i = 0; i < dt.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -347,13 +338,13 @@ 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/dtypes]: https://github.com/stdlib-js/array-dtypes/tree/esm -[@stdlib/array/filled]: https://github.com/stdlib-js/array-filled +[@stdlib/array/filled]: https://github.com/stdlib-js/array-filled/tree/esm -[@stdlib/array/typed]: https://github.com/stdlib-js/array-typed +[@stdlib/array/typed]: https://github.com/stdlib-js/array-typed/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 17cfb5a..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,341 +0,0 @@ -/** -* @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 isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); -var isArray = require( '@stdlib/assert-is-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var Complex64 = require( '@stdlib/complex-float32-ctor' ); -var Complex128 = require( '@stdlib/complex-float64-ctor' ); -var pkg = require( './../package.json' ).name; -var filledarrayBy = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 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=float64', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'float64', 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=float32', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'float32', 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=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; - var i; - - clbk = constantFunction( new Complex128( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'complex128', 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=complex64', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( new Complex64( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'complex64', 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=int32', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int32', 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=uint32', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint32', 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=int16', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int16', 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=uint16', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint16', 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=int8', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int8', 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=uint8', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint8', 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=uint8c', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint8c', 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=generic', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'generic', clbk ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.length.bool.js b/benchmark/benchmark.length.bool.js deleted file mode 100644 index 3cdd152..0000000 --- a/benchmark/benchmark.length.bool.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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/benchmark/benchmark.length.complex128.js b/benchmark/benchmark.length.complex128.js deleted file mode 100644 index 122bc7c..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 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 Complex128 = require( '@stdlib/complex-float64-ctor' ); -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( new Complex128( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'complex128', 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=complex128,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.complex64.js b/benchmark/benchmark.length.complex64.js deleted file mode 100644 index e7a2d74..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 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 Complex64 = require( '@stdlib/complex-float32-ctor' ); -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( new Complex64( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'complex64', 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=complex64,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.float32.js b/benchmark/benchmark.length.float32.js deleted file mode 100644 index d2b2ba7..0000000 --- a/benchmark/benchmark.length.float32.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'float32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=float32,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.float64.js b/benchmark/benchmark.length.float64.js deleted file mode 100644 index 65064e3..0000000 --- a/benchmark/benchmark.length.float64.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'float64', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=float64,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.generic.js b/benchmark/benchmark.length.generic.js deleted file mode 100644 index eb87dfa..0000000 --- a/benchmark/benchmark.length.generic.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isArray = require( '@stdlib/assert-is-array' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'generic', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isArray( 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=generic,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int16.js b/benchmark/benchmark.length.int16.js deleted file mode 100644 index 914ff7c..0000000 --- a/benchmark/benchmark.length.int16.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int16', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=int16,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int32.js b/benchmark/benchmark.length.int32.js deleted file mode 100644 index cc0f678..0000000 --- a/benchmark/benchmark.length.int32.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=int32,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int8.js b/benchmark/benchmark.length.int8.js deleted file mode 100644 index 77553b0..0000000 --- a/benchmark/benchmark.length.int8.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int8', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=int8,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint16.js b/benchmark/benchmark.length.uint16.js deleted file mode 100644 index c68efdd..0000000 --- a/benchmark/benchmark.length.uint16.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint16', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint16,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint32.js b/benchmark/benchmark.length.uint32.js deleted file mode 100644 index 27c1742..0000000 --- a/benchmark/benchmark.length.uint32.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint32,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint8.js b/benchmark/benchmark.length.uint8.js deleted file mode 100644 index 2a26be4..0000000 --- a/benchmark/benchmark.length.uint8.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint8', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint8,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint8c.js b/benchmark/benchmark.length.uint8c.js deleted file mode 100644 index dd6e8c2..0000000 --- a/benchmark/benchmark.length.uint8c.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint8c', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint8c,len='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index c138144..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by" -%% click B href "https://github.com/stdlib-js/array-filled-by/tree/main" -%% click C href "https://github.com/stdlib-js/array-filled-by/tree/production" -%% click D href "https://github.com/stdlib-js/array-filled-by/tree/esm" -%% click E href "https://github.com/stdlib-js/array-filled-by/tree/deno" -%% click F href "https://github.com/stdlib-js/array-filled-by/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by -[production-url]: https://github.com/stdlib-js/array-filled-by/tree/production -[deno-url]: https://github.com/stdlib-js/array-filled-by/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-filled-by/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-filled-by/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-filled-by/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-filled-by/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-filled-by/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 188fc9b..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import filledarrayBy from '../docs/types/index'; -export = filledarrayBy; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 65ae3db..0000000 --- a/dist/index.js +++ /dev/null @@ -1,36 +0,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 deleted file mode 100644 index e88f9aa..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "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,YACjDC,EAAuB,QAAS,uCAAwC,EAAE,YAC1EC,EAAoB,QAAS,+DAAgE,EAC7FC,EAAoB,QAAS,gDAAiD,EAC9EC,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,EAAQ,UAAU,OAGbA,IAAU,EACd,OAAAE,EAAOrB,EAAOS,CAAc,EACrB,IAAIY,EAAM,CAAE,EAIpB,GADAD,EAAQ,UAAW,CAAE,EAChB5B,EAAU4B,CAAM,EAAI,CAExB,GAAKD,EAAQ,EACZ,MAAM,IAAI,UAAW,2FAA4F,EAGlH,GADAE,EAAOrB,EAAOoB,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWd,EAAQ,sEAAuEa,CAAM,CAAE,EAG7G,OAAO,IAAIC,EAAM,CAAE,CACpB,CAEA,GAAKF,EAAQ,EACZ,MAAM,IAAI,UAAW,2FAA4F,EAMlH,GAHAA,GAAS,EAGJpB,EAAY,UAAWoB,CAAM,CAAE,EAEnC,GAAKpB,EAAY,UAAWoB,EAAM,CAAE,CAAE,GAMrC,GALAN,EAAU,UAAWM,CAAM,EAC3BA,GAAS,EACTP,EAAO,UAAWO,CAAM,EAGnBA,IAAU,EACd,MAAM,IAAI,UAAW,2FAA4F,OAIlHP,EAAO,UAAWO,CAAM,UAIhBA,GAAS,GAIlB,GAHAN,EAAU,UAAWM,CAAM,EAC3BA,GAAS,EACTP,EAAO,UAAWO,CAAM,EACnB,CAACpB,EAAYa,CAAK,EACtB,MAAM,IAAI,UAAWL,EAAQ,uEAAwEK,CAAK,CAAE,MAK7G,OAAM,IAAI,UAAW,2FAA4F,EAWlH,GARAO,GAAS,EACJA,GAAS,GAAK3B,EAAU,UAAW2B,CAAM,CAAE,GAC/CC,EAAQ,UAAWD,CAAM,EACzBA,GAAS,GAETC,EAAQX,EAETY,EAAOrB,EAAOoB,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWd,EAAQ,sEAAuEa,CAAM,CAAE,EAG7G,GAAKA,IAAU,UAAY,CAE1B,GADAG,EAAM,UAAW,CAAE,EACdJ,IAAU,EAAI,CAMlB,GALK1B,EAAsB8B,CAAI,EAC9BD,EAAMC,EACK3B,EAAc2B,CAAI,IAC7BD,EAAMC,EAAI,QAEND,IAAQ,OACZ,OAAOpB,EAAaoB,EAAKV,EAAMC,CAAQ,EAExC,GAAKhB,EAAe0B,CAAI,EACvB,MAAM,IAAI,MAAO,mFAAoF,EAEtG,GAAKzB,EAAUyB,CAAI,EAAI,CACtB,GAAKf,IAAwB,GAC5B,MAAM,IAAI,UAAWD,EAAQ,sIAAuIgB,CAAI,CAAE,EAE3K,GAAK,CAACxB,EAAYwB,EAAKnB,CAAgB,CAAE,EACxC,MAAM,IAAI,UAAWG,EAAQ,wGAAyGgB,CAAI,CAAE,EAG7I,GADAA,EAAMA,EAAKnB,CAAgB,EAAE,EACxB,CAACL,EAAYwB,EAAI,IAAK,EAC1B,MAAM,IAAI,UAAWhB,EAAQ,wGAAyGgB,CAAI,CAAE,EAE7I,OAAOb,EAAqBa,EAAKX,EAAMC,CAAQ,CAChD,CACA,MAAM,IAAI,UAAWN,EAAQ,wGAAyGgB,CAAI,CAAE,CAC7I,SAAY1B,EAAe0B,CAAI,EAC9B,MAAM,IAAI,MAAO,mFAAoF,EAEtG,MAAM,IAAI,UAAWhB,EAAQ,wGAAyGgB,CAAI,CAAE,CAC7I,CACA,GAAKJ,IAAU,EAEd,GADAI,EAAM,UAAW,CAAE,EACd3B,EAAc2B,CAAI,EACtBT,EAAM,IAAIO,EAAME,EAAI,MAAO,UAChB1B,EAAe0B,CAAI,EAC9BT,EAAM,IAAIO,EAAME,CAAI,UACT9B,EAAsB8B,CAAI,EACrCT,EAAM,IAAIO,EAAME,CAAI,UACTzB,EAAUyB,CAAI,EAAI,CAC7B,GAAKf,IAAwB,GAC5B,MAAM,IAAI,UAAWD,EAAQ,sIAAuIgB,CAAI,CAAE,EAE3K,GAAK,CAACxB,EAAYwB,EAAKnB,CAAgB,CAAE,EACxC,MAAM,IAAI,UAAWG,EAAQ,wGAAyGgB,CAAI,CAAE,EAG7I,GADAA,EAAMA,EAAKnB,CAAgB,EAAE,EACxB,CAACL,EAAYwB,EAAI,IAAK,EAC1B,MAAM,IAAI,UAAWhB,EAAQ,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,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 deleted file mode 100644 index 06f3146..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,157 +0,0 @@ - -{{alias}}( [dtype] ) - Creates a filled array. - - Parameters - ---------- - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr = {{alias}}() - - > arr = {{alias}}( 'float32' ) - - - -{{alias}}( length[, dtype], clbk[, thisArg] ) - Returns a filled array according to a provided callback function and having - a specified length. - - Parameters - ---------- - length: integer - Array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > function clbk() { return 1.0; }; - > var arr = {{alias}}( 5, clbk ) - [ 1.0, 1.0, 1.0, 1.0, 1.0 ] - > arr = {{alias}}( 5, 'int32', clbk ) - [ 1, 1, 1, 1, 1 ] - - -{{alias}}( array[, dtype], clbk[, thisArg] ) - Creates a filled array from another array (or array-like object) according - to a provided callback function. - - Parameters - ---------- - array: ArrayLikeObject - Array from which to generate another array. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias}}( [ 0.5, 0.5, 0.5 ], {{alias:@stdlib/utils/constant-function}}( 2.0 ) ) - [ 2.0, 2.0, 2.0 ] - > var arr2 = {{alias}}( arr1, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( iterable[, dtype], clbk[, thisArg] ) - Creates a filled array from an iterable according to a provided callback - function. - - Parameters - ---------- - iterable: Iterable - Iterable from which to generate an array. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias:@stdlib/iter/constant}}( 3.0, {'iter': 3} ); - > var arr2 = {{alias}}( arr1, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( buffer[, byteOffset[, length]][, dtype], clbk[, thisArg] ) - Returns a filled typed array view of an ArrayBuffer according to a provided - callback function. - - The 'generic' array data type is *not* supported. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( buf, 0, 4, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0, 1.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 394ac49..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,606 +0,0 @@ -/* -* @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. -*/ - -/// - -import { IterableIterator } from '@stdlib/types/iter'; -import filledarrayBy = require( './index' ); - - -/** -* Returns an iterator protocol-compliant object. -* -* @returns iterator protocol-compliant object -*/ -function iterator(): IterableIterator { - const obj: IterableIterator = { - [Symbol.iterator]: iterator, - 'next': next - }; - return obj; -} - -/** -* Implements the iterator protocol `next` method. -* -* @returns iterator protocol-compliant object -*/ -function next(): any { - return { - 'value': 1.0, - 'done': false - }; -} - -/** -* Callback function. -* -* @param i - current array index -* @returns return value -*/ -function clbk( i: number ): number { - return i; -} - - -// TESTS // - -// The function returns an array or typed array... -{ - filledarrayBy(); // $ExpectType ArrayOrTypedArray - filledarrayBy( 'float32' ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( 10, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( 10, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( 10, 'int32', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( 10, 'int32', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const x = new Float64Array( 10 ); - filledarrayBy( x, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( x, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( x, 'uint8', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( x, 'uint8', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const y = [ 2.0, 2.0, 2.0 ]; - filledarrayBy( y, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( y, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( y, 'float64', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( y, 'float64', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const it = iterator(); - filledarrayBy( it, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( it, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( it, 'uint8c', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( it, 'uint8c', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const buf = new ArrayBuffer( 32 ); - filledarrayBy( buf, clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 'uint32', clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 'uint32', clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 8, clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 8, clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 8, 'uint16', clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 8, 'uint16', clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 8, 2, clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 8, 2, clbk, {} ); // $ExpectType RealOrComplexTypedArray - - filledarrayBy( buf, 8, 2, 'int16', clbk ); // $ExpectType RealOrComplexTypedArray - filledarrayBy( buf, 8, 2, 'int16', clbk, {} ); // $ExpectType RealOrComplexTypedArray -} - -// The compiler throws an error if a callback function argument is not a function... -{ - filledarrayBy( 'float64', '5' ); // $ExpectError - filledarrayBy( 'float64', 1.0 ); // $ExpectError - filledarrayBy( 'float64', false ); // $ExpectError - filledarrayBy( 'float64', true ); // $ExpectError - filledarrayBy( 'float64', null ); // $ExpectError - filledarrayBy( 'float64', undefined ); // $ExpectError - filledarrayBy( 'float64', [] ); // $ExpectError - filledarrayBy( 'float64', {} ); // $ExpectError - - filledarrayBy( 'float64', '5', {} ); // $ExpectError - filledarrayBy( 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( 'float64', false, {} ); // $ExpectError - filledarrayBy( 'float64', true, {} ); // $ExpectError - filledarrayBy( 'float64', null, {} ); // $ExpectError - filledarrayBy( 'float64', undefined, {} ); // $ExpectError - filledarrayBy( 'float64', [], {} ); // $ExpectError - filledarrayBy( 'float64', {}, {} ); // $ExpectError - - filledarrayBy( 10, '5' ); // $ExpectError - filledarrayBy( 10, 1.0 ); // $ExpectError - filledarrayBy( 10, false ); // $ExpectError - filledarrayBy( 10, true ); // $ExpectError - filledarrayBy( 10, null ); // $ExpectError - filledarrayBy( 10, undefined ); // $ExpectError - filledarrayBy( 10, [] ); // $ExpectError - filledarrayBy( 10, {} ); // $ExpectError - - filledarrayBy( 10, '5', {} ); // $ExpectError - filledarrayBy( 10, 1.0, {} ); // $ExpectError - filledarrayBy( 10, false, {} ); // $ExpectError - filledarrayBy( 10, true, {} ); // $ExpectError - filledarrayBy( 10, null, {} ); // $ExpectError - filledarrayBy( 10, undefined, {} ); // $ExpectError - filledarrayBy( 10, [], {} ); // $ExpectError - filledarrayBy( 10, {}, {} ); // $ExpectError - - filledarrayBy( 10, 'float64', '5' ); // $ExpectError - filledarrayBy( 10, 'float64', 1.0 ); // $ExpectError - filledarrayBy( 10, 'float64', false ); // $ExpectError - filledarrayBy( 10, 'float64', true ); // $ExpectError - filledarrayBy( 10, 'float64', null ); // $ExpectError - filledarrayBy( 10, 'float64', undefined ); // $ExpectError - filledarrayBy( 10, 'float64', [] ); // $ExpectError - filledarrayBy( 10, 'float64', {} ); // $ExpectError - - filledarrayBy( 10, 'float64', '5', {} ); // $ExpectError - filledarrayBy( 10, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( 10, 'float64', false, {} ); // $ExpectError - filledarrayBy( 10, 'float64', true, {} ); // $ExpectError - filledarrayBy( 10, 'float64', null, {} ); // $ExpectError - filledarrayBy( 10, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( 10, 'float64', [], {} ); // $ExpectError - filledarrayBy( 10, 'float64', {}, {} ); // $ExpectError - - const x = new Float64Array( 10 ); - filledarrayBy( x, '5' ); // $ExpectError - filledarrayBy( x, 1.0 ); // $ExpectError - filledarrayBy( x, false ); // $ExpectError - filledarrayBy( x, true ); // $ExpectError - filledarrayBy( x, null ); // $ExpectError - filledarrayBy( x, undefined ); // $ExpectError - filledarrayBy( x, [] ); // $ExpectError - filledarrayBy( x, {} ); // $ExpectError - - filledarrayBy( x, '5', {} ); // $ExpectError - filledarrayBy( x, 1.0, {} ); // $ExpectError - filledarrayBy( x, false, {} ); // $ExpectError - filledarrayBy( x, true, {} ); // $ExpectError - filledarrayBy( x, null, {} ); // $ExpectError - filledarrayBy( x, undefined, {} ); // $ExpectError - filledarrayBy( x, [], {} ); // $ExpectError - filledarrayBy( x, {}, {} ); // $ExpectError - - filledarrayBy( x, 'float64', '5' ); // $ExpectError - filledarrayBy( x, 'float64', 1.0 ); // $ExpectError - filledarrayBy( x, 'float64', false ); // $ExpectError - filledarrayBy( x, 'float64', true ); // $ExpectError - filledarrayBy( x, 'float64', null ); // $ExpectError - filledarrayBy( x, 'float64', undefined ); // $ExpectError - filledarrayBy( x, 'float64', [] ); // $ExpectError - filledarrayBy( x, 'float64', {} ); // $ExpectError - - filledarrayBy( x, 'float64', '5', {} ); // $ExpectError - filledarrayBy( x, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( x, 'float64', false, {} ); // $ExpectError - filledarrayBy( x, 'float64', true, {} ); // $ExpectError - filledarrayBy( x, 'float64', null, {} ); // $ExpectError - filledarrayBy( x, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( x, 'float64', [], {} ); // $ExpectError - filledarrayBy( x, 'float64', {}, {} ); // $ExpectError - - const y = [ 2.0, 2.0, 2.0 ]; - filledarrayBy( y, '5' ); // $ExpectError - filledarrayBy( y, 1.0 ); // $ExpectError - filledarrayBy( y, false ); // $ExpectError - filledarrayBy( y, true ); // $ExpectError - filledarrayBy( y, null ); // $ExpectError - filledarrayBy( y, undefined ); // $ExpectError - filledarrayBy( y, [] ); // $ExpectError - filledarrayBy( y, {} ); // $ExpectError - - filledarrayBy( y, '5', {} ); // $ExpectError - filledarrayBy( y, 1.0, {} ); // $ExpectError - filledarrayBy( y, false, {} ); // $ExpectError - filledarrayBy( y, true, {} ); // $ExpectError - filledarrayBy( y, null, {} ); // $ExpectError - filledarrayBy( y, undefined, {} ); // $ExpectError - filledarrayBy( y, [], {} ); // $ExpectError - filledarrayBy( y, {}, {} ); // $ExpectError - - filledarrayBy( y, 'float64', '5' ); // $ExpectError - filledarrayBy( y, 'float64', 1.0 ); // $ExpectError - filledarrayBy( y, 'float64', false ); // $ExpectError - filledarrayBy( y, 'float64', true ); // $ExpectError - filledarrayBy( y, 'float64', null ); // $ExpectError - filledarrayBy( y, 'float64', undefined ); // $ExpectError - filledarrayBy( y, 'float64', [] ); // $ExpectError - filledarrayBy( y, 'float64', {} ); // $ExpectError - - filledarrayBy( y, 'float64', '5', {} ); // $ExpectError - filledarrayBy( y, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( y, 'float64', false, {} ); // $ExpectError - filledarrayBy( y, 'float64', true, {} ); // $ExpectError - filledarrayBy( y, 'float64', null, {} ); // $ExpectError - filledarrayBy( y, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( y, 'float64', [], {} ); // $ExpectError - filledarrayBy( y, 'float64', {}, {} ); // $ExpectError - - const it = iterator(); - filledarrayBy( it, '5' ); // $ExpectError - filledarrayBy( it, 1.0 ); // $ExpectError - filledarrayBy( it, false ); // $ExpectError - filledarrayBy( it, true ); // $ExpectError - filledarrayBy( it, null ); // $ExpectError - filledarrayBy( it, undefined ); // $ExpectError - filledarrayBy( it, [] ); // $ExpectError - filledarrayBy( it, {} ); // $ExpectError - - filledarrayBy( it, '5', {} ); // $ExpectError - filledarrayBy( it, 1.0, {} ); // $ExpectError - filledarrayBy( it, false, {} ); // $ExpectError - filledarrayBy( it, true, {} ); // $ExpectError - filledarrayBy( it, null, {} ); // $ExpectError - filledarrayBy( it, undefined, {} ); // $ExpectError - filledarrayBy( it, [], {} ); // $ExpectError - filledarrayBy( it, {}, {} ); // $ExpectError - - filledarrayBy( it, 'float64', '5' ); // $ExpectError - filledarrayBy( it, 'float64', 1.0 ); // $ExpectError - filledarrayBy( it, 'float64', false ); // $ExpectError - filledarrayBy( it, 'float64', true ); // $ExpectError - filledarrayBy( it, 'float64', null ); // $ExpectError - filledarrayBy( it, 'float64', undefined ); // $ExpectError - filledarrayBy( it, 'float64', [] ); // $ExpectError - filledarrayBy( it, 'float64', {} ); // $ExpectError - - filledarrayBy( it, 'float64', '5', {} ); // $ExpectError - filledarrayBy( it, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( it, 'float64', false, {} ); // $ExpectError - filledarrayBy( it, 'float64', true, {} ); // $ExpectError - filledarrayBy( it, 'float64', null, {} ); // $ExpectError - filledarrayBy( it, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( it, 'float64', [], {} ); // $ExpectError - filledarrayBy( it, 'float64', {}, {} ); // $ExpectError - - const buf = new ArrayBuffer( 32 ); - filledarrayBy( buf, '5' ); // $ExpectError - filledarrayBy( buf, 1.0 ); // $ExpectError - filledarrayBy( buf, false ); // $ExpectError - filledarrayBy( buf, true ); // $ExpectError - filledarrayBy( buf, null ); // $ExpectError - filledarrayBy( buf, undefined ); // $ExpectError - filledarrayBy( buf, [] ); // $ExpectError - filledarrayBy( buf, {} ); // $ExpectError - - filledarrayBy( buf, '5', {} ); // $ExpectError - filledarrayBy( buf, 1.0, {} ); // $ExpectError - filledarrayBy( buf, false, {} ); // $ExpectError - filledarrayBy( buf, true, {} ); // $ExpectError - filledarrayBy( buf, null, {} ); // $ExpectError - filledarrayBy( buf, undefined, {} ); // $ExpectError - filledarrayBy( buf, [], {} ); // $ExpectError - filledarrayBy( buf, {}, {} ); // $ExpectError - - filledarrayBy( buf, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 'float64', false ); // $ExpectError - filledarrayBy( buf, 'float64', true ); // $ExpectError - filledarrayBy( buf, 'float64', null ); // $ExpectError - filledarrayBy( buf, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 'float64', {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5' ); // $ExpectError - filledarrayBy( buf, 8, 1.0 ); // $ExpectError - filledarrayBy( buf, 8, false ); // $ExpectError - filledarrayBy( buf, 8, true ); // $ExpectError - filledarrayBy( buf, 8, null ); // $ExpectError - filledarrayBy( buf, 8, undefined ); // $ExpectError - filledarrayBy( buf, 8, [] ); // $ExpectError - filledarrayBy( buf, 8, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, false, {} ); // $ExpectError - filledarrayBy( buf, 8, true, {} ); // $ExpectError - filledarrayBy( buf, 8, null, {} ); // $ExpectError - filledarrayBy( buf, 8, undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, [], {} ); // $ExpectError - filledarrayBy( buf, 8, {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 8, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 'float64', false ); // $ExpectError - filledarrayBy( buf, 8, 'float64', true ); // $ExpectError - filledarrayBy( buf, 8, 'float64', null ); // $ExpectError - filledarrayBy( buf, 8, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 8, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 8, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 8, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, '5' ); // $ExpectError - filledarrayBy( buf, 8, 2, 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 2, false ); // $ExpectError - filledarrayBy( buf, 8, 2, true ); // $ExpectError - filledarrayBy( buf, 8, 2, null ); // $ExpectError - filledarrayBy( buf, 8, 2, undefined ); // $ExpectError - filledarrayBy( buf, 8, 2, [] ); // $ExpectError - filledarrayBy( buf, 8, 2, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, false, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, true, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, null, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, [], {} ); // $ExpectError - filledarrayBy( buf, 8, 2, {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', false ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', true ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', null ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', {}, {} ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid length, typed array, array-like object, `ArrayBuffer`, or iterable argument... -{ - filledarrayBy( false, clbk ); // $ExpectError - filledarrayBy( true, clbk ); // $ExpectError - filledarrayBy( null, clbk ); // $ExpectError - filledarrayBy( {}, clbk ); // $ExpectError - - filledarrayBy( false, clbk, {} ); // $ExpectError - filledarrayBy( true, clbk, {} ); // $ExpectError - filledarrayBy( null, clbk, {} ); // $ExpectError - filledarrayBy( {}, clbk, {} ); // $ExpectError - - filledarrayBy( false, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 'float64', clbk ); // $ExpectError - - filledarrayBy( false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, clbk ); // $ExpectError - filledarrayBy( 1.0, 8, clbk ); // $ExpectError - filledarrayBy( false, 8, clbk ); // $ExpectError - filledarrayBy( true, 8, clbk ); // $ExpectError - filledarrayBy( null, 8, clbk ); // $ExpectError - filledarrayBy( undefined, 8, clbk ); // $ExpectError - filledarrayBy( [], 8, clbk ); // $ExpectError - filledarrayBy( {}, 8, clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, clbk ); // $ExpectError - - filledarrayBy( '5', 8, clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, clbk, {} ); // $ExpectError - filledarrayBy( false, 8, clbk, {} ); // $ExpectError - filledarrayBy( true, 8, clbk, {} ); // $ExpectError - filledarrayBy( null, 8, clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, clbk, {} ); // $ExpectError - filledarrayBy( [], 8, clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 'float64', clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( false, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( [], 8, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 'float64', clbk ); // $ExpectError - - filledarrayBy( '5', 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 2, clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 2, clbk ); // $ExpectError - filledarrayBy( false, 8, 2, clbk ); // $ExpectError - filledarrayBy( true, 8, 2, clbk ); // $ExpectError - filledarrayBy( null, 8, 2, clbk ); // $ExpectError - filledarrayBy( undefined, 8, 2, clbk ); // $ExpectError - filledarrayBy( [], 8, 2, clbk ); // $ExpectError - filledarrayBy( {}, 8, 2, clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, clbk ); // $ExpectError - - filledarrayBy( '5', 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( false, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( [], 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, 'float64', clbk ); // $ExpectError - - filledarrayBy( '5', 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a byte offset argument which is not a number... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, false, clbk ); // $ExpectError - filledarrayBy( buf, true, clbk ); // $ExpectError - filledarrayBy( buf, null, clbk ); // $ExpectError - filledarrayBy( buf, [], clbk ); // $ExpectError - filledarrayBy( buf, {}, clbk ); // $ExpectError - - filledarrayBy( buf, false, clbk, {} ); // $ExpectError - filledarrayBy( buf, true, clbk, {} ); // $ExpectError - filledarrayBy( buf, null, clbk, {} ); // $ExpectError - filledarrayBy( buf, [], clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, clbk, {} ); // $ExpectError - - filledarrayBy( buf, '5', 'float64', clbk ); // $ExpectError - filledarrayBy( buf, false, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, true, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, null, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, [], 'float64', clbk ); // $ExpectError - filledarrayBy( buf, {}, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, '5', 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( buf, false, 2, clbk ); // $ExpectError - filledarrayBy( buf, true, 2, clbk ); // $ExpectError - filledarrayBy( buf, null, 2, clbk ); // $ExpectError - filledarrayBy( buf, [], 2, clbk ); // $ExpectError - filledarrayBy( buf, {}, 2, clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, clbk ); // $ExpectError - - filledarrayBy( buf, false, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, clbk, {} ); // $ExpectError - - filledarrayBy( buf, '5', 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, false, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, true, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, null, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, undefined, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, [], 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, {}, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, '5', 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, false, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, undefined, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a view length argument which is not a number... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, 8, false, clbk ); // $ExpectError - filledarrayBy( buf, 8, true, clbk ); // $ExpectError - filledarrayBy( buf, 8, null, clbk ); // $ExpectError - filledarrayBy( buf, 8, [], clbk ); // $ExpectError - filledarrayBy( buf, 8, {}, clbk ); // $ExpectError - - filledarrayBy( buf, 8, false, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, true, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, null, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, [], clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, {}, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, clbk, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5', 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, false, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, true, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, null, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, [], 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, {}, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, 8, '5', 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, [], 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, {}, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided too many arguments... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, 8, 2, 'float64', 1, clbk, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 997a381..0000000 --- a/examples/index.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ).factory; -var dtypes = require( '@stdlib/array-typed-real-dtypes' ); -var filledarrayBy = require( './../lib' ); - -// Create a pseudorandom number generator: -var rand = discreteUniform( 0, 100 ); - -// Get a list of array data types: -var dt = dtypes(); - -// Generate filled arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = filledarrayBy( 10, dt[ i ], rand ); - console.log( arr ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 764e40e..cb63cd1 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, RealOrComplexTypedArray, BooleanArray, DataType } from '@stdlib/types/array'; import { IterableIterator } from '@stdlib/types/iter'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..1c99feb --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@v0.0.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-ctors@v0.3.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill-by@v0.2.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled-by@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@v0.2.2-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.3.0-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";var v=f(),g=j.get("dtypes.default");function c(){var f,j,c,b,y,x,u,E;if(0===(j=arguments.length))return new(y=d(g))(0);if(r(c=arguments[0])){if(j>1)throw new TypeError(w("00h05"));if(null===(y=d(c)))throw new TypeError(w("00h2Y",c));return new y(0)}if(j<2)throw new TypeError(w("00h05"));if(h(arguments[j-=1]))if(h(arguments[j-1])){if(f=arguments[j],b=arguments[j-=1],0===j)throw new TypeError(w("00h05"))}else b=arguments[j];else{if(!(j>=2))throw new TypeError(w("00h05"));if(f=arguments[j],!h(b=arguments[j-=1]))throw new TypeError(w("00h2b",b))}if((j-=1)>=0&&r(arguments[j])?(c=arguments[j],j-=1):c=g,null===(y=d(c)))throw new TypeError(w("00h2Y",c));if("generic"===c){if(E=arguments[0],0===j){if(e(E)?u=E:i(E)&&(u=E.length),void 0!==u)return m(u,b,f);if(n(E))throw new Error(w("00h04"));if(o(E)){if(!1===v)throw new TypeError(w("00h2Z",E));if(!h(E[p]))throw new TypeError(w("00h2a",E));if(E=E[p](),!h(E.next))throw new TypeError(w("00h2a",E));return function(r,e,t){var s,i;for(s=[],i=-1;!r.next().done;)i+=1,s.push(e.call(t,i));return s}(E,b,f)}throw new TypeError(w("00h2a",E))}if(n(E))throw new Error(w("00h04"));throw new TypeError(w("00h2a",E))}if(0===j)if(i(E=arguments[0]))x=new y(E.length);else if(n(E))x=new y(E);else if(e(E))x=new y(E);else{if(!o(E))throw new TypeError(w("00h2a",E));if(!1===v)throw new TypeError(w("00h2Z",E));if(!h(E[p]))throw new TypeError(w("00h2a",E));if(E=E[p](),!h(E.next))throw new TypeError(w("00h2a",E));x=new y(a(E))}else x=1===j?new y(arguments[0],arguments[1]):new y(arguments[0],arguments[1],arguments[2]);return x.length>0&&(t(c)||s(c)?function(r,e,t){var s;for(s=0;s\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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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( format('00h05') );\n\t\t}\n\t\tctor = ctors( dtype );\n\t\tif ( ctor === null ) {\n\t\t\tthrow new TypeError( format( '00h2Y', 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( format('00h05') );\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( format('00h05') );\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( '00h2b', 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( format('00h05') );\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( '00h2Y', 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( format('00h04') );\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( '00h2Z', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00h2a', 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( '00h2a', 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( '00h2a', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format('00h04') );\n\t\t}\n\t\tthrow new TypeError( format( '00h2a', 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( '00h2Z', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00h2a', 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( '00h2a', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00h2a', 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\nexport default filledarrayBy;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","DEFAULT_DTYPE","defaults","get","filledarrayBy","thisArg","nargs","dtype","clbk","ctor","arr","len","arg","arguments","length","ctors","isString","TypeError","format","isFunction","isNonNegativeInteger","isCollection","filledArray","isArrayBuffer","Error","isObject","ITERATOR_SYMBOL","next","it","i","done","push","call","filledArrayIterator","iterLength","isComplexDataType","isBooleanDataType","set","filledAccessors","gfillBy","value","aidx"],"mappings":";;sjDA0CA,IAAIA,EAAsBC,IACtBC,EAAgBC,EAASC,IAAK,kBA2MlC,SAASC,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAKJ,GAAe,KAHfN,EAAQO,UAAUC,QAKjB,OAAO,IADPL,EAAOM,EAAOd,IACG,GAIlB,GAAKe,EADLT,EAAQM,UAAW,IACM,CAExB,GAAKP,EAAQ,EACZ,MAAM,IAAIW,UAAWC,EAAO,UAG7B,GAAc,QADdT,EAAOM,EAAOR,IAEb,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,OAAO,IAAIE,EAAM,EACjB,CAED,GAAKH,EAAQ,EACZ,MAAM,IAAIW,UAAWC,EAAO,UAM7B,GAAKC,EAAYN,UAHjBP,GAAS,IAKR,GAAKa,EAAYN,UAAWP,EAAM,KAMjC,GALAD,EAAUQ,UAAWP,GAErBE,EAAOK,UADPP,GAAS,GAIM,IAAVA,EACJ,MAAM,IAAIW,UAAWC,EAAO,eAI7BV,EAAOK,UAAWP,OAIf,MAAKA,GAAS,GAUlB,MAAM,IAAIW,UAAWC,EAAO,UAN5B,GAHAb,EAAUQ,UAAWP,IAGfa,EADNX,EAAOK,UADPP,GAAS,IAGR,MAAM,IAAIW,UAAWC,EAAQ,QAASV,GAMvC,CAUD,IARAF,GAAS,IACK,GAAKU,EAAUH,UAAWP,KACvCC,EAAQM,UAAWP,GACnBA,GAAS,GAETC,EAAQN,EAGK,QADdQ,EAAOM,EAAOR,IAEb,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,GAAe,YAAVA,EAAsB,CAE1B,GADAK,EAAMC,UAAW,GACF,IAAVP,EAAc,CAMlB,GALKc,EAAsBR,GAC1BD,EAAMC,EACKS,EAAcT,KACzBD,EAAMC,EAAIE,aAEE,IAARH,EACJ,OAAOW,EAAaX,EAAKH,EAAMH,GAEhC,GAAKkB,EAAeX,GACnB,MAAM,IAAIY,MAAON,EAAO,UAEzB,GAAKO,EAAUb,GAAQ,CACtB,IAA6B,IAAxBb,EACJ,MAAM,IAAIkB,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAYP,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLP,EAAYP,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvC,OAvSJ,SAA8BgB,EAAIpB,EAAMH,GACvC,IAAIK,EACAmB,EAKJ,IAFAnB,EAAM,GACNmB,GAAK,GAEAD,EAAGD,OACAG,MAGPD,GAAK,EACLnB,EAAIqB,KAAMvB,EAAKwB,KAAM3B,EAASwB,IAE/B,OAAOnB,CACR,CAuRWuB,CAAqBrB,EAAKJ,EAAMH,EACvC,CACD,MAAM,IAAIY,UAAWC,EAAQ,QAASN,GACzC,CAAS,GAAKW,EAAeX,GAC1B,MAAM,IAAIY,MAAON,EAAO,UAEzB,MAAM,IAAID,UAAWC,EAAQ,QAASN,GACtC,CACD,GAAe,IAAVN,EAEJ,GAAKe,EADLT,EAAMC,UAAW,IAEhBH,EAAM,IAAID,EAAMG,EAAIE,aACd,GAAKS,EAAeX,GAC1BF,EAAM,IAAID,EAAMG,QACV,GAAKQ,EAAsBR,GACjCF,EAAM,IAAID,EAAMG,OACV,KAAKa,EAAUb,GAarB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAZtC,IAA6B,IAAxBb,EACJ,MAAM,IAAIkB,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAYP,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLP,EAAYP,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvCF,EAAM,IAAID,EAAMyB,EAAYtB,GAG5B,MAEDF,EADqB,IAAVJ,EACL,IAAIG,EAAMI,UAAU,GAAIA,UAAU,IAElC,IAAIJ,EAAMI,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKH,EAAII,OAAS,IACZqB,EAAmB5B,IAAW6B,EAAmB7B,GAjTxD,SAA0BG,EAAKF,EAAMH,GACpC,IAAIwB,EACJ,IAAMA,EAAI,EAAGA,EAAInB,EAAII,OAAQe,IAC5BnB,EAAI2B,IAAK7B,EAAKwB,KAAM3B,EAASwB,GAAKA,EAGpC,CA4SGS,CAAiB5B,EAAKF,EAAMH,GAE5BkC,EAAS7B,EAAII,OAAQJ,EAAK,GAe5B,SAAmB8B,EAAOC,GACzB,OAAOjC,EAAKwB,KAAM3B,EAASoC,EAC3B,KAdM/B,CAeR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d115cf0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,192 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -/** -* Create a filled array according to a provided callback function. -* -* @module @stdlib/array-filled-by -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* var arr = filledarrayBy(); -* // returns -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'generic', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( [ 0.5, 0.5 ], clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1; -* } -* -* var arr = filledarrayBy( [ 5, -3 ], 'int32', clbk ); -* // returns [ 1, 1 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk1() { -* return 10; -* } -* -* function clbk2() { -* return 1.0; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, clbk2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk1() { -* return 1.0; -* } -* -* function clbk2() { -* return 2; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, 'uint32', clbk2 ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 'float32', clbk ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, clbk ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, 'int32', clbk ); -* // returns [ 1, 1 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index ed1aa9a..0000000 --- a/lib/main.js +++ /dev/null @@ -1,416 +0,0 @@ -/** -* @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 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' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var ctors = require( '@stdlib/array-ctors' ); -var gfillBy = require( '@stdlib/blas-ext-base-gfill-by' ); -var filledArray = require( '@stdlib/array-base-filled-by' ); -var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var iterLength = require( '@stdlib/iter-length' ); -var defaults = require( '@stdlib/array-defaults' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport(); -var DEFAULT_DTYPE = defaults.get( 'dtypes.default' ); - - -// FUNCTIONS // - -/** -* Creates a filled "generic" array from an iterator. -* -* @private -* @param {Iterable} it - iterator -* @param {Callback} clbk - callback function -* @param {*} thisArg - callback function execution context -* @returns {Array} filled array -*/ -function filledArrayIterator( it, clbk, thisArg ) { - var arr; - var i; - var v; - - arr = []; - i = -1; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - i += 1; - arr.push( clbk.call( thisArg, i ) ); - } - return arr; -} - -/** -* Fills an array exposing accessors for getting and setting array elements. -* -* @private -* @param {Collection} arr - input array -* @param {Callback} clbk - callback function -* @param {*} thisArg - callback function execution context -* @returns {Collection} input array -*/ -function filledAccessors( arr, clbk, thisArg ) { - var i; - for ( i = 0; i < arr.length; i++ ) { - arr.set( clbk.call( thisArg, i ), i ); - } - return arr; -} - - -// MAIN // - -/** -* Creates a filled array according to a provided callback function. -* -* @param {(NonNegativeInteger|TypedArray|ArrayLikeObject|ArrayBuffer|Iterable)} [arg] - a length, typed array, array-like object, buffer, or iterable -* @param {NonNegativeInteger} [byteOffset=0] - byte offset -* @param {NonNegativeInteger} [length] - view length -* @param {string} [dtype="float64"] - data type -* @param {Callback} [clbk] - callback to invoke -* @param {*} [thisArg] - callback execution context -* @throws {TypeError} must provide a recognized data type -* @throws {TypeError} must provide a length, typed array, array-like object, buffer, or iterable -* @throws {TypeError} callback argument must be a function. -* @throws {Error} creating a generic array from an `ArrayBuffer` is not supported -* @returns {(TypedArray|Array)} array or typed array -* -* @example -* var arr = filledarrayBy(); -* // returns -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'generic', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( [ 0.5, 0.5 ], clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1; -* } -* -* var arr = filledarrayBy( [ 5, -3 ], 'int32', clbk ); -* // returns [ 1, 1 ] -* -* @example -* function clbk1() { -* return 10; -* } -* -* function clbk2() { -* return 1.0; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, clbk2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk1() { -* return 1.0; -* } -* -* function clbk2() { -* return 2; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, 'uint32', clbk2 ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 'float32', clbk ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, clbk ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, 'int32', clbk ); -* // returns [ 1, 1 ] -*/ -function filledarrayBy() { - var thisArg; - var nargs; - var dtype; - var clbk; - var ctor; - var arr; - var len; - var arg; - - nargs = arguments.length; - - // If we weren't provided any arguments, return an empty array... - if ( nargs === 0 ) { - ctor = ctors( DEFAULT_DTYPE ); - return new ctor( 0 ); - } - // Check if we were provided a dtype as the first argument... - dtype = arguments[ 0 ]; - if ( isString( dtype ) ) { - // Invoking this function with arguments `f( dtype, clbk[, thisArg] )` is not allowed (otherwise, we'd need to also allow `f( clbk[, thisArg] )`)... - if ( nargs > 1 ) { - throw new TypeError( format('00h05') ); - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '00h2Y', dtype ) ); - } - // Return an empty array having the specified dtype: - return new ctor( 0 ); - } - // For all other supported invocations, we need at least two arguments... - if ( nargs < 2 ) { - throw new TypeError( format('00h05') ); - } - // At this point, we need to do some argument juggling... - nargs -= 1; // henceforth, the number of available arguments is `nargs+1` - - // Determine whether the last argument is a callback or "this" context... - if ( isFunction( arguments[ nargs ] ) ) { - // 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... - if ( isFunction( arguments[ nargs-1 ] ) ) { - thisArg = arguments[ nargs ]; - nargs -= 1; - clbk = arguments[ nargs ]; - - // Check if we were provided only a callback and a "this" context.. - if ( nargs === 0 ) { - throw new TypeError( format('00h05') ); - } - } else { - // "this" context is left undefined... - clbk = arguments[ nargs ]; - } - } - // 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... - else if ( nargs >= 2 ) { - thisArg = arguments[ nargs ]; - nargs -= 1; - clbk = arguments[ nargs ]; - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '00h2b', clbk ) ); - } - } - // If were were only provided 2 arguments and the last argument was not a function, we've been provided an insufficient number of arguments... - else { - throw new TypeError( format('00h05') ); - } - // Now that we've processed the callback arguments, let's continue working backward to see if we've been provided a `dtype` argument... - nargs -= 1; - if ( nargs >= 0 && isString( arguments[ nargs ] ) ) { - dtype = arguments[ nargs ]; - nargs -= 1; - } else { - dtype = DEFAULT_DTYPE; - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '00h2Y', dtype ) ); - } - // At this point, we've resolved the output array data type, and now we can actually create the output array... - if ( dtype === 'generic' ) { - arg = arguments[ 0 ]; - if ( nargs === 0 ) { - if ( isNonNegativeInteger( arg ) ) { - len = arg; - } else if ( isCollection( arg ) ) { - len = arg.length; - } - if ( len !== void 0 ) { - return filledArray( len, clbk, thisArg ); - } - if ( isArrayBuffer( arg ) ) { - throw new Error( format('00h04') ); - } - if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( '00h2Z', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00h2a', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00h2a', arg ) ); - } - return filledArrayIterator( arg, clbk, thisArg ); - } - throw new TypeError( format( '00h2a', arg ) ); - } else if ( isArrayBuffer( arg ) ) { - throw new Error( format('00h04') ); - } - throw new TypeError( format( '00h2a', arg ) ); - } - if ( nargs === 0 ) { // length || array-like || ArrayBuffer || iterable - arg = arguments[ 0 ]; - if ( isCollection( arg ) ) { - arr = new ctor( arg.length ); - } else if ( isArrayBuffer( arg ) ) { - arr = new ctor( arg ); - } else if ( isNonNegativeInteger( arg ) ) { - arr = new ctor( arg ); - } else if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( '00h2Z', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00h2a', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00h2a', arg ) ); - } - arr = new ctor( iterLength( arg ) ); - } else { - throw new TypeError( format( '00h2a', arg ) ); - } - } else if ( nargs === 1 ) { - arr = new ctor( arguments[0], arguments[1] ); // (ArrayBuffer, byteOffset) - } else { - arr = new ctor( arguments[0], arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset, length) - } - if ( arr.length > 0 ) { - if ( isComplexDataType( dtype ) || isBooleanDataType( dtype ) ) { - filledAccessors( arr, clbk, thisArg ); - } else { - gfillBy( arr.length, arr, 1, callback ); - } - } - return arr; - - /** - * Callback which wraps a provided callback and is invoked for each array element. - * - * @private - * @param {*} value - element value - * @param {NonNegativeInteger} aidx - array index - * @param {NonNegativeInteger} sidx - strided index - * @param {Collection} array - input array/collection - * @returns {*} callback return value - */ - function callback( value, aidx ) { - return clbk.call( thisArg, aidx ); - } -} - - -// EXPORTS // - -module.exports = filledarrayBy; diff --git a/package.json b/package.json index d01aec1..b16be36 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Create a filled array according to a provided callback function.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,75 +13,6 @@ "bugs": { "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.2", - "@stdlib/array-ctors": "^0.3.0", - "@stdlib/array-defaults": "^0.3.0", - "@stdlib/assert-has-iterator-symbol-support": "^0.2.2", - "@stdlib/assert-is-arraybuffer": "^0.2.2", - "@stdlib/assert-is-collection": "^0.2.2", - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer": "^0.2.2", - "@stdlib/assert-is-object": "^0.2.2", - "@stdlib/assert-is-string": "^0.2.2", - "@stdlib/blas-ext-base-gfill-by": "^0.2.1", - "@stdlib/iter-length": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/symbol-iterator": "^0.2.2", - "@stdlib/types": "^0.4.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-bool": "^0.1.0", - "@stdlib/array-buffer": "^0.2.2", - "@stdlib/array-complex128": "^0.3.0", - "@stdlib/array-complex64": "^0.3.0", - "@stdlib/array-float32": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/array-int16": "^0.2.2", - "@stdlib/array-int32": "^0.2.2", - "@stdlib/array-int8": "^0.2.2", - "@stdlib/array-typed-real-dtypes": "^0.2.2", - "@stdlib/array-uint16": "^0.2.2", - "@stdlib/array-uint32": "^0.2.2", - "@stdlib/array-uint8": "^0.2.2", - "@stdlib/array-uint8c": "^0.2.2", - "@stdlib/assert-instance-of": "^0.2.2", - "@stdlib/assert-is-array": "^0.2.2", - "@stdlib/assert-is-typed-array": "^0.2.2", - "@stdlib/assert-is-typed-array-like": "^0.2.2", - "@stdlib/complex-float32-ctor": "^0.0.2", - "@stdlib/complex-float64-ctor": "^0.0.3", - "@stdlib/iter-constant": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/random-base-discrete-uniform": "^0.2.1", - "@stdlib/strided-base-reinterpret-boolean": "^0.0.2", - "@stdlib/strided-base-reinterpret-complex128": "^0.2.2", - "@stdlib/strided-base-reinterpret-complex64": "^0.2.1", - "@stdlib/utils-constant-function": "^0.2.2", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..e4cee9c --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index ca0cf25..0000000 --- a/test/test.js +++ /dev/null @@ -1,4397 +0,0 @@ -/** -* @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. -*/ - -/* eslint-disable max-len */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -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' ); -var iterConstant = require( '@stdlib/iter-constant' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var filledarrayBy = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': !hasIteratorSymbolSupport() -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof filledarrayBy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if only provided callback arguments', function test( t ) { - t.throws( clbk1, TypeError, 'throws an error' ); - t.throws( clbk2, TypeError, 'throws an error' ); - t.throws( clbk3, TypeError, 'throws an error' ); - t.end(); - - function clbk1() { - filledarrayBy( constantFunction( 1.0 ) ); - } - - function clbk2() { - filledarrayBy( constantFunction( 1.0 ), {} ); - } - - function clbk3() { - filledarrayBy( constantFunction( 1.0 ), constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (only argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (typed array; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (array-like object)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (array-like object; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 8 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 8 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, 1, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (iterator)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( iterConstant( 1.0 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (iterator; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( iterConstant( 1.0 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if only provided data type and callback arguments', function test( t ) { - t.throws( clbk1, TypeError, 'throws an error' ); - t.throws( clbk2, TypeError, 'throws an error' ); - t.throws( clbk3, TypeError, 'throws an error' ); - t.end(); - - function clbk1() { - filledarrayBy( 'float64', constantFunction( 1.0 ) ); - } - - function clbk2() { - filledarrayBy( 'float64', constantFunction( 1.0 ), {} ); - } - - function clbk3() { - filledarrayBy( 'float64', constantFunction( 1.0 ), constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (array-like object)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (array-like object; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, 1, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, 1, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (no iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (no iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (non-function iterator symbol property)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (non-function iterator symbol property; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (`next` property is not a function)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ) ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (`next` property is not a function; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ), {} ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (no iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (no iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (non-function iterator symbol property)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (non-function iterator symbol property; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (`next` property is not a function)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ) ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (`next` property is not a function; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ), {} ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 1, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 1, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function returns a filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - arr = filledarrayBy(); - - t.strictEqual( instanceOf( arr, Float64Array ), 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=float64)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - arr = filledarrayBy( 'float64' ); - - t.strictEqual( instanceOf( arr, Float64Array ), 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=float32)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( 0 ); - arr = filledarrayBy( 'float32' ); - - t.strictEqual( instanceOf( arr, Float32Array ), 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=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; - - expected = new Complex128Array( 0 ); - arr = filledarrayBy( 'complex128' ); - - t.strictEqual( instanceOf( arr, Complex128Array ), 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=complex64)', function test( t ) { - var expected; - var arr; - - expected = new Complex64Array( 0 ); - arr = filledarrayBy( 'complex64' ); - - t.strictEqual( instanceOf( arr, Complex64Array ), 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=int32)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( 0 ); - arr = filledarrayBy( 'int32' ); - - t.strictEqual( instanceOf( arr, Int32Array ), 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=uint32)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( 0 ); - arr = filledarrayBy( 'uint32' ); - - t.strictEqual( instanceOf( arr, Uint32Array ), 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=int16)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( 0 ); - arr = filledarrayBy( 'int16' ); - - t.strictEqual( instanceOf( arr, Int16Array ), 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=uint16)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( 0 ); - arr = filledarrayBy( 'uint16' ); - - t.strictEqual( instanceOf( arr, Uint16Array ), 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=int8)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( 0 ); - arr = filledarrayBy( 'int8' ); - - t.strictEqual( instanceOf( arr, Int8Array ), 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=uint8)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( 0 ); - arr = filledarrayBy( 'uint8' ); - - t.strictEqual( instanceOf( arr, Uint8Array ), 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=uint8c)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( 0 ); - arr = filledarrayBy( 'uint8c' ); - - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), 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=generic)', function test( t ) { - var expected; - var arr; - - expected = []; - arr = filledarrayBy( 'generic' ); - - t.strictEqual( instanceOf( arr, Array ), 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 (default, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, length=0)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array(); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 0, clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, clbk, ctx ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (default, length; thisArg=function)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, clbk, context ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this(); // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } - - function context() { - ctx.count += 1; - } -}); - -tape( 'the function returns a filled array (dtype=float64, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, 'float64', clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, length; thisArg=function)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, 'float64', clbk, context ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this(); // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } - - function context() { - ctx.count += 1; - } -}); - -tape( 'the function returns a filled array (dtype=float32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, 'float32', clbk ); - - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - 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; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = filledarrayBy( 5, 'complex128', clbk ); - - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = filledarrayBy( 5, 'complex64', clbk ); - - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int32Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int32', clbk ); - - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint32Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint32', clbk ); - - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int16Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int16', clbk ); - - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint16', clbk ); - - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int8Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int8', clbk ); - - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint8', clbk ); - - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint8c', clbk ); - - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = [ 1, 1, 1, 1, 1 ]; - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'generic', clbk ); - - t.strictEqual( instanceOf( arr, Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - 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; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = [ 1.0, 2.0 ]; - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = [ 1.0, 2.0 ]; - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int32', clbk ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, typed array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, typed array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - 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; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = new Float64Array( [ 1.0, 2.0 ] ); - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = new Float64Array( [ 1.0, 2.0 ] ); - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (default, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - 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; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer, byteoffset; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer, byteoffset; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - 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; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 48 ); - out = filledarrayBy( buf, 16, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 24 ); - out = filledarrayBy( buf, 8, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int32', clbk ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint8c', clbk ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - 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; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 64 ); - out = filledarrayBy( buf, 16, 2, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset, length)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 1, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 1, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled array (default, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, iterator; thisArg)', opts, function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - ctx = { - 'count': 0 - }; - indices = []; - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, iterator; thisArg)', opts, function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - ctx = { - 'count': 0 - }; - indices = []; - out = filledarrayBy( arr, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - 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; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = iterConstant( new Complex128( 3.0, 3.0 ), { - 'iter': 2 - }); - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = iterConstant( new Complex64( 3.0, 3.0 ), { - 'iter': 2 - }); - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); From 20fc58264a0e3c2e7eb8bb0dc7e07846197b25df Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 28 Sep 2024 21:16:55 +0000 Subject: [PATCH 069/117] Transform error messages --- lib/main.js | 38 +++++++++++++++++++------------------- package.json | 2 +- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/lib/main.js b/lib/main.js index b322cfe..ed1aa9a 100644 --- a/lib/main.js +++ b/lib/main.js @@ -35,7 +35,7 @@ var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-supp var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); var iterLength = require( '@stdlib/iter-length' ); var defaults = require( '@stdlib/array-defaults' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -266,18 +266,18 @@ function filledarrayBy() { if ( isString( dtype ) ) { // Invoking this function with arguments `f( dtype, clbk[, thisArg] )` is not allowed (otherwise, we'd need to also allow `f( clbk[, thisArg] )`)... if ( nargs > 1 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format('00h05') ); } ctor = ctors( dtype ); if ( ctor === null ) { - throw new TypeError( format( 'invalid argument. Must provide a recognized data type. Value: `%s`.', dtype ) ); + throw new TypeError( format( '00h2Y', dtype ) ); } // Return an empty array having the specified dtype: return new ctor( 0 ); } // For all other supported invocations, we need at least two arguments... if ( nargs < 2 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format('00h05') ); } // At this point, we need to do some argument juggling... nargs -= 1; // henceforth, the number of available arguments is `nargs+1` @@ -292,7 +292,7 @@ function filledarrayBy() { // Check if we were provided only a callback and a "this" context.. if ( nargs === 0 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format('00h05') ); } } else { // "this" context is left undefined... @@ -305,12 +305,12 @@ function filledarrayBy() { nargs -= 1; clbk = arguments[ nargs ]; if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '00h2b', clbk ) ); } } // If were were only provided 2 arguments and the last argument was not a function, we've been provided an insufficient number of arguments... else { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format('00h05') ); } // Now that we've processed the callback arguments, let's continue working backward to see if we've been provided a `dtype` argument... nargs -= 1; @@ -322,7 +322,7 @@ function filledarrayBy() { } ctor = ctors( dtype ); if ( ctor === null ) { - throw new TypeError( format( 'invalid argument. Must provide a recognized data type. Value: `%s`.', dtype ) ); + throw new TypeError( format( '00h2Y', dtype ) ); } // At this point, we've resolved the output array data type, and now we can actually create the output array... if ( dtype === 'generic' ) { @@ -337,26 +337,26 @@ function filledarrayBy() { return filledArray( len, clbk, thisArg ); } if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format('00h04') ); } if ( isObject( arg ) ) { if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2Z', arg ) ); } if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } arg = arg[ ITERATOR_SYMBOL ](); if ( !isFunction( arg.next ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } return filledArrayIterator( arg, clbk, thisArg ); } - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } else if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format('00h04') ); } - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } if ( nargs === 0 ) { // length || array-like || ArrayBuffer || iterable arg = arguments[ 0 ]; @@ -368,18 +368,18 @@ function filledarrayBy() { arr = new ctor( arg ); } else if ( isObject( arg ) ) { if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2Z', arg ) ); } if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } arg = arg[ ITERATOR_SYMBOL ](); if ( !isFunction( arg.next ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } arr = new ctor( iterLength( arg ) ); } else { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } } else if ( nargs === 1 ) { arr = new ctor( arguments[0], arguments[1] ); // (ArrayBuffer, byteOffset) diff --git a/package.json b/package.json index c089d32..d01aec1 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "@stdlib/assert-is-string": "^0.2.2", "@stdlib/blas-ext-base-gfill-by": "^0.2.1", "@stdlib/iter-length": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/symbol-iterator": "^0.2.2", "@stdlib/types": "^0.4.1", "@stdlib/error-tools-fmtprodmsg": "^0.2.2" From 6195d0805705c8a003ff9e684040ae174b235c76 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 28 Sep 2024 21:17:56 +0000 Subject: [PATCH 070/117] Remove files --- index.d.ts | 322 ---- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5169 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index cb63cd1..0000000 --- a/index.d.ts +++ /dev/null @@ -1,322 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, RealOrComplexTypedArray, BooleanArray, DataType } from '@stdlib/types/array'; -import { IterableIterator } from '@stdlib/types/iter'; - -/** -* Array or typed array. -*/ -type ArrayOrTypedArray = Array | RealOrComplexTypedArray | BooleanArray; - -/** -* Nullary callback function. -* -* @returns fill value -*/ -type Nullary = () => any; - -/** -* Unary callback function. -* -* @param i - current array index -* @returns fill value -*/ -type Unary = ( i: number ) => any; - -/** -* Callback function. -* -* @param i - current array index -* @returns fill value -*/ -type Callback = Nullary | Unary; - -/** -* Creates a filled array according to a provided callback function and having a specified data type. -* -* @param dtype - data type -* @returns filled array -* -* @example -* var arr = filledarrayBy(); -* // returns -* -* @example -* var arr = filledarrayBy( 'float32' ); -* // returns -*/ -declare function filledarrayBy( dtype?: DataType ): ArrayOrTypedArray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Creates a filled array according to a provided callback function and having a specified `length`. -* -* @param length - array length -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* -* var arr = filledarrayBy( 5, constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( length: number, clbk: Callback, thisArg?: any ): ArrayOrTypedArray; - -/** -* Creates a filled array according to a provided callback function and having a specified `length`. -* -* @param length - array length -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* -* var arr = filledarrayBy( 5, 'float64', constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( length: number, dtype: DataType, clbk: Callback, thisArg?: any ): ArrayOrTypedArray; - -/** -* Creates a filled array from another `array` according to a provided callback function. -* -* @param array - typed array or array-like object -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* -* 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; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Creates a filled array from another `array` according to a provided callback function. -* -* @param array - typed array or array-like object -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* -* 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; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Creates a filled array from an iterable according to a callback function. -* -* @param iterable - iterable -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var iterConstant = require( '@stdlib/iter-constant' ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarrayBy( it, constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( iterable: IterableIterator, clbk: Callback, thisArg?: any ): ArrayOrTypedArray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Creates a filled array from an iterable according to a callback function. -* -* @param iterable - iterable -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var iterConstant = require( '@stdlib/iter-constant' ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarrayBy( it, 'float64', constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( iterable: IterableIterator, dtype: DataType, clbk: 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. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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 | BooleanArray; - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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 | BooleanArray; - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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 | BooleanArray; - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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 | BooleanArray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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 | BooleanArray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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 | BooleanArray; // eslint-disable-line @typescript-eslint/unified-signatures - - -// EXPORTS // - -export = filledarrayBy; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 1c99feb..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@v0.0.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-ctors@v0.3.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill-by@v0.2.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled-by@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@v0.2.2-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.3.0-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";var v=f(),g=j.get("dtypes.default");function c(){var f,j,c,b,y,x,u,E;if(0===(j=arguments.length))return new(y=d(g))(0);if(r(c=arguments[0])){if(j>1)throw new TypeError(w("00h05"));if(null===(y=d(c)))throw new TypeError(w("00h2Y",c));return new y(0)}if(j<2)throw new TypeError(w("00h05"));if(h(arguments[j-=1]))if(h(arguments[j-1])){if(f=arguments[j],b=arguments[j-=1],0===j)throw new TypeError(w("00h05"))}else b=arguments[j];else{if(!(j>=2))throw new TypeError(w("00h05"));if(f=arguments[j],!h(b=arguments[j-=1]))throw new TypeError(w("00h2b",b))}if((j-=1)>=0&&r(arguments[j])?(c=arguments[j],j-=1):c=g,null===(y=d(c)))throw new TypeError(w("00h2Y",c));if("generic"===c){if(E=arguments[0],0===j){if(e(E)?u=E:i(E)&&(u=E.length),void 0!==u)return m(u,b,f);if(n(E))throw new Error(w("00h04"));if(o(E)){if(!1===v)throw new TypeError(w("00h2Z",E));if(!h(E[p]))throw new TypeError(w("00h2a",E));if(E=E[p](),!h(E.next))throw new TypeError(w("00h2a",E));return function(r,e,t){var s,i;for(s=[],i=-1;!r.next().done;)i+=1,s.push(e.call(t,i));return s}(E,b,f)}throw new TypeError(w("00h2a",E))}if(n(E))throw new Error(w("00h04"));throw new TypeError(w("00h2a",E))}if(0===j)if(i(E=arguments[0]))x=new y(E.length);else if(n(E))x=new y(E);else if(e(E))x=new y(E);else{if(!o(E))throw new TypeError(w("00h2a",E));if(!1===v)throw new TypeError(w("00h2Z",E));if(!h(E[p]))throw new TypeError(w("00h2a",E));if(E=E[p](),!h(E.next))throw new TypeError(w("00h2a",E));x=new y(a(E))}else x=1===j?new y(arguments[0],arguments[1]):new y(arguments[0],arguments[1],arguments[2]);return x.length>0&&(t(c)||s(c)?function(r,e,t){var s;for(s=0;s\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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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( format('00h05') );\n\t\t}\n\t\tctor = ctors( dtype );\n\t\tif ( ctor === null ) {\n\t\t\tthrow new TypeError( format( '00h2Y', 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( format('00h05') );\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( format('00h05') );\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( '00h2b', 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( format('00h05') );\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( '00h2Y', 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( format('00h04') );\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( '00h2Z', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00h2a', 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( '00h2a', 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( '00h2a', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format('00h04') );\n\t\t}\n\t\tthrow new TypeError( format( '00h2a', 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( '00h2Z', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00h2a', 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( '00h2a', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00h2a', 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\nexport default filledarrayBy;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","DEFAULT_DTYPE","defaults","get","filledarrayBy","thisArg","nargs","dtype","clbk","ctor","arr","len","arg","arguments","length","ctors","isString","TypeError","format","isFunction","isNonNegativeInteger","isCollection","filledArray","isArrayBuffer","Error","isObject","ITERATOR_SYMBOL","next","it","i","done","push","call","filledArrayIterator","iterLength","isComplexDataType","isBooleanDataType","set","filledAccessors","gfillBy","value","aidx"],"mappings":";;sjDA0CA,IAAIA,EAAsBC,IACtBC,EAAgBC,EAASC,IAAK,kBA2MlC,SAASC,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAKJ,GAAe,KAHfN,EAAQO,UAAUC,QAKjB,OAAO,IADPL,EAAOM,EAAOd,IACG,GAIlB,GAAKe,EADLT,EAAQM,UAAW,IACM,CAExB,GAAKP,EAAQ,EACZ,MAAM,IAAIW,UAAWC,EAAO,UAG7B,GAAc,QADdT,EAAOM,EAAOR,IAEb,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,OAAO,IAAIE,EAAM,EACjB,CAED,GAAKH,EAAQ,EACZ,MAAM,IAAIW,UAAWC,EAAO,UAM7B,GAAKC,EAAYN,UAHjBP,GAAS,IAKR,GAAKa,EAAYN,UAAWP,EAAM,KAMjC,GALAD,EAAUQ,UAAWP,GAErBE,EAAOK,UADPP,GAAS,GAIM,IAAVA,EACJ,MAAM,IAAIW,UAAWC,EAAO,eAI7BV,EAAOK,UAAWP,OAIf,MAAKA,GAAS,GAUlB,MAAM,IAAIW,UAAWC,EAAO,UAN5B,GAHAb,EAAUQ,UAAWP,IAGfa,EADNX,EAAOK,UADPP,GAAS,IAGR,MAAM,IAAIW,UAAWC,EAAQ,QAASV,GAMvC,CAUD,IARAF,GAAS,IACK,GAAKU,EAAUH,UAAWP,KACvCC,EAAQM,UAAWP,GACnBA,GAAS,GAETC,EAAQN,EAGK,QADdQ,EAAOM,EAAOR,IAEb,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,GAAe,YAAVA,EAAsB,CAE1B,GADAK,EAAMC,UAAW,GACF,IAAVP,EAAc,CAMlB,GALKc,EAAsBR,GAC1BD,EAAMC,EACKS,EAAcT,KACzBD,EAAMC,EAAIE,aAEE,IAARH,EACJ,OAAOW,EAAaX,EAAKH,EAAMH,GAEhC,GAAKkB,EAAeX,GACnB,MAAM,IAAIY,MAAON,EAAO,UAEzB,GAAKO,EAAUb,GAAQ,CACtB,IAA6B,IAAxBb,EACJ,MAAM,IAAIkB,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAYP,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLP,EAAYP,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvC,OAvSJ,SAA8BgB,EAAIpB,EAAMH,GACvC,IAAIK,EACAmB,EAKJ,IAFAnB,EAAM,GACNmB,GAAK,GAEAD,EAAGD,OACAG,MAGPD,GAAK,EACLnB,EAAIqB,KAAMvB,EAAKwB,KAAM3B,EAASwB,IAE/B,OAAOnB,CACR,CAuRWuB,CAAqBrB,EAAKJ,EAAMH,EACvC,CACD,MAAM,IAAIY,UAAWC,EAAQ,QAASN,GACzC,CAAS,GAAKW,EAAeX,GAC1B,MAAM,IAAIY,MAAON,EAAO,UAEzB,MAAM,IAAID,UAAWC,EAAQ,QAASN,GACtC,CACD,GAAe,IAAVN,EAEJ,GAAKe,EADLT,EAAMC,UAAW,IAEhBH,EAAM,IAAID,EAAMG,EAAIE,aACd,GAAKS,EAAeX,GAC1BF,EAAM,IAAID,EAAMG,QACV,GAAKQ,EAAsBR,GACjCF,EAAM,IAAID,EAAMG,OACV,KAAKa,EAAUb,GAarB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAZtC,IAA6B,IAAxBb,EACJ,MAAM,IAAIkB,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAYP,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLP,EAAYP,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvCF,EAAM,IAAID,EAAMyB,EAAYtB,GAG5B,MAEDF,EADqB,IAAVJ,EACL,IAAIG,EAAMI,UAAU,GAAIA,UAAU,IAElC,IAAIJ,EAAMI,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKH,EAAII,OAAS,IACZqB,EAAmB5B,IAAW6B,EAAmB7B,GAjTxD,SAA0BG,EAAKF,EAAMH,GACpC,IAAIwB,EACJ,IAAMA,EAAI,EAAGA,EAAInB,EAAII,OAAQe,IAC5BnB,EAAI2B,IAAK7B,EAAKwB,KAAM3B,EAASwB,GAAKA,EAGpC,CA4SGS,CAAiB5B,EAAKF,EAAMH,GAE5BkC,EAAS7B,EAAII,OAAQJ,EAAK,GAe5B,SAAmB8B,EAAOC,GACzB,OAAOjC,EAAKwB,KAAM3B,EAASoC,EAC3B,KAdM/B,CAeR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index e4cee9c..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 81ca990837660f9e9708a2a4bf09b25738294cd4 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 28 Sep 2024 21:18:13 +0000 Subject: [PATCH 071/117] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 252 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 191 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 49 +- SECURITY.md | 5 - benchmark/benchmark.js | 341 -- benchmark/benchmark.length.bool.js | 97 - benchmark/benchmark.length.complex128.js | 98 - benchmark/benchmark.length.complex64.js | 98 - benchmark/benchmark.length.float32.js | 97 - benchmark/benchmark.length.float64.js | 97 - benchmark/benchmark.length.generic.js | 97 - benchmark/benchmark.length.int16.js | 97 - benchmark/benchmark.length.int32.js | 97 - benchmark/benchmark.length.int8.js | 97 - benchmark/benchmark.length.uint16.js | 97 - benchmark/benchmark.length.uint32.js | 97 - benchmark/benchmark.length.uint8.js | 97 - benchmark/benchmark.length.uint8c.js | 97 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 36 - dist/index.js.map | 7 - docs/repl.txt | 157 - docs/types/test.ts | 606 --- examples/index.js | 37 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 192 - lib/main.js | 416 -- package.json | 96 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 4397 ------------------- 55 files changed, 4870 insertions(+), 11039 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.length.bool.js delete mode 100644 benchmark/benchmark.length.complex128.js delete mode 100644 benchmark/benchmark.length.complex64.js delete mode 100644 benchmark/benchmark.length.float32.js delete mode 100644 benchmark/benchmark.length.float64.js delete mode 100644 benchmark/benchmark.length.generic.js delete mode 100644 benchmark/benchmark.length.int16.js delete mode 100644 benchmark/benchmark.length.int32.js delete mode 100644 benchmark/benchmark.length.int8.js delete mode 100644 benchmark/benchmark.length.uint16.js delete mode 100644 benchmark/benchmark.length.uint32.js delete mode 100644 benchmark/benchmark.length.uint8.js delete mode 100644 benchmark/benchmark.length.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 8be0b82..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index f988046..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index b2c1f9c..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '42 6 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -278,7 +269,7 @@ for ( i = 0; i < dt.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -347,13 +338,13 @@ 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/dtypes]: https://github.com/stdlib-js/array-dtypes/tree/esm -[@stdlib/array/filled]: https://github.com/stdlib-js/array-filled +[@stdlib/array/filled]: https://github.com/stdlib-js/array-filled/tree/esm -[@stdlib/array/typed]: https://github.com/stdlib-js/array-typed +[@stdlib/array/typed]: https://github.com/stdlib-js/array-typed/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 17cfb5a..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,341 +0,0 @@ -/** -* @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 isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); -var isArray = require( '@stdlib/assert-is-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var Complex64 = require( '@stdlib/complex-float32-ctor' ); -var Complex128 = require( '@stdlib/complex-float64-ctor' ); -var pkg = require( './../package.json' ).name; -var filledarrayBy = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 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=float64', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'float64', 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=float32', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'float32', 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=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; - var i; - - clbk = constantFunction( new Complex128( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'complex128', 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=complex64', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( new Complex64( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'complex64', 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=int32', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int32', 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=uint32', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint32', 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=int16', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int16', 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=uint16', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint16', 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=int8', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int8', 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=uint8', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint8', 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=uint8c', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint8c', 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=generic', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'generic', clbk ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.length.bool.js b/benchmark/benchmark.length.bool.js deleted file mode 100644 index 3cdd152..0000000 --- a/benchmark/benchmark.length.bool.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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/benchmark/benchmark.length.complex128.js b/benchmark/benchmark.length.complex128.js deleted file mode 100644 index 122bc7c..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 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 Complex128 = require( '@stdlib/complex-float64-ctor' ); -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( new Complex128( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'complex128', 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=complex128,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.complex64.js b/benchmark/benchmark.length.complex64.js deleted file mode 100644 index e7a2d74..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 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 Complex64 = require( '@stdlib/complex-float32-ctor' ); -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( new Complex64( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'complex64', 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=complex64,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.float32.js b/benchmark/benchmark.length.float32.js deleted file mode 100644 index d2b2ba7..0000000 --- a/benchmark/benchmark.length.float32.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'float32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=float32,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.float64.js b/benchmark/benchmark.length.float64.js deleted file mode 100644 index 65064e3..0000000 --- a/benchmark/benchmark.length.float64.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'float64', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=float64,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.generic.js b/benchmark/benchmark.length.generic.js deleted file mode 100644 index eb87dfa..0000000 --- a/benchmark/benchmark.length.generic.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isArray = require( '@stdlib/assert-is-array' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'generic', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isArray( 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=generic,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int16.js b/benchmark/benchmark.length.int16.js deleted file mode 100644 index 914ff7c..0000000 --- a/benchmark/benchmark.length.int16.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int16', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=int16,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int32.js b/benchmark/benchmark.length.int32.js deleted file mode 100644 index cc0f678..0000000 --- a/benchmark/benchmark.length.int32.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=int32,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int8.js b/benchmark/benchmark.length.int8.js deleted file mode 100644 index 77553b0..0000000 --- a/benchmark/benchmark.length.int8.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int8', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=int8,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint16.js b/benchmark/benchmark.length.uint16.js deleted file mode 100644 index c68efdd..0000000 --- a/benchmark/benchmark.length.uint16.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint16', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint16,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint32.js b/benchmark/benchmark.length.uint32.js deleted file mode 100644 index 27c1742..0000000 --- a/benchmark/benchmark.length.uint32.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint32,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint8.js b/benchmark/benchmark.length.uint8.js deleted file mode 100644 index 2a26be4..0000000 --- a/benchmark/benchmark.length.uint8.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint8', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint8,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint8c.js b/benchmark/benchmark.length.uint8c.js deleted file mode 100644 index dd6e8c2..0000000 --- a/benchmark/benchmark.length.uint8c.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint8c', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint8c,len='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index c138144..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by" -%% click B href "https://github.com/stdlib-js/array-filled-by/tree/main" -%% click C href "https://github.com/stdlib-js/array-filled-by/tree/production" -%% click D href "https://github.com/stdlib-js/array-filled-by/tree/esm" -%% click E href "https://github.com/stdlib-js/array-filled-by/tree/deno" -%% click F href "https://github.com/stdlib-js/array-filled-by/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by -[production-url]: https://github.com/stdlib-js/array-filled-by/tree/production -[deno-url]: https://github.com/stdlib-js/array-filled-by/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-filled-by/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-filled-by/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-filled-by/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-filled-by/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-filled-by/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 188fc9b..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import filledarrayBy from '../docs/types/index'; -export = filledarrayBy; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 65ae3db..0000000 --- a/dist/index.js +++ /dev/null @@ -1,36 +0,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 deleted file mode 100644 index e88f9aa..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "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,YACjDC,EAAuB,QAAS,uCAAwC,EAAE,YAC1EC,EAAoB,QAAS,+DAAgE,EAC7FC,EAAoB,QAAS,gDAAiD,EAC9EC,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,EAAQ,UAAU,OAGbA,IAAU,EACd,OAAAE,EAAOrB,EAAOS,CAAc,EACrB,IAAIY,EAAM,CAAE,EAIpB,GADAD,EAAQ,UAAW,CAAE,EAChB5B,EAAU4B,CAAM,EAAI,CAExB,GAAKD,EAAQ,EACZ,MAAM,IAAI,UAAW,2FAA4F,EAGlH,GADAE,EAAOrB,EAAOoB,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWd,EAAQ,sEAAuEa,CAAM,CAAE,EAG7G,OAAO,IAAIC,EAAM,CAAE,CACpB,CAEA,GAAKF,EAAQ,EACZ,MAAM,IAAI,UAAW,2FAA4F,EAMlH,GAHAA,GAAS,EAGJpB,EAAY,UAAWoB,CAAM,CAAE,EAEnC,GAAKpB,EAAY,UAAWoB,EAAM,CAAE,CAAE,GAMrC,GALAN,EAAU,UAAWM,CAAM,EAC3BA,GAAS,EACTP,EAAO,UAAWO,CAAM,EAGnBA,IAAU,EACd,MAAM,IAAI,UAAW,2FAA4F,OAIlHP,EAAO,UAAWO,CAAM,UAIhBA,GAAS,GAIlB,GAHAN,EAAU,UAAWM,CAAM,EAC3BA,GAAS,EACTP,EAAO,UAAWO,CAAM,EACnB,CAACpB,EAAYa,CAAK,EACtB,MAAM,IAAI,UAAWL,EAAQ,uEAAwEK,CAAK,CAAE,MAK7G,OAAM,IAAI,UAAW,2FAA4F,EAWlH,GARAO,GAAS,EACJA,GAAS,GAAK3B,EAAU,UAAW2B,CAAM,CAAE,GAC/CC,EAAQ,UAAWD,CAAM,EACzBA,GAAS,GAETC,EAAQX,EAETY,EAAOrB,EAAOoB,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWd,EAAQ,sEAAuEa,CAAM,CAAE,EAG7G,GAAKA,IAAU,UAAY,CAE1B,GADAG,EAAM,UAAW,CAAE,EACdJ,IAAU,EAAI,CAMlB,GALK1B,EAAsB8B,CAAI,EAC9BD,EAAMC,EACK3B,EAAc2B,CAAI,IAC7BD,EAAMC,EAAI,QAEND,IAAQ,OACZ,OAAOpB,EAAaoB,EAAKV,EAAMC,CAAQ,EAExC,GAAKhB,EAAe0B,CAAI,EACvB,MAAM,IAAI,MAAO,mFAAoF,EAEtG,GAAKzB,EAAUyB,CAAI,EAAI,CACtB,GAAKf,IAAwB,GAC5B,MAAM,IAAI,UAAWD,EAAQ,sIAAuIgB,CAAI,CAAE,EAE3K,GAAK,CAACxB,EAAYwB,EAAKnB,CAAgB,CAAE,EACxC,MAAM,IAAI,UAAWG,EAAQ,wGAAyGgB,CAAI,CAAE,EAG7I,GADAA,EAAMA,EAAKnB,CAAgB,EAAE,EACxB,CAACL,EAAYwB,EAAI,IAAK,EAC1B,MAAM,IAAI,UAAWhB,EAAQ,wGAAyGgB,CAAI,CAAE,EAE7I,OAAOb,EAAqBa,EAAKX,EAAMC,CAAQ,CAChD,CACA,MAAM,IAAI,UAAWN,EAAQ,wGAAyGgB,CAAI,CAAE,CAC7I,SAAY1B,EAAe0B,CAAI,EAC9B,MAAM,IAAI,MAAO,mFAAoF,EAEtG,MAAM,IAAI,UAAWhB,EAAQ,wGAAyGgB,CAAI,CAAE,CAC7I,CACA,GAAKJ,IAAU,EAEd,GADAI,EAAM,UAAW,CAAE,EACd3B,EAAc2B,CAAI,EACtBT,EAAM,IAAIO,EAAME,EAAI,MAAO,UAChB1B,EAAe0B,CAAI,EAC9BT,EAAM,IAAIO,EAAME,CAAI,UACT9B,EAAsB8B,CAAI,EACrCT,EAAM,IAAIO,EAAME,CAAI,UACTzB,EAAUyB,CAAI,EAAI,CAC7B,GAAKf,IAAwB,GAC5B,MAAM,IAAI,UAAWD,EAAQ,sIAAuIgB,CAAI,CAAE,EAE3K,GAAK,CAACxB,EAAYwB,EAAKnB,CAAgB,CAAE,EACxC,MAAM,IAAI,UAAWG,EAAQ,wGAAyGgB,CAAI,CAAE,EAG7I,GADAA,EAAMA,EAAKnB,CAAgB,EAAE,EACxB,CAACL,EAAYwB,EAAI,IAAK,EAC1B,MAAM,IAAI,UAAWhB,EAAQ,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,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 deleted file mode 100644 index 06f3146..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,157 +0,0 @@ - -{{alias}}( [dtype] ) - Creates a filled array. - - Parameters - ---------- - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr = {{alias}}() - - > arr = {{alias}}( 'float32' ) - - - -{{alias}}( length[, dtype], clbk[, thisArg] ) - Returns a filled array according to a provided callback function and having - a specified length. - - Parameters - ---------- - length: integer - Array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > function clbk() { return 1.0; }; - > var arr = {{alias}}( 5, clbk ) - [ 1.0, 1.0, 1.0, 1.0, 1.0 ] - > arr = {{alias}}( 5, 'int32', clbk ) - [ 1, 1, 1, 1, 1 ] - - -{{alias}}( array[, dtype], clbk[, thisArg] ) - Creates a filled array from another array (or array-like object) according - to a provided callback function. - - Parameters - ---------- - array: ArrayLikeObject - Array from which to generate another array. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias}}( [ 0.5, 0.5, 0.5 ], {{alias:@stdlib/utils/constant-function}}( 2.0 ) ) - [ 2.0, 2.0, 2.0 ] - > var arr2 = {{alias}}( arr1, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( iterable[, dtype], clbk[, thisArg] ) - Creates a filled array from an iterable according to a provided callback - function. - - Parameters - ---------- - iterable: Iterable - Iterable from which to generate an array. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias:@stdlib/iter/constant}}( 3.0, {'iter': 3} ); - > var arr2 = {{alias}}( arr1, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( buffer[, byteOffset[, length]][, dtype], clbk[, thisArg] ) - Returns a filled typed array view of an ArrayBuffer according to a provided - callback function. - - The 'generic' array data type is *not* supported. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( buf, 0, 4, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0, 1.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index bb876ed..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,606 +0,0 @@ -/* -* @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. -*/ - -/// - -import { IterableIterator } from '@stdlib/types/iter'; -import filledarrayBy = require( './index' ); - - -/** -* Returns an iterator protocol-compliant object. -* -* @returns iterator protocol-compliant object -*/ -function iterator(): IterableIterator { - const obj: IterableIterator = { - [Symbol.iterator]: iterator, - 'next': next - }; - return obj; -} - -/** -* Implements the iterator protocol `next` method. -* -* @returns iterator protocol-compliant object -*/ -function next(): any { - return { - 'value': 1.0, - 'done': false - }; -} - -/** -* Callback function. -* -* @param i - current array index -* @returns return value -*/ -function clbk( i: number ): number { - return i; -} - - -// TESTS // - -// The function returns an array or typed array... -{ - filledarrayBy(); // $ExpectType ArrayOrTypedArray - filledarrayBy( 'float32' ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( 10, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( 10, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( 10, 'int32', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( 10, 'int32', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const x = new Float64Array( 10 ); - filledarrayBy( x, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( x, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( x, 'uint8', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( x, 'uint8', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const y = [ 2.0, 2.0, 2.0 ]; - filledarrayBy( y, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( y, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( y, 'float64', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( y, 'float64', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const it = iterator(); - filledarrayBy( it, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( it, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( it, 'uint8c', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( it, 'uint8c', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const buf = new ArrayBuffer( 32 ); - filledarrayBy( buf, clbk ); // $ExpectType RealOrComplexTypedArray | BooleanArray - filledarrayBy( buf, clbk, {} ); // $ExpectType RealOrComplexTypedArray | BooleanArray - - filledarrayBy( buf, 'uint32', clbk ); // $ExpectType RealOrComplexTypedArray | BooleanArray - filledarrayBy( buf, 'uint32', clbk, {} ); // $ExpectType RealOrComplexTypedArray | BooleanArray - - filledarrayBy( buf, 8, clbk ); // $ExpectType RealOrComplexTypedArray | BooleanArray - filledarrayBy( buf, 8, clbk, {} ); // $ExpectType RealOrComplexTypedArray | BooleanArray - - filledarrayBy( buf, 8, 'uint16', clbk ); // $ExpectType RealOrComplexTypedArray | BooleanArray - filledarrayBy( buf, 8, 'uint16', clbk, {} ); // $ExpectType RealOrComplexTypedArray | BooleanArray - - filledarrayBy( buf, 8, 2, clbk ); // $ExpectType RealOrComplexTypedArray | BooleanArray - filledarrayBy( buf, 8, 2, clbk, {} ); // $ExpectType RealOrComplexTypedArray | BooleanArray - - filledarrayBy( buf, 8, 2, 'int16', clbk ); // $ExpectType RealOrComplexTypedArray | BooleanArray - filledarrayBy( buf, 8, 2, 'int16', clbk, {} ); // $ExpectType RealOrComplexTypedArray | BooleanArray -} - -// The compiler throws an error if a callback function argument is not a function... -{ - filledarrayBy( 'float64', '5' ); // $ExpectError - filledarrayBy( 'float64', 1.0 ); // $ExpectError - filledarrayBy( 'float64', false ); // $ExpectError - filledarrayBy( 'float64', true ); // $ExpectError - filledarrayBy( 'float64', null ); // $ExpectError - filledarrayBy( 'float64', undefined ); // $ExpectError - filledarrayBy( 'float64', [] ); // $ExpectError - filledarrayBy( 'float64', {} ); // $ExpectError - - filledarrayBy( 'float64', '5', {} ); // $ExpectError - filledarrayBy( 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( 'float64', false, {} ); // $ExpectError - filledarrayBy( 'float64', true, {} ); // $ExpectError - filledarrayBy( 'float64', null, {} ); // $ExpectError - filledarrayBy( 'float64', undefined, {} ); // $ExpectError - filledarrayBy( 'float64', [], {} ); // $ExpectError - filledarrayBy( 'float64', {}, {} ); // $ExpectError - - filledarrayBy( 10, '5' ); // $ExpectError - filledarrayBy( 10, 1.0 ); // $ExpectError - filledarrayBy( 10, false ); // $ExpectError - filledarrayBy( 10, true ); // $ExpectError - filledarrayBy( 10, null ); // $ExpectError - filledarrayBy( 10, undefined ); // $ExpectError - filledarrayBy( 10, [] ); // $ExpectError - filledarrayBy( 10, {} ); // $ExpectError - - filledarrayBy( 10, '5', {} ); // $ExpectError - filledarrayBy( 10, 1.0, {} ); // $ExpectError - filledarrayBy( 10, false, {} ); // $ExpectError - filledarrayBy( 10, true, {} ); // $ExpectError - filledarrayBy( 10, null, {} ); // $ExpectError - filledarrayBy( 10, undefined, {} ); // $ExpectError - filledarrayBy( 10, [], {} ); // $ExpectError - filledarrayBy( 10, {}, {} ); // $ExpectError - - filledarrayBy( 10, 'float64', '5' ); // $ExpectError - filledarrayBy( 10, 'float64', 1.0 ); // $ExpectError - filledarrayBy( 10, 'float64', false ); // $ExpectError - filledarrayBy( 10, 'float64', true ); // $ExpectError - filledarrayBy( 10, 'float64', null ); // $ExpectError - filledarrayBy( 10, 'float64', undefined ); // $ExpectError - filledarrayBy( 10, 'float64', [] ); // $ExpectError - filledarrayBy( 10, 'float64', {} ); // $ExpectError - - filledarrayBy( 10, 'float64', '5', {} ); // $ExpectError - filledarrayBy( 10, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( 10, 'float64', false, {} ); // $ExpectError - filledarrayBy( 10, 'float64', true, {} ); // $ExpectError - filledarrayBy( 10, 'float64', null, {} ); // $ExpectError - filledarrayBy( 10, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( 10, 'float64', [], {} ); // $ExpectError - filledarrayBy( 10, 'float64', {}, {} ); // $ExpectError - - const x = new Float64Array( 10 ); - filledarrayBy( x, '5' ); // $ExpectError - filledarrayBy( x, 1.0 ); // $ExpectError - filledarrayBy( x, false ); // $ExpectError - filledarrayBy( x, true ); // $ExpectError - filledarrayBy( x, null ); // $ExpectError - filledarrayBy( x, undefined ); // $ExpectError - filledarrayBy( x, [] ); // $ExpectError - filledarrayBy( x, {} ); // $ExpectError - - filledarrayBy( x, '5', {} ); // $ExpectError - filledarrayBy( x, 1.0, {} ); // $ExpectError - filledarrayBy( x, false, {} ); // $ExpectError - filledarrayBy( x, true, {} ); // $ExpectError - filledarrayBy( x, null, {} ); // $ExpectError - filledarrayBy( x, undefined, {} ); // $ExpectError - filledarrayBy( x, [], {} ); // $ExpectError - filledarrayBy( x, {}, {} ); // $ExpectError - - filledarrayBy( x, 'float64', '5' ); // $ExpectError - filledarrayBy( x, 'float64', 1.0 ); // $ExpectError - filledarrayBy( x, 'float64', false ); // $ExpectError - filledarrayBy( x, 'float64', true ); // $ExpectError - filledarrayBy( x, 'float64', null ); // $ExpectError - filledarrayBy( x, 'float64', undefined ); // $ExpectError - filledarrayBy( x, 'float64', [] ); // $ExpectError - filledarrayBy( x, 'float64', {} ); // $ExpectError - - filledarrayBy( x, 'float64', '5', {} ); // $ExpectError - filledarrayBy( x, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( x, 'float64', false, {} ); // $ExpectError - filledarrayBy( x, 'float64', true, {} ); // $ExpectError - filledarrayBy( x, 'float64', null, {} ); // $ExpectError - filledarrayBy( x, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( x, 'float64', [], {} ); // $ExpectError - filledarrayBy( x, 'float64', {}, {} ); // $ExpectError - - const y = [ 2.0, 2.0, 2.0 ]; - filledarrayBy( y, '5' ); // $ExpectError - filledarrayBy( y, 1.0 ); // $ExpectError - filledarrayBy( y, false ); // $ExpectError - filledarrayBy( y, true ); // $ExpectError - filledarrayBy( y, null ); // $ExpectError - filledarrayBy( y, undefined ); // $ExpectError - filledarrayBy( y, [] ); // $ExpectError - filledarrayBy( y, {} ); // $ExpectError - - filledarrayBy( y, '5', {} ); // $ExpectError - filledarrayBy( y, 1.0, {} ); // $ExpectError - filledarrayBy( y, false, {} ); // $ExpectError - filledarrayBy( y, true, {} ); // $ExpectError - filledarrayBy( y, null, {} ); // $ExpectError - filledarrayBy( y, undefined, {} ); // $ExpectError - filledarrayBy( y, [], {} ); // $ExpectError - filledarrayBy( y, {}, {} ); // $ExpectError - - filledarrayBy( y, 'float64', '5' ); // $ExpectError - filledarrayBy( y, 'float64', 1.0 ); // $ExpectError - filledarrayBy( y, 'float64', false ); // $ExpectError - filledarrayBy( y, 'float64', true ); // $ExpectError - filledarrayBy( y, 'float64', null ); // $ExpectError - filledarrayBy( y, 'float64', undefined ); // $ExpectError - filledarrayBy( y, 'float64', [] ); // $ExpectError - filledarrayBy( y, 'float64', {} ); // $ExpectError - - filledarrayBy( y, 'float64', '5', {} ); // $ExpectError - filledarrayBy( y, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( y, 'float64', false, {} ); // $ExpectError - filledarrayBy( y, 'float64', true, {} ); // $ExpectError - filledarrayBy( y, 'float64', null, {} ); // $ExpectError - filledarrayBy( y, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( y, 'float64', [], {} ); // $ExpectError - filledarrayBy( y, 'float64', {}, {} ); // $ExpectError - - const it = iterator(); - filledarrayBy( it, '5' ); // $ExpectError - filledarrayBy( it, 1.0 ); // $ExpectError - filledarrayBy( it, false ); // $ExpectError - filledarrayBy( it, true ); // $ExpectError - filledarrayBy( it, null ); // $ExpectError - filledarrayBy( it, undefined ); // $ExpectError - filledarrayBy( it, [] ); // $ExpectError - filledarrayBy( it, {} ); // $ExpectError - - filledarrayBy( it, '5', {} ); // $ExpectError - filledarrayBy( it, 1.0, {} ); // $ExpectError - filledarrayBy( it, false, {} ); // $ExpectError - filledarrayBy( it, true, {} ); // $ExpectError - filledarrayBy( it, null, {} ); // $ExpectError - filledarrayBy( it, undefined, {} ); // $ExpectError - filledarrayBy( it, [], {} ); // $ExpectError - filledarrayBy( it, {}, {} ); // $ExpectError - - filledarrayBy( it, 'float64', '5' ); // $ExpectError - filledarrayBy( it, 'float64', 1.0 ); // $ExpectError - filledarrayBy( it, 'float64', false ); // $ExpectError - filledarrayBy( it, 'float64', true ); // $ExpectError - filledarrayBy( it, 'float64', null ); // $ExpectError - filledarrayBy( it, 'float64', undefined ); // $ExpectError - filledarrayBy( it, 'float64', [] ); // $ExpectError - filledarrayBy( it, 'float64', {} ); // $ExpectError - - filledarrayBy( it, 'float64', '5', {} ); // $ExpectError - filledarrayBy( it, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( it, 'float64', false, {} ); // $ExpectError - filledarrayBy( it, 'float64', true, {} ); // $ExpectError - filledarrayBy( it, 'float64', null, {} ); // $ExpectError - filledarrayBy( it, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( it, 'float64', [], {} ); // $ExpectError - filledarrayBy( it, 'float64', {}, {} ); // $ExpectError - - const buf = new ArrayBuffer( 32 ); - filledarrayBy( buf, '5' ); // $ExpectError - filledarrayBy( buf, 1.0 ); // $ExpectError - filledarrayBy( buf, false ); // $ExpectError - filledarrayBy( buf, true ); // $ExpectError - filledarrayBy( buf, null ); // $ExpectError - filledarrayBy( buf, undefined ); // $ExpectError - filledarrayBy( buf, [] ); // $ExpectError - filledarrayBy( buf, {} ); // $ExpectError - - filledarrayBy( buf, '5', {} ); // $ExpectError - filledarrayBy( buf, 1.0, {} ); // $ExpectError - filledarrayBy( buf, false, {} ); // $ExpectError - filledarrayBy( buf, true, {} ); // $ExpectError - filledarrayBy( buf, null, {} ); // $ExpectError - filledarrayBy( buf, undefined, {} ); // $ExpectError - filledarrayBy( buf, [], {} ); // $ExpectError - filledarrayBy( buf, {}, {} ); // $ExpectError - - filledarrayBy( buf, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 'float64', false ); // $ExpectError - filledarrayBy( buf, 'float64', true ); // $ExpectError - filledarrayBy( buf, 'float64', null ); // $ExpectError - filledarrayBy( buf, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 'float64', {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5' ); // $ExpectError - filledarrayBy( buf, 8, 1.0 ); // $ExpectError - filledarrayBy( buf, 8, false ); // $ExpectError - filledarrayBy( buf, 8, true ); // $ExpectError - filledarrayBy( buf, 8, null ); // $ExpectError - filledarrayBy( buf, 8, undefined ); // $ExpectError - filledarrayBy( buf, 8, [] ); // $ExpectError - filledarrayBy( buf, 8, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, false, {} ); // $ExpectError - filledarrayBy( buf, 8, true, {} ); // $ExpectError - filledarrayBy( buf, 8, null, {} ); // $ExpectError - filledarrayBy( buf, 8, undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, [], {} ); // $ExpectError - filledarrayBy( buf, 8, {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 8, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 'float64', false ); // $ExpectError - filledarrayBy( buf, 8, 'float64', true ); // $ExpectError - filledarrayBy( buf, 8, 'float64', null ); // $ExpectError - filledarrayBy( buf, 8, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 8, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 8, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 8, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, '5' ); // $ExpectError - filledarrayBy( buf, 8, 2, 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 2, false ); // $ExpectError - filledarrayBy( buf, 8, 2, true ); // $ExpectError - filledarrayBy( buf, 8, 2, null ); // $ExpectError - filledarrayBy( buf, 8, 2, undefined ); // $ExpectError - filledarrayBy( buf, 8, 2, [] ); // $ExpectError - filledarrayBy( buf, 8, 2, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, false, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, true, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, null, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, [], {} ); // $ExpectError - filledarrayBy( buf, 8, 2, {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', false ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', true ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', null ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', {}, {} ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid length, typed array, array-like object, `ArrayBuffer`, or iterable argument... -{ - filledarrayBy( false, clbk ); // $ExpectError - filledarrayBy( true, clbk ); // $ExpectError - filledarrayBy( null, clbk ); // $ExpectError - filledarrayBy( {}, clbk ); // $ExpectError - - filledarrayBy( false, clbk, {} ); // $ExpectError - filledarrayBy( true, clbk, {} ); // $ExpectError - filledarrayBy( null, clbk, {} ); // $ExpectError - filledarrayBy( {}, clbk, {} ); // $ExpectError - - filledarrayBy( false, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 'float64', clbk ); // $ExpectError - - filledarrayBy( false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, clbk ); // $ExpectError - filledarrayBy( 1.0, 8, clbk ); // $ExpectError - filledarrayBy( false, 8, clbk ); // $ExpectError - filledarrayBy( true, 8, clbk ); // $ExpectError - filledarrayBy( null, 8, clbk ); // $ExpectError - filledarrayBy( undefined, 8, clbk ); // $ExpectError - filledarrayBy( [], 8, clbk ); // $ExpectError - filledarrayBy( {}, 8, clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, clbk ); // $ExpectError - - filledarrayBy( '5', 8, clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, clbk, {} ); // $ExpectError - filledarrayBy( false, 8, clbk, {} ); // $ExpectError - filledarrayBy( true, 8, clbk, {} ); // $ExpectError - filledarrayBy( null, 8, clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, clbk, {} ); // $ExpectError - filledarrayBy( [], 8, clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 'float64', clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( false, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( [], 8, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 'float64', clbk ); // $ExpectError - - filledarrayBy( '5', 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 2, clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 2, clbk ); // $ExpectError - filledarrayBy( false, 8, 2, clbk ); // $ExpectError - filledarrayBy( true, 8, 2, clbk ); // $ExpectError - filledarrayBy( null, 8, 2, clbk ); // $ExpectError - filledarrayBy( undefined, 8, 2, clbk ); // $ExpectError - filledarrayBy( [], 8, 2, clbk ); // $ExpectError - filledarrayBy( {}, 8, 2, clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, clbk ); // $ExpectError - - filledarrayBy( '5', 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( false, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( [], 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, 'float64', clbk ); // $ExpectError - - filledarrayBy( '5', 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a byte offset argument which is not a number... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, false, clbk ); // $ExpectError - filledarrayBy( buf, true, clbk ); // $ExpectError - filledarrayBy( buf, null, clbk ); // $ExpectError - filledarrayBy( buf, [], clbk ); // $ExpectError - filledarrayBy( buf, {}, clbk ); // $ExpectError - - filledarrayBy( buf, false, clbk, {} ); // $ExpectError - filledarrayBy( buf, true, clbk, {} ); // $ExpectError - filledarrayBy( buf, null, clbk, {} ); // $ExpectError - filledarrayBy( buf, [], clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, clbk, {} ); // $ExpectError - - filledarrayBy( buf, '5', 'float64', clbk ); // $ExpectError - filledarrayBy( buf, false, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, true, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, null, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, [], 'float64', clbk ); // $ExpectError - filledarrayBy( buf, {}, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, '5', 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( buf, false, 2, clbk ); // $ExpectError - filledarrayBy( buf, true, 2, clbk ); // $ExpectError - filledarrayBy( buf, null, 2, clbk ); // $ExpectError - filledarrayBy( buf, [], 2, clbk ); // $ExpectError - filledarrayBy( buf, {}, 2, clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, clbk ); // $ExpectError - - filledarrayBy( buf, false, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, clbk, {} ); // $ExpectError - - filledarrayBy( buf, '5', 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, false, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, true, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, null, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, undefined, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, [], 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, {}, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, '5', 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, false, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, undefined, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a view length argument which is not a number... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, 8, false, clbk ); // $ExpectError - filledarrayBy( buf, 8, true, clbk ); // $ExpectError - filledarrayBy( buf, 8, null, clbk ); // $ExpectError - filledarrayBy( buf, 8, [], clbk ); // $ExpectError - filledarrayBy( buf, 8, {}, clbk ); // $ExpectError - - filledarrayBy( buf, 8, false, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, true, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, null, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, [], clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, {}, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, clbk, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5', 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, false, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, true, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, null, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, [], 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, {}, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, 8, '5', 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, [], 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, {}, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided too many arguments... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, 8, 2, 'float64', 1, clbk, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 997a381..0000000 --- a/examples/index.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ).factory; -var dtypes = require( '@stdlib/array-typed-real-dtypes' ); -var filledarrayBy = require( './../lib' ); - -// Create a pseudorandom number generator: -var rand = discreteUniform( 0, 100 ); - -// Get a list of array data types: -var dt = dtypes(); - -// Generate filled arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = filledarrayBy( 10, dt[ i ], rand ); - console.log( arr ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 764e40e..cb63cd1 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, RealOrComplexTypedArray, BooleanArray, DataType } from '@stdlib/types/array'; import { IterableIterator } from '@stdlib/types/iter'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..1c99feb --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@v0.0.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-ctors@v0.3.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill-by@v0.2.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled-by@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@v0.2.2-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.3.0-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";var v=f(),g=j.get("dtypes.default");function c(){var f,j,c,b,y,x,u,E;if(0===(j=arguments.length))return new(y=d(g))(0);if(r(c=arguments[0])){if(j>1)throw new TypeError(w("00h05"));if(null===(y=d(c)))throw new TypeError(w("00h2Y",c));return new y(0)}if(j<2)throw new TypeError(w("00h05"));if(h(arguments[j-=1]))if(h(arguments[j-1])){if(f=arguments[j],b=arguments[j-=1],0===j)throw new TypeError(w("00h05"))}else b=arguments[j];else{if(!(j>=2))throw new TypeError(w("00h05"));if(f=arguments[j],!h(b=arguments[j-=1]))throw new TypeError(w("00h2b",b))}if((j-=1)>=0&&r(arguments[j])?(c=arguments[j],j-=1):c=g,null===(y=d(c)))throw new TypeError(w("00h2Y",c));if("generic"===c){if(E=arguments[0],0===j){if(e(E)?u=E:i(E)&&(u=E.length),void 0!==u)return m(u,b,f);if(n(E))throw new Error(w("00h04"));if(o(E)){if(!1===v)throw new TypeError(w("00h2Z",E));if(!h(E[p]))throw new TypeError(w("00h2a",E));if(E=E[p](),!h(E.next))throw new TypeError(w("00h2a",E));return function(r,e,t){var s,i;for(s=[],i=-1;!r.next().done;)i+=1,s.push(e.call(t,i));return s}(E,b,f)}throw new TypeError(w("00h2a",E))}if(n(E))throw new Error(w("00h04"));throw new TypeError(w("00h2a",E))}if(0===j)if(i(E=arguments[0]))x=new y(E.length);else if(n(E))x=new y(E);else if(e(E))x=new y(E);else{if(!o(E))throw new TypeError(w("00h2a",E));if(!1===v)throw new TypeError(w("00h2Z",E));if(!h(E[p]))throw new TypeError(w("00h2a",E));if(E=E[p](),!h(E.next))throw new TypeError(w("00h2a",E));x=new y(a(E))}else x=1===j?new y(arguments[0],arguments[1]):new y(arguments[0],arguments[1],arguments[2]);return x.length>0&&(t(c)||s(c)?function(r,e,t){var s;for(s=0;s\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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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( format('00h05') );\n\t\t}\n\t\tctor = ctors( dtype );\n\t\tif ( ctor === null ) {\n\t\t\tthrow new TypeError( format( '00h2Y', 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( format('00h05') );\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( format('00h05') );\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( '00h2b', 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( format('00h05') );\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( '00h2Y', 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( format('00h04') );\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( '00h2Z', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00h2a', 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( '00h2a', 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( '00h2a', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format('00h04') );\n\t\t}\n\t\tthrow new TypeError( format( '00h2a', 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( '00h2Z', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00h2a', 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( '00h2a', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00h2a', 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\nexport default filledarrayBy;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","DEFAULT_DTYPE","defaults","get","filledarrayBy","thisArg","nargs","dtype","clbk","ctor","arr","len","arg","arguments","length","ctors","isString","TypeError","format","isFunction","isNonNegativeInteger","isCollection","filledArray","isArrayBuffer","Error","isObject","ITERATOR_SYMBOL","next","it","i","done","push","call","filledArrayIterator","iterLength","isComplexDataType","isBooleanDataType","set","filledAccessors","gfillBy","value","aidx"],"mappings":";;sjDA0CA,IAAIA,EAAsBC,IACtBC,EAAgBC,EAASC,IAAK,kBA2MlC,SAASC,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAKJ,GAAe,KAHfN,EAAQO,UAAUC,QAKjB,OAAO,IADPL,EAAOM,EAAOd,IACG,GAIlB,GAAKe,EADLT,EAAQM,UAAW,IACM,CAExB,GAAKP,EAAQ,EACZ,MAAM,IAAIW,UAAWC,EAAO,UAG7B,GAAc,QADdT,EAAOM,EAAOR,IAEb,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,OAAO,IAAIE,EAAM,EACjB,CAED,GAAKH,EAAQ,EACZ,MAAM,IAAIW,UAAWC,EAAO,UAM7B,GAAKC,EAAYN,UAHjBP,GAAS,IAKR,GAAKa,EAAYN,UAAWP,EAAM,KAMjC,GALAD,EAAUQ,UAAWP,GAErBE,EAAOK,UADPP,GAAS,GAIM,IAAVA,EACJ,MAAM,IAAIW,UAAWC,EAAO,eAI7BV,EAAOK,UAAWP,OAIf,MAAKA,GAAS,GAUlB,MAAM,IAAIW,UAAWC,EAAO,UAN5B,GAHAb,EAAUQ,UAAWP,IAGfa,EADNX,EAAOK,UADPP,GAAS,IAGR,MAAM,IAAIW,UAAWC,EAAQ,QAASV,GAMvC,CAUD,IARAF,GAAS,IACK,GAAKU,EAAUH,UAAWP,KACvCC,EAAQM,UAAWP,GACnBA,GAAS,GAETC,EAAQN,EAGK,QADdQ,EAAOM,EAAOR,IAEb,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,GAAe,YAAVA,EAAsB,CAE1B,GADAK,EAAMC,UAAW,GACF,IAAVP,EAAc,CAMlB,GALKc,EAAsBR,GAC1BD,EAAMC,EACKS,EAAcT,KACzBD,EAAMC,EAAIE,aAEE,IAARH,EACJ,OAAOW,EAAaX,EAAKH,EAAMH,GAEhC,GAAKkB,EAAeX,GACnB,MAAM,IAAIY,MAAON,EAAO,UAEzB,GAAKO,EAAUb,GAAQ,CACtB,IAA6B,IAAxBb,EACJ,MAAM,IAAIkB,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAYP,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLP,EAAYP,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvC,OAvSJ,SAA8BgB,EAAIpB,EAAMH,GACvC,IAAIK,EACAmB,EAKJ,IAFAnB,EAAM,GACNmB,GAAK,GAEAD,EAAGD,OACAG,MAGPD,GAAK,EACLnB,EAAIqB,KAAMvB,EAAKwB,KAAM3B,EAASwB,IAE/B,OAAOnB,CACR,CAuRWuB,CAAqBrB,EAAKJ,EAAMH,EACvC,CACD,MAAM,IAAIY,UAAWC,EAAQ,QAASN,GACzC,CAAS,GAAKW,EAAeX,GAC1B,MAAM,IAAIY,MAAON,EAAO,UAEzB,MAAM,IAAID,UAAWC,EAAQ,QAASN,GACtC,CACD,GAAe,IAAVN,EAEJ,GAAKe,EADLT,EAAMC,UAAW,IAEhBH,EAAM,IAAID,EAAMG,EAAIE,aACd,GAAKS,EAAeX,GAC1BF,EAAM,IAAID,EAAMG,QACV,GAAKQ,EAAsBR,GACjCF,EAAM,IAAID,EAAMG,OACV,KAAKa,EAAUb,GAarB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAZtC,IAA6B,IAAxBb,EACJ,MAAM,IAAIkB,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAYP,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLP,EAAYP,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvCF,EAAM,IAAID,EAAMyB,EAAYtB,GAG5B,MAEDF,EADqB,IAAVJ,EACL,IAAIG,EAAMI,UAAU,GAAIA,UAAU,IAElC,IAAIJ,EAAMI,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKH,EAAII,OAAS,IACZqB,EAAmB5B,IAAW6B,EAAmB7B,GAjTxD,SAA0BG,EAAKF,EAAMH,GACpC,IAAIwB,EACJ,IAAMA,EAAI,EAAGA,EAAInB,EAAII,OAAQe,IAC5BnB,EAAI2B,IAAK7B,EAAKwB,KAAM3B,EAASwB,GAAKA,EAGpC,CA4SGS,CAAiB5B,EAAKF,EAAMH,GAE5BkC,EAAS7B,EAAII,OAAQJ,EAAK,GAe5B,SAAmB8B,EAAOC,GACzB,OAAOjC,EAAKwB,KAAM3B,EAASoC,EAC3B,KAdM/B,CAeR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d115cf0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,192 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -/** -* Create a filled array according to a provided callback function. -* -* @module @stdlib/array-filled-by -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* var arr = filledarrayBy(); -* // returns -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'generic', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( [ 0.5, 0.5 ], clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1; -* } -* -* var arr = filledarrayBy( [ 5, -3 ], 'int32', clbk ); -* // returns [ 1, 1 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk1() { -* return 10; -* } -* -* function clbk2() { -* return 1.0; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, clbk2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk1() { -* return 1.0; -* } -* -* function clbk2() { -* return 2; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, 'uint32', clbk2 ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 'float32', clbk ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, clbk ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, 'int32', clbk ); -* // returns [ 1, 1 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index ed1aa9a..0000000 --- a/lib/main.js +++ /dev/null @@ -1,416 +0,0 @@ -/** -* @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 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' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var ctors = require( '@stdlib/array-ctors' ); -var gfillBy = require( '@stdlib/blas-ext-base-gfill-by' ); -var filledArray = require( '@stdlib/array-base-filled-by' ); -var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var iterLength = require( '@stdlib/iter-length' ); -var defaults = require( '@stdlib/array-defaults' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport(); -var DEFAULT_DTYPE = defaults.get( 'dtypes.default' ); - - -// FUNCTIONS // - -/** -* Creates a filled "generic" array from an iterator. -* -* @private -* @param {Iterable} it - iterator -* @param {Callback} clbk - callback function -* @param {*} thisArg - callback function execution context -* @returns {Array} filled array -*/ -function filledArrayIterator( it, clbk, thisArg ) { - var arr; - var i; - var v; - - arr = []; - i = -1; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - i += 1; - arr.push( clbk.call( thisArg, i ) ); - } - return arr; -} - -/** -* Fills an array exposing accessors for getting and setting array elements. -* -* @private -* @param {Collection} arr - input array -* @param {Callback} clbk - callback function -* @param {*} thisArg - callback function execution context -* @returns {Collection} input array -*/ -function filledAccessors( arr, clbk, thisArg ) { - var i; - for ( i = 0; i < arr.length; i++ ) { - arr.set( clbk.call( thisArg, i ), i ); - } - return arr; -} - - -// MAIN // - -/** -* Creates a filled array according to a provided callback function. -* -* @param {(NonNegativeInteger|TypedArray|ArrayLikeObject|ArrayBuffer|Iterable)} [arg] - a length, typed array, array-like object, buffer, or iterable -* @param {NonNegativeInteger} [byteOffset=0] - byte offset -* @param {NonNegativeInteger} [length] - view length -* @param {string} [dtype="float64"] - data type -* @param {Callback} [clbk] - callback to invoke -* @param {*} [thisArg] - callback execution context -* @throws {TypeError} must provide a recognized data type -* @throws {TypeError} must provide a length, typed array, array-like object, buffer, or iterable -* @throws {TypeError} callback argument must be a function. -* @throws {Error} creating a generic array from an `ArrayBuffer` is not supported -* @returns {(TypedArray|Array)} array or typed array -* -* @example -* var arr = filledarrayBy(); -* // returns -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'generic', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( [ 0.5, 0.5 ], clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1; -* } -* -* var arr = filledarrayBy( [ 5, -3 ], 'int32', clbk ); -* // returns [ 1, 1 ] -* -* @example -* function clbk1() { -* return 10; -* } -* -* function clbk2() { -* return 1.0; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, clbk2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk1() { -* return 1.0; -* } -* -* function clbk2() { -* return 2; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, 'uint32', clbk2 ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 'float32', clbk ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, clbk ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, 'int32', clbk ); -* // returns [ 1, 1 ] -*/ -function filledarrayBy() { - var thisArg; - var nargs; - var dtype; - var clbk; - var ctor; - var arr; - var len; - var arg; - - nargs = arguments.length; - - // If we weren't provided any arguments, return an empty array... - if ( nargs === 0 ) { - ctor = ctors( DEFAULT_DTYPE ); - return new ctor( 0 ); - } - // Check if we were provided a dtype as the first argument... - dtype = arguments[ 0 ]; - if ( isString( dtype ) ) { - // Invoking this function with arguments `f( dtype, clbk[, thisArg] )` is not allowed (otherwise, we'd need to also allow `f( clbk[, thisArg] )`)... - if ( nargs > 1 ) { - throw new TypeError( format('00h05') ); - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '00h2Y', dtype ) ); - } - // Return an empty array having the specified dtype: - return new ctor( 0 ); - } - // For all other supported invocations, we need at least two arguments... - if ( nargs < 2 ) { - throw new TypeError( format('00h05') ); - } - // At this point, we need to do some argument juggling... - nargs -= 1; // henceforth, the number of available arguments is `nargs+1` - - // Determine whether the last argument is a callback or "this" context... - if ( isFunction( arguments[ nargs ] ) ) { - // 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... - if ( isFunction( arguments[ nargs-1 ] ) ) { - thisArg = arguments[ nargs ]; - nargs -= 1; - clbk = arguments[ nargs ]; - - // Check if we were provided only a callback and a "this" context.. - if ( nargs === 0 ) { - throw new TypeError( format('00h05') ); - } - } else { - // "this" context is left undefined... - clbk = arguments[ nargs ]; - } - } - // 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... - else if ( nargs >= 2 ) { - thisArg = arguments[ nargs ]; - nargs -= 1; - clbk = arguments[ nargs ]; - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '00h2b', clbk ) ); - } - } - // If were were only provided 2 arguments and the last argument was not a function, we've been provided an insufficient number of arguments... - else { - throw new TypeError( format('00h05') ); - } - // Now that we've processed the callback arguments, let's continue working backward to see if we've been provided a `dtype` argument... - nargs -= 1; - if ( nargs >= 0 && isString( arguments[ nargs ] ) ) { - dtype = arguments[ nargs ]; - nargs -= 1; - } else { - dtype = DEFAULT_DTYPE; - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '00h2Y', dtype ) ); - } - // At this point, we've resolved the output array data type, and now we can actually create the output array... - if ( dtype === 'generic' ) { - arg = arguments[ 0 ]; - if ( nargs === 0 ) { - if ( isNonNegativeInteger( arg ) ) { - len = arg; - } else if ( isCollection( arg ) ) { - len = arg.length; - } - if ( len !== void 0 ) { - return filledArray( len, clbk, thisArg ); - } - if ( isArrayBuffer( arg ) ) { - throw new Error( format('00h04') ); - } - if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( '00h2Z', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00h2a', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00h2a', arg ) ); - } - return filledArrayIterator( arg, clbk, thisArg ); - } - throw new TypeError( format( '00h2a', arg ) ); - } else if ( isArrayBuffer( arg ) ) { - throw new Error( format('00h04') ); - } - throw new TypeError( format( '00h2a', arg ) ); - } - if ( nargs === 0 ) { // length || array-like || ArrayBuffer || iterable - arg = arguments[ 0 ]; - if ( isCollection( arg ) ) { - arr = new ctor( arg.length ); - } else if ( isArrayBuffer( arg ) ) { - arr = new ctor( arg ); - } else if ( isNonNegativeInteger( arg ) ) { - arr = new ctor( arg ); - } else if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( '00h2Z', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00h2a', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00h2a', arg ) ); - } - arr = new ctor( iterLength( arg ) ); - } else { - throw new TypeError( format( '00h2a', arg ) ); - } - } else if ( nargs === 1 ) { - arr = new ctor( arguments[0], arguments[1] ); // (ArrayBuffer, byteOffset) - } else { - arr = new ctor( arguments[0], arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset, length) - } - if ( arr.length > 0 ) { - if ( isComplexDataType( dtype ) || isBooleanDataType( dtype ) ) { - filledAccessors( arr, clbk, thisArg ); - } else { - gfillBy( arr.length, arr, 1, callback ); - } - } - return arr; - - /** - * Callback which wraps a provided callback and is invoked for each array element. - * - * @private - * @param {*} value - element value - * @param {NonNegativeInteger} aidx - array index - * @param {NonNegativeInteger} sidx - strided index - * @param {Collection} array - input array/collection - * @returns {*} callback return value - */ - function callback( value, aidx ) { - return clbk.call( thisArg, aidx ); - } -} - - -// EXPORTS // - -module.exports = filledarrayBy; diff --git a/package.json b/package.json index d01aec1..b16be36 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Create a filled array according to a provided callback function.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,75 +13,6 @@ "bugs": { "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.2", - "@stdlib/array-ctors": "^0.3.0", - "@stdlib/array-defaults": "^0.3.0", - "@stdlib/assert-has-iterator-symbol-support": "^0.2.2", - "@stdlib/assert-is-arraybuffer": "^0.2.2", - "@stdlib/assert-is-collection": "^0.2.2", - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer": "^0.2.2", - "@stdlib/assert-is-object": "^0.2.2", - "@stdlib/assert-is-string": "^0.2.2", - "@stdlib/blas-ext-base-gfill-by": "^0.2.1", - "@stdlib/iter-length": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/symbol-iterator": "^0.2.2", - "@stdlib/types": "^0.4.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-bool": "^0.1.0", - "@stdlib/array-buffer": "^0.2.2", - "@stdlib/array-complex128": "^0.3.0", - "@stdlib/array-complex64": "^0.3.0", - "@stdlib/array-float32": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/array-int16": "^0.2.2", - "@stdlib/array-int32": "^0.2.2", - "@stdlib/array-int8": "^0.2.2", - "@stdlib/array-typed-real-dtypes": "^0.2.2", - "@stdlib/array-uint16": "^0.2.2", - "@stdlib/array-uint32": "^0.2.2", - "@stdlib/array-uint8": "^0.2.2", - "@stdlib/array-uint8c": "^0.2.2", - "@stdlib/assert-instance-of": "^0.2.2", - "@stdlib/assert-is-array": "^0.2.2", - "@stdlib/assert-is-typed-array": "^0.2.2", - "@stdlib/assert-is-typed-array-like": "^0.2.2", - "@stdlib/complex-float32-ctor": "^0.0.2", - "@stdlib/complex-float64-ctor": "^0.0.3", - "@stdlib/iter-constant": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/random-base-discrete-uniform": "^0.2.1", - "@stdlib/strided-base-reinterpret-boolean": "^0.0.2", - "@stdlib/strided-base-reinterpret-complex128": "^0.2.2", - "@stdlib/strided-base-reinterpret-complex64": "^0.2.1", - "@stdlib/utils-constant-function": "^0.2.2", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..e4cee9c --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index ca0cf25..0000000 --- a/test/test.js +++ /dev/null @@ -1,4397 +0,0 @@ -/** -* @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. -*/ - -/* eslint-disable max-len */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -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' ); -var iterConstant = require( '@stdlib/iter-constant' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var filledarrayBy = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': !hasIteratorSymbolSupport() -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof filledarrayBy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if only provided callback arguments', function test( t ) { - t.throws( clbk1, TypeError, 'throws an error' ); - t.throws( clbk2, TypeError, 'throws an error' ); - t.throws( clbk3, TypeError, 'throws an error' ); - t.end(); - - function clbk1() { - filledarrayBy( constantFunction( 1.0 ) ); - } - - function clbk2() { - filledarrayBy( constantFunction( 1.0 ), {} ); - } - - function clbk3() { - filledarrayBy( constantFunction( 1.0 ), constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (only argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (typed array; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (array-like object)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (array-like object; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 8 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 8 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, 1, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (iterator)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( iterConstant( 1.0 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (iterator; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( iterConstant( 1.0 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if only provided data type and callback arguments', function test( t ) { - t.throws( clbk1, TypeError, 'throws an error' ); - t.throws( clbk2, TypeError, 'throws an error' ); - t.throws( clbk3, TypeError, 'throws an error' ); - t.end(); - - function clbk1() { - filledarrayBy( 'float64', constantFunction( 1.0 ) ); - } - - function clbk2() { - filledarrayBy( 'float64', constantFunction( 1.0 ), {} ); - } - - function clbk3() { - filledarrayBy( 'float64', constantFunction( 1.0 ), constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (array-like object)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (array-like object; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, 1, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, 1, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (no iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (no iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (non-function iterator symbol property)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (non-function iterator symbol property; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (`next` property is not a function)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ) ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (`next` property is not a function; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ), {} ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (no iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (no iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (non-function iterator symbol property)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (non-function iterator symbol property; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (`next` property is not a function)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ) ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (`next` property is not a function; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ), {} ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 1, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 1, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function returns a filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - arr = filledarrayBy(); - - t.strictEqual( instanceOf( arr, Float64Array ), 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=float64)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - arr = filledarrayBy( 'float64' ); - - t.strictEqual( instanceOf( arr, Float64Array ), 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=float32)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( 0 ); - arr = filledarrayBy( 'float32' ); - - t.strictEqual( instanceOf( arr, Float32Array ), 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=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; - - expected = new Complex128Array( 0 ); - arr = filledarrayBy( 'complex128' ); - - t.strictEqual( instanceOf( arr, Complex128Array ), 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=complex64)', function test( t ) { - var expected; - var arr; - - expected = new Complex64Array( 0 ); - arr = filledarrayBy( 'complex64' ); - - t.strictEqual( instanceOf( arr, Complex64Array ), 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=int32)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( 0 ); - arr = filledarrayBy( 'int32' ); - - t.strictEqual( instanceOf( arr, Int32Array ), 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=uint32)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( 0 ); - arr = filledarrayBy( 'uint32' ); - - t.strictEqual( instanceOf( arr, Uint32Array ), 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=int16)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( 0 ); - arr = filledarrayBy( 'int16' ); - - t.strictEqual( instanceOf( arr, Int16Array ), 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=uint16)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( 0 ); - arr = filledarrayBy( 'uint16' ); - - t.strictEqual( instanceOf( arr, Uint16Array ), 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=int8)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( 0 ); - arr = filledarrayBy( 'int8' ); - - t.strictEqual( instanceOf( arr, Int8Array ), 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=uint8)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( 0 ); - arr = filledarrayBy( 'uint8' ); - - t.strictEqual( instanceOf( arr, Uint8Array ), 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=uint8c)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( 0 ); - arr = filledarrayBy( 'uint8c' ); - - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), 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=generic)', function test( t ) { - var expected; - var arr; - - expected = []; - arr = filledarrayBy( 'generic' ); - - t.strictEqual( instanceOf( arr, Array ), 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 (default, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, length=0)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array(); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 0, clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, clbk, ctx ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (default, length; thisArg=function)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, clbk, context ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this(); // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } - - function context() { - ctx.count += 1; - } -}); - -tape( 'the function returns a filled array (dtype=float64, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, 'float64', clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, length; thisArg=function)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, 'float64', clbk, context ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this(); // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } - - function context() { - ctx.count += 1; - } -}); - -tape( 'the function returns a filled array (dtype=float32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, 'float32', clbk ); - - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - 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; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = filledarrayBy( 5, 'complex128', clbk ); - - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = filledarrayBy( 5, 'complex64', clbk ); - - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int32Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int32', clbk ); - - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint32Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint32', clbk ); - - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int16Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int16', clbk ); - - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint16', clbk ); - - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int8Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int8', clbk ); - - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint8', clbk ); - - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint8c', clbk ); - - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = [ 1, 1, 1, 1, 1 ]; - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'generic', clbk ); - - t.strictEqual( instanceOf( arr, Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - 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; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = [ 1.0, 2.0 ]; - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = [ 1.0, 2.0 ]; - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int32', clbk ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, typed array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, typed array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - 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; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = new Float64Array( [ 1.0, 2.0 ] ); - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = new Float64Array( [ 1.0, 2.0 ] ); - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (default, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - 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; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer, byteoffset; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer, byteoffset; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - 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; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 48 ); - out = filledarrayBy( buf, 16, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 24 ); - out = filledarrayBy( buf, 8, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int32', clbk ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint8c', clbk ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - 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; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 64 ); - out = filledarrayBy( buf, 16, 2, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset, length)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 1, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 1, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled array (default, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, iterator; thisArg)', opts, function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - ctx = { - 'count': 0 - }; - indices = []; - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, iterator; thisArg)', opts, function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - ctx = { - 'count': 0 - }; - indices = []; - out = filledarrayBy( arr, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - 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; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = iterConstant( new Complex128( 3.0, 3.0 ), { - 'iter': 2 - }); - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = iterConstant( new Complex64( 3.0, 3.0 ), { - 'iter': 2 - }); - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); From 9755fbb27545c1c1a3b041a195fef8d236936f88 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 3 Feb 2025 01:24:17 +0000 Subject: [PATCH 072/117] Transform error messages --- lib/main.js | 38 +++++++++++++++++++------------------- package.json | 2 +- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/lib/main.js b/lib/main.js index b322cfe..ed1aa9a 100644 --- a/lib/main.js +++ b/lib/main.js @@ -35,7 +35,7 @@ var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-supp var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); var iterLength = require( '@stdlib/iter-length' ); var defaults = require( '@stdlib/array-defaults' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -266,18 +266,18 @@ function filledarrayBy() { if ( isString( dtype ) ) { // Invoking this function with arguments `f( dtype, clbk[, thisArg] )` is not allowed (otherwise, we'd need to also allow `f( clbk[, thisArg] )`)... if ( nargs > 1 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format('00h05') ); } ctor = ctors( dtype ); if ( ctor === null ) { - throw new TypeError( format( 'invalid argument. Must provide a recognized data type. Value: `%s`.', dtype ) ); + throw new TypeError( format( '00h2Y', dtype ) ); } // Return an empty array having the specified dtype: return new ctor( 0 ); } // For all other supported invocations, we need at least two arguments... if ( nargs < 2 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format('00h05') ); } // At this point, we need to do some argument juggling... nargs -= 1; // henceforth, the number of available arguments is `nargs+1` @@ -292,7 +292,7 @@ function filledarrayBy() { // Check if we were provided only a callback and a "this" context.. if ( nargs === 0 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format('00h05') ); } } else { // "this" context is left undefined... @@ -305,12 +305,12 @@ function filledarrayBy() { nargs -= 1; clbk = arguments[ nargs ]; if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '00h2b', clbk ) ); } } // If were were only provided 2 arguments and the last argument was not a function, we've been provided an insufficient number of arguments... else { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format('00h05') ); } // Now that we've processed the callback arguments, let's continue working backward to see if we've been provided a `dtype` argument... nargs -= 1; @@ -322,7 +322,7 @@ function filledarrayBy() { } ctor = ctors( dtype ); if ( ctor === null ) { - throw new TypeError( format( 'invalid argument. Must provide a recognized data type. Value: `%s`.', dtype ) ); + throw new TypeError( format( '00h2Y', dtype ) ); } // At this point, we've resolved the output array data type, and now we can actually create the output array... if ( dtype === 'generic' ) { @@ -337,26 +337,26 @@ function filledarrayBy() { return filledArray( len, clbk, thisArg ); } if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format('00h04') ); } if ( isObject( arg ) ) { if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2Z', arg ) ); } if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } arg = arg[ ITERATOR_SYMBOL ](); if ( !isFunction( arg.next ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } return filledArrayIterator( arg, clbk, thisArg ); } - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } else if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format('00h04') ); } - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } if ( nargs === 0 ) { // length || array-like || ArrayBuffer || iterable arg = arguments[ 0 ]; @@ -368,18 +368,18 @@ function filledarrayBy() { arr = new ctor( arg ); } else if ( isObject( arg ) ) { if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2Z', arg ) ); } if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } arg = arg[ ITERATOR_SYMBOL ](); if ( !isFunction( arg.next ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } arr = new ctor( iterLength( arg ) ); } else { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } } else if ( nargs === 1 ) { arr = new ctor( arguments[0], arguments[1] ); // (ArrayBuffer, byteOffset) diff --git a/package.json b/package.json index 42e92b1..b5ac3ab 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "@stdlib/assert-is-string": "^0.2.2", "@stdlib/blas-ext-base-gfill-by": "^0.2.1", "@stdlib/iter-length": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/symbol-iterator": "^0.2.2", "@stdlib/types": "^0.4.3", "@stdlib/error-tools-fmtprodmsg": "^0.2.2" From a9365c93ea30dbbf6750a02bfa3a1ab8a94e8d00 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 3 Feb 2025 01:52:17 +0000 Subject: [PATCH 073/117] Remove files --- index.d.ts | 322 ---- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5169 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index cb63cd1..0000000 --- a/index.d.ts +++ /dev/null @@ -1,322 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, RealOrComplexTypedArray, BooleanArray, DataType } from '@stdlib/types/array'; -import { IterableIterator } from '@stdlib/types/iter'; - -/** -* Array or typed array. -*/ -type ArrayOrTypedArray = Array | RealOrComplexTypedArray | BooleanArray; - -/** -* Nullary callback function. -* -* @returns fill value -*/ -type Nullary = () => any; - -/** -* Unary callback function. -* -* @param i - current array index -* @returns fill value -*/ -type Unary = ( i: number ) => any; - -/** -* Callback function. -* -* @param i - current array index -* @returns fill value -*/ -type Callback = Nullary | Unary; - -/** -* Creates a filled array according to a provided callback function and having a specified data type. -* -* @param dtype - data type -* @returns filled array -* -* @example -* var arr = filledarrayBy(); -* // returns -* -* @example -* var arr = filledarrayBy( 'float32' ); -* // returns -*/ -declare function filledarrayBy( dtype?: DataType ): ArrayOrTypedArray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Creates a filled array according to a provided callback function and having a specified `length`. -* -* @param length - array length -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* -* var arr = filledarrayBy( 5, constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( length: number, clbk: Callback, thisArg?: any ): ArrayOrTypedArray; - -/** -* Creates a filled array according to a provided callback function and having a specified `length`. -* -* @param length - array length -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* -* var arr = filledarrayBy( 5, 'float64', constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( length: number, dtype: DataType, clbk: Callback, thisArg?: any ): ArrayOrTypedArray; - -/** -* Creates a filled array from another `array` according to a provided callback function. -* -* @param array - typed array or array-like object -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* -* 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; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Creates a filled array from another `array` according to a provided callback function. -* -* @param array - typed array or array-like object -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* -* 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; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Creates a filled array from an iterable according to a callback function. -* -* @param iterable - iterable -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var iterConstant = require( '@stdlib/iter-constant' ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarrayBy( it, constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( iterable: IterableIterator, clbk: Callback, thisArg?: any ): ArrayOrTypedArray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Creates a filled array from an iterable according to a callback function. -* -* @param iterable - iterable -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var iterConstant = require( '@stdlib/iter-constant' ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarrayBy( it, 'float64', constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( iterable: IterableIterator, dtype: DataType, clbk: 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. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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 | BooleanArray; - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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 | BooleanArray; - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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 | BooleanArray; - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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 | BooleanArray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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 | BooleanArray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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 | BooleanArray; // eslint-disable-line @typescript-eslint/unified-signatures - - -// EXPORTS // - -export = filledarrayBy; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 1c99feb..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@v0.0.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-ctors@v0.3.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill-by@v0.2.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled-by@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@v0.2.2-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.3.0-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";var v=f(),g=j.get("dtypes.default");function c(){var f,j,c,b,y,x,u,E;if(0===(j=arguments.length))return new(y=d(g))(0);if(r(c=arguments[0])){if(j>1)throw new TypeError(w("00h05"));if(null===(y=d(c)))throw new TypeError(w("00h2Y",c));return new y(0)}if(j<2)throw new TypeError(w("00h05"));if(h(arguments[j-=1]))if(h(arguments[j-1])){if(f=arguments[j],b=arguments[j-=1],0===j)throw new TypeError(w("00h05"))}else b=arguments[j];else{if(!(j>=2))throw new TypeError(w("00h05"));if(f=arguments[j],!h(b=arguments[j-=1]))throw new TypeError(w("00h2b",b))}if((j-=1)>=0&&r(arguments[j])?(c=arguments[j],j-=1):c=g,null===(y=d(c)))throw new TypeError(w("00h2Y",c));if("generic"===c){if(E=arguments[0],0===j){if(e(E)?u=E:i(E)&&(u=E.length),void 0!==u)return m(u,b,f);if(n(E))throw new Error(w("00h04"));if(o(E)){if(!1===v)throw new TypeError(w("00h2Z",E));if(!h(E[p]))throw new TypeError(w("00h2a",E));if(E=E[p](),!h(E.next))throw new TypeError(w("00h2a",E));return function(r,e,t){var s,i;for(s=[],i=-1;!r.next().done;)i+=1,s.push(e.call(t,i));return s}(E,b,f)}throw new TypeError(w("00h2a",E))}if(n(E))throw new Error(w("00h04"));throw new TypeError(w("00h2a",E))}if(0===j)if(i(E=arguments[0]))x=new y(E.length);else if(n(E))x=new y(E);else if(e(E))x=new y(E);else{if(!o(E))throw new TypeError(w("00h2a",E));if(!1===v)throw new TypeError(w("00h2Z",E));if(!h(E[p]))throw new TypeError(w("00h2a",E));if(E=E[p](),!h(E.next))throw new TypeError(w("00h2a",E));x=new y(a(E))}else x=1===j?new y(arguments[0],arguments[1]):new y(arguments[0],arguments[1],arguments[2]);return x.length>0&&(t(c)||s(c)?function(r,e,t){var s;for(s=0;s\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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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( format('00h05') );\n\t\t}\n\t\tctor = ctors( dtype );\n\t\tif ( ctor === null ) {\n\t\t\tthrow new TypeError( format( '00h2Y', 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( format('00h05') );\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( format('00h05') );\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( '00h2b', 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( format('00h05') );\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( '00h2Y', 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( format('00h04') );\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( '00h2Z', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00h2a', 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( '00h2a', 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( '00h2a', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format('00h04') );\n\t\t}\n\t\tthrow new TypeError( format( '00h2a', 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( '00h2Z', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00h2a', 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( '00h2a', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00h2a', 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\nexport default filledarrayBy;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","DEFAULT_DTYPE","defaults","get","filledarrayBy","thisArg","nargs","dtype","clbk","ctor","arr","len","arg","arguments","length","ctors","isString","TypeError","format","isFunction","isNonNegativeInteger","isCollection","filledArray","isArrayBuffer","Error","isObject","ITERATOR_SYMBOL","next","it","i","done","push","call","filledArrayIterator","iterLength","isComplexDataType","isBooleanDataType","set","filledAccessors","gfillBy","value","aidx"],"mappings":";;sjDA0CA,IAAIA,EAAsBC,IACtBC,EAAgBC,EAASC,IAAK,kBA2MlC,SAASC,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAKJ,GAAe,KAHfN,EAAQO,UAAUC,QAKjB,OAAO,IADPL,EAAOM,EAAOd,IACG,GAIlB,GAAKe,EADLT,EAAQM,UAAW,IACM,CAExB,GAAKP,EAAQ,EACZ,MAAM,IAAIW,UAAWC,EAAO,UAG7B,GAAc,QADdT,EAAOM,EAAOR,IAEb,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,OAAO,IAAIE,EAAM,EACjB,CAED,GAAKH,EAAQ,EACZ,MAAM,IAAIW,UAAWC,EAAO,UAM7B,GAAKC,EAAYN,UAHjBP,GAAS,IAKR,GAAKa,EAAYN,UAAWP,EAAM,KAMjC,GALAD,EAAUQ,UAAWP,GAErBE,EAAOK,UADPP,GAAS,GAIM,IAAVA,EACJ,MAAM,IAAIW,UAAWC,EAAO,eAI7BV,EAAOK,UAAWP,OAIf,MAAKA,GAAS,GAUlB,MAAM,IAAIW,UAAWC,EAAO,UAN5B,GAHAb,EAAUQ,UAAWP,IAGfa,EADNX,EAAOK,UADPP,GAAS,IAGR,MAAM,IAAIW,UAAWC,EAAQ,QAASV,GAMvC,CAUD,IARAF,GAAS,IACK,GAAKU,EAAUH,UAAWP,KACvCC,EAAQM,UAAWP,GACnBA,GAAS,GAETC,EAAQN,EAGK,QADdQ,EAAOM,EAAOR,IAEb,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,GAAe,YAAVA,EAAsB,CAE1B,GADAK,EAAMC,UAAW,GACF,IAAVP,EAAc,CAMlB,GALKc,EAAsBR,GAC1BD,EAAMC,EACKS,EAAcT,KACzBD,EAAMC,EAAIE,aAEE,IAARH,EACJ,OAAOW,EAAaX,EAAKH,EAAMH,GAEhC,GAAKkB,EAAeX,GACnB,MAAM,IAAIY,MAAON,EAAO,UAEzB,GAAKO,EAAUb,GAAQ,CACtB,IAA6B,IAAxBb,EACJ,MAAM,IAAIkB,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAYP,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLP,EAAYP,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvC,OAvSJ,SAA8BgB,EAAIpB,EAAMH,GACvC,IAAIK,EACAmB,EAKJ,IAFAnB,EAAM,GACNmB,GAAK,GAEAD,EAAGD,OACAG,MAGPD,GAAK,EACLnB,EAAIqB,KAAMvB,EAAKwB,KAAM3B,EAASwB,IAE/B,OAAOnB,CACR,CAuRWuB,CAAqBrB,EAAKJ,EAAMH,EACvC,CACD,MAAM,IAAIY,UAAWC,EAAQ,QAASN,GACzC,CAAS,GAAKW,EAAeX,GAC1B,MAAM,IAAIY,MAAON,EAAO,UAEzB,MAAM,IAAID,UAAWC,EAAQ,QAASN,GACtC,CACD,GAAe,IAAVN,EAEJ,GAAKe,EADLT,EAAMC,UAAW,IAEhBH,EAAM,IAAID,EAAMG,EAAIE,aACd,GAAKS,EAAeX,GAC1BF,EAAM,IAAID,EAAMG,QACV,GAAKQ,EAAsBR,GACjCF,EAAM,IAAID,EAAMG,OACV,KAAKa,EAAUb,GAarB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAZtC,IAA6B,IAAxBb,EACJ,MAAM,IAAIkB,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAYP,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLP,EAAYP,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvCF,EAAM,IAAID,EAAMyB,EAAYtB,GAG5B,MAEDF,EADqB,IAAVJ,EACL,IAAIG,EAAMI,UAAU,GAAIA,UAAU,IAElC,IAAIJ,EAAMI,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKH,EAAII,OAAS,IACZqB,EAAmB5B,IAAW6B,EAAmB7B,GAjTxD,SAA0BG,EAAKF,EAAMH,GACpC,IAAIwB,EACJ,IAAMA,EAAI,EAAGA,EAAInB,EAAII,OAAQe,IAC5BnB,EAAI2B,IAAK7B,EAAKwB,KAAM3B,EAASwB,GAAKA,EAGpC,CA4SGS,CAAiB5B,EAAKF,EAAMH,GAE5BkC,EAAS7B,EAAII,OAAQJ,EAAK,GAe5B,SAAmB8B,EAAOC,GACzB,OAAOjC,EAAKwB,KAAM3B,EAASoC,EAC3B,KAdM/B,CAeR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index e4cee9c..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From e8b1a04c0d7f04d5e1469aaebdc107f61866ac59 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 3 Feb 2025 01:52:38 +0000 Subject: [PATCH 074/117] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 191 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 49 +- SECURITY.md | 5 - benchmark/benchmark.js | 341 -- benchmark/benchmark.length.bool.js | 97 - benchmark/benchmark.length.complex128.js | 98 - benchmark/benchmark.length.complex64.js | 98 - benchmark/benchmark.length.float32.js | 97 - benchmark/benchmark.length.float64.js | 97 - benchmark/benchmark.length.generic.js | 97 - benchmark/benchmark.length.int16.js | 97 - benchmark/benchmark.length.int32.js | 97 - benchmark/benchmark.length.int8.js | 97 - benchmark/benchmark.length.uint16.js | 97 - benchmark/benchmark.length.uint32.js | 97 - benchmark/benchmark.length.uint8.js | 97 - benchmark/benchmark.length.uint8c.js | 97 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 36 - dist/index.js.map | 7 - docs/repl.txt | 157 - docs/types/test.ts | 606 --- examples/index.js | 37 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 192 - lib/main.js | 416 -- package.json | 96 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 4397 ---------------- 57 files changed, 4870 insertions(+), 11144 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.length.bool.js delete mode 100644 benchmark/benchmark.length.complex128.js delete mode 100644 benchmark/benchmark.length.complex64.js delete mode 100644 benchmark/benchmark.length.float32.js delete mode 100644 benchmark/benchmark.length.float64.js delete mode 100644 benchmark/benchmark.length.generic.js delete mode 100644 benchmark/benchmark.length.int16.js delete mode 100644 benchmark/benchmark.length.int32.js delete mode 100644 benchmark/benchmark.length.int8.js delete mode 100644 benchmark/benchmark.length.uint16.js delete mode 100644 benchmark/benchmark.length.uint32.js delete mode 100644 benchmark/benchmark.length.uint8.js delete mode 100644 benchmark/benchmark.length.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 821a0bf..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-02-03T01:10:27.747Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 8be0b82..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index f988046..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index b2c1f9c..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '42 6 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -278,7 +269,7 @@ for ( i = 0; i < dt.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -347,13 +338,13 @@ Copyright © 2016-2025. 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/dtypes]: https://github.com/stdlib-js/array-dtypes/tree/esm -[@stdlib/array/filled]: https://github.com/stdlib-js/array-filled +[@stdlib/array/filled]: https://github.com/stdlib-js/array-filled/tree/esm -[@stdlib/array/typed]: https://github.com/stdlib-js/array-typed +[@stdlib/array/typed]: https://github.com/stdlib-js/array-typed/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 17cfb5a..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,341 +0,0 @@ -/** -* @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 isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); -var isArray = require( '@stdlib/assert-is-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var Complex64 = require( '@stdlib/complex-float32-ctor' ); -var Complex128 = require( '@stdlib/complex-float64-ctor' ); -var pkg = require( './../package.json' ).name; -var filledarrayBy = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 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=float64', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'float64', 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=float32', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'float32', 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=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; - var i; - - clbk = constantFunction( new Complex128( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'complex128', 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=complex64', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( new Complex64( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'complex64', 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=int32', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int32', 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=uint32', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint32', 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=int16', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int16', 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=uint16', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint16', 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=int8', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int8', 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=uint8', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint8', 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=uint8c', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint8c', 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=generic', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'generic', clbk ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.length.bool.js b/benchmark/benchmark.length.bool.js deleted file mode 100644 index 3cdd152..0000000 --- a/benchmark/benchmark.length.bool.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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/benchmark/benchmark.length.complex128.js b/benchmark/benchmark.length.complex128.js deleted file mode 100644 index 122bc7c..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 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 Complex128 = require( '@stdlib/complex-float64-ctor' ); -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( new Complex128( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'complex128', 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=complex128,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.complex64.js b/benchmark/benchmark.length.complex64.js deleted file mode 100644 index e7a2d74..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 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 Complex64 = require( '@stdlib/complex-float32-ctor' ); -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( new Complex64( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'complex64', 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=complex64,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.float32.js b/benchmark/benchmark.length.float32.js deleted file mode 100644 index d2b2ba7..0000000 --- a/benchmark/benchmark.length.float32.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'float32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=float32,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.float64.js b/benchmark/benchmark.length.float64.js deleted file mode 100644 index 65064e3..0000000 --- a/benchmark/benchmark.length.float64.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'float64', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=float64,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.generic.js b/benchmark/benchmark.length.generic.js deleted file mode 100644 index eb87dfa..0000000 --- a/benchmark/benchmark.length.generic.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isArray = require( '@stdlib/assert-is-array' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'generic', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isArray( 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=generic,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int16.js b/benchmark/benchmark.length.int16.js deleted file mode 100644 index 914ff7c..0000000 --- a/benchmark/benchmark.length.int16.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int16', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=int16,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int32.js b/benchmark/benchmark.length.int32.js deleted file mode 100644 index cc0f678..0000000 --- a/benchmark/benchmark.length.int32.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=int32,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int8.js b/benchmark/benchmark.length.int8.js deleted file mode 100644 index 77553b0..0000000 --- a/benchmark/benchmark.length.int8.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int8', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=int8,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint16.js b/benchmark/benchmark.length.uint16.js deleted file mode 100644 index c68efdd..0000000 --- a/benchmark/benchmark.length.uint16.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint16', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint16,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint32.js b/benchmark/benchmark.length.uint32.js deleted file mode 100644 index 27c1742..0000000 --- a/benchmark/benchmark.length.uint32.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint32,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint8.js b/benchmark/benchmark.length.uint8.js deleted file mode 100644 index 2a26be4..0000000 --- a/benchmark/benchmark.length.uint8.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint8', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint8,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint8c.js b/benchmark/benchmark.length.uint8c.js deleted file mode 100644 index dd6e8c2..0000000 --- a/benchmark/benchmark.length.uint8c.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint8c', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint8c,len='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index c138144..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by" -%% click B href "https://github.com/stdlib-js/array-filled-by/tree/main" -%% click C href "https://github.com/stdlib-js/array-filled-by/tree/production" -%% click D href "https://github.com/stdlib-js/array-filled-by/tree/esm" -%% click E href "https://github.com/stdlib-js/array-filled-by/tree/deno" -%% click F href "https://github.com/stdlib-js/array-filled-by/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by -[production-url]: https://github.com/stdlib-js/array-filled-by/tree/production -[deno-url]: https://github.com/stdlib-js/array-filled-by/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-filled-by/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-filled-by/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-filled-by/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-filled-by/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-filled-by/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 188fc9b..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import filledarrayBy from '../docs/types/index'; -export = filledarrayBy; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 65ae3db..0000000 --- a/dist/index.js +++ /dev/null @@ -1,36 +0,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 deleted file mode 100644 index e88f9aa..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "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,YACjDC,EAAuB,QAAS,uCAAwC,EAAE,YAC1EC,EAAoB,QAAS,+DAAgE,EAC7FC,EAAoB,QAAS,gDAAiD,EAC9EC,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,EAAQ,UAAU,OAGbA,IAAU,EACd,OAAAE,EAAOrB,EAAOS,CAAc,EACrB,IAAIY,EAAM,CAAE,EAIpB,GADAD,EAAQ,UAAW,CAAE,EAChB5B,EAAU4B,CAAM,EAAI,CAExB,GAAKD,EAAQ,EACZ,MAAM,IAAI,UAAW,2FAA4F,EAGlH,GADAE,EAAOrB,EAAOoB,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWd,EAAQ,sEAAuEa,CAAM,CAAE,EAG7G,OAAO,IAAIC,EAAM,CAAE,CACpB,CAEA,GAAKF,EAAQ,EACZ,MAAM,IAAI,UAAW,2FAA4F,EAMlH,GAHAA,GAAS,EAGJpB,EAAY,UAAWoB,CAAM,CAAE,EAEnC,GAAKpB,EAAY,UAAWoB,EAAM,CAAE,CAAE,GAMrC,GALAN,EAAU,UAAWM,CAAM,EAC3BA,GAAS,EACTP,EAAO,UAAWO,CAAM,EAGnBA,IAAU,EACd,MAAM,IAAI,UAAW,2FAA4F,OAIlHP,EAAO,UAAWO,CAAM,UAIhBA,GAAS,GAIlB,GAHAN,EAAU,UAAWM,CAAM,EAC3BA,GAAS,EACTP,EAAO,UAAWO,CAAM,EACnB,CAACpB,EAAYa,CAAK,EACtB,MAAM,IAAI,UAAWL,EAAQ,uEAAwEK,CAAK,CAAE,MAK7G,OAAM,IAAI,UAAW,2FAA4F,EAWlH,GARAO,GAAS,EACJA,GAAS,GAAK3B,EAAU,UAAW2B,CAAM,CAAE,GAC/CC,EAAQ,UAAWD,CAAM,EACzBA,GAAS,GAETC,EAAQX,EAETY,EAAOrB,EAAOoB,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWd,EAAQ,sEAAuEa,CAAM,CAAE,EAG7G,GAAKA,IAAU,UAAY,CAE1B,GADAG,EAAM,UAAW,CAAE,EACdJ,IAAU,EAAI,CAMlB,GALK1B,EAAsB8B,CAAI,EAC9BD,EAAMC,EACK3B,EAAc2B,CAAI,IAC7BD,EAAMC,EAAI,QAEND,IAAQ,OACZ,OAAOpB,EAAaoB,EAAKV,EAAMC,CAAQ,EAExC,GAAKhB,EAAe0B,CAAI,EACvB,MAAM,IAAI,MAAO,mFAAoF,EAEtG,GAAKzB,EAAUyB,CAAI,EAAI,CACtB,GAAKf,IAAwB,GAC5B,MAAM,IAAI,UAAWD,EAAQ,sIAAuIgB,CAAI,CAAE,EAE3K,GAAK,CAACxB,EAAYwB,EAAKnB,CAAgB,CAAE,EACxC,MAAM,IAAI,UAAWG,EAAQ,wGAAyGgB,CAAI,CAAE,EAG7I,GADAA,EAAMA,EAAKnB,CAAgB,EAAE,EACxB,CAACL,EAAYwB,EAAI,IAAK,EAC1B,MAAM,IAAI,UAAWhB,EAAQ,wGAAyGgB,CAAI,CAAE,EAE7I,OAAOb,EAAqBa,EAAKX,EAAMC,CAAQ,CAChD,CACA,MAAM,IAAI,UAAWN,EAAQ,wGAAyGgB,CAAI,CAAE,CAC7I,SAAY1B,EAAe0B,CAAI,EAC9B,MAAM,IAAI,MAAO,mFAAoF,EAEtG,MAAM,IAAI,UAAWhB,EAAQ,wGAAyGgB,CAAI,CAAE,CAC7I,CACA,GAAKJ,IAAU,EAEd,GADAI,EAAM,UAAW,CAAE,EACd3B,EAAc2B,CAAI,EACtBT,EAAM,IAAIO,EAAME,EAAI,MAAO,UAChB1B,EAAe0B,CAAI,EAC9BT,EAAM,IAAIO,EAAME,CAAI,UACT9B,EAAsB8B,CAAI,EACrCT,EAAM,IAAIO,EAAME,CAAI,UACTzB,EAAUyB,CAAI,EAAI,CAC7B,GAAKf,IAAwB,GAC5B,MAAM,IAAI,UAAWD,EAAQ,sIAAuIgB,CAAI,CAAE,EAE3K,GAAK,CAACxB,EAAYwB,EAAKnB,CAAgB,CAAE,EACxC,MAAM,IAAI,UAAWG,EAAQ,wGAAyGgB,CAAI,CAAE,EAG7I,GADAA,EAAMA,EAAKnB,CAAgB,EAAE,EACxB,CAACL,EAAYwB,EAAI,IAAK,EAC1B,MAAM,IAAI,UAAWhB,EAAQ,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,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 deleted file mode 100644 index 06f3146..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,157 +0,0 @@ - -{{alias}}( [dtype] ) - Creates a filled array. - - Parameters - ---------- - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr = {{alias}}() - - > arr = {{alias}}( 'float32' ) - - - -{{alias}}( length[, dtype], clbk[, thisArg] ) - Returns a filled array according to a provided callback function and having - a specified length. - - Parameters - ---------- - length: integer - Array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > function clbk() { return 1.0; }; - > var arr = {{alias}}( 5, clbk ) - [ 1.0, 1.0, 1.0, 1.0, 1.0 ] - > arr = {{alias}}( 5, 'int32', clbk ) - [ 1, 1, 1, 1, 1 ] - - -{{alias}}( array[, dtype], clbk[, thisArg] ) - Creates a filled array from another array (or array-like object) according - to a provided callback function. - - Parameters - ---------- - array: ArrayLikeObject - Array from which to generate another array. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias}}( [ 0.5, 0.5, 0.5 ], {{alias:@stdlib/utils/constant-function}}( 2.0 ) ) - [ 2.0, 2.0, 2.0 ] - > var arr2 = {{alias}}( arr1, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( iterable[, dtype], clbk[, thisArg] ) - Creates a filled array from an iterable according to a provided callback - function. - - Parameters - ---------- - iterable: Iterable - Iterable from which to generate an array. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias:@stdlib/iter/constant}}( 3.0, {'iter': 3} ); - > var arr2 = {{alias}}( arr1, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( buffer[, byteOffset[, length]][, dtype], clbk[, thisArg] ) - Returns a filled typed array view of an ArrayBuffer according to a provided - callback function. - - The 'generic' array data type is *not* supported. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( buf, 0, 4, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0, 1.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index bb876ed..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,606 +0,0 @@ -/* -* @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. -*/ - -/// - -import { IterableIterator } from '@stdlib/types/iter'; -import filledarrayBy = require( './index' ); - - -/** -* Returns an iterator protocol-compliant object. -* -* @returns iterator protocol-compliant object -*/ -function iterator(): IterableIterator { - const obj: IterableIterator = { - [Symbol.iterator]: iterator, - 'next': next - }; - return obj; -} - -/** -* Implements the iterator protocol `next` method. -* -* @returns iterator protocol-compliant object -*/ -function next(): any { - return { - 'value': 1.0, - 'done': false - }; -} - -/** -* Callback function. -* -* @param i - current array index -* @returns return value -*/ -function clbk( i: number ): number { - return i; -} - - -// TESTS // - -// The function returns an array or typed array... -{ - filledarrayBy(); // $ExpectType ArrayOrTypedArray - filledarrayBy( 'float32' ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( 10, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( 10, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( 10, 'int32', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( 10, 'int32', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const x = new Float64Array( 10 ); - filledarrayBy( x, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( x, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( x, 'uint8', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( x, 'uint8', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const y = [ 2.0, 2.0, 2.0 ]; - filledarrayBy( y, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( y, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( y, 'float64', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( y, 'float64', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const it = iterator(); - filledarrayBy( it, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( it, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( it, 'uint8c', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( it, 'uint8c', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const buf = new ArrayBuffer( 32 ); - filledarrayBy( buf, clbk ); // $ExpectType RealOrComplexTypedArray | BooleanArray - filledarrayBy( buf, clbk, {} ); // $ExpectType RealOrComplexTypedArray | BooleanArray - - filledarrayBy( buf, 'uint32', clbk ); // $ExpectType RealOrComplexTypedArray | BooleanArray - filledarrayBy( buf, 'uint32', clbk, {} ); // $ExpectType RealOrComplexTypedArray | BooleanArray - - filledarrayBy( buf, 8, clbk ); // $ExpectType RealOrComplexTypedArray | BooleanArray - filledarrayBy( buf, 8, clbk, {} ); // $ExpectType RealOrComplexTypedArray | BooleanArray - - filledarrayBy( buf, 8, 'uint16', clbk ); // $ExpectType RealOrComplexTypedArray | BooleanArray - filledarrayBy( buf, 8, 'uint16', clbk, {} ); // $ExpectType RealOrComplexTypedArray | BooleanArray - - filledarrayBy( buf, 8, 2, clbk ); // $ExpectType RealOrComplexTypedArray | BooleanArray - filledarrayBy( buf, 8, 2, clbk, {} ); // $ExpectType RealOrComplexTypedArray | BooleanArray - - filledarrayBy( buf, 8, 2, 'int16', clbk ); // $ExpectType RealOrComplexTypedArray | BooleanArray - filledarrayBy( buf, 8, 2, 'int16', clbk, {} ); // $ExpectType RealOrComplexTypedArray | BooleanArray -} - -// The compiler throws an error if a callback function argument is not a function... -{ - filledarrayBy( 'float64', '5' ); // $ExpectError - filledarrayBy( 'float64', 1.0 ); // $ExpectError - filledarrayBy( 'float64', false ); // $ExpectError - filledarrayBy( 'float64', true ); // $ExpectError - filledarrayBy( 'float64', null ); // $ExpectError - filledarrayBy( 'float64', undefined ); // $ExpectError - filledarrayBy( 'float64', [] ); // $ExpectError - filledarrayBy( 'float64', {} ); // $ExpectError - - filledarrayBy( 'float64', '5', {} ); // $ExpectError - filledarrayBy( 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( 'float64', false, {} ); // $ExpectError - filledarrayBy( 'float64', true, {} ); // $ExpectError - filledarrayBy( 'float64', null, {} ); // $ExpectError - filledarrayBy( 'float64', undefined, {} ); // $ExpectError - filledarrayBy( 'float64', [], {} ); // $ExpectError - filledarrayBy( 'float64', {}, {} ); // $ExpectError - - filledarrayBy( 10, '5' ); // $ExpectError - filledarrayBy( 10, 1.0 ); // $ExpectError - filledarrayBy( 10, false ); // $ExpectError - filledarrayBy( 10, true ); // $ExpectError - filledarrayBy( 10, null ); // $ExpectError - filledarrayBy( 10, undefined ); // $ExpectError - filledarrayBy( 10, [] ); // $ExpectError - filledarrayBy( 10, {} ); // $ExpectError - - filledarrayBy( 10, '5', {} ); // $ExpectError - filledarrayBy( 10, 1.0, {} ); // $ExpectError - filledarrayBy( 10, false, {} ); // $ExpectError - filledarrayBy( 10, true, {} ); // $ExpectError - filledarrayBy( 10, null, {} ); // $ExpectError - filledarrayBy( 10, undefined, {} ); // $ExpectError - filledarrayBy( 10, [], {} ); // $ExpectError - filledarrayBy( 10, {}, {} ); // $ExpectError - - filledarrayBy( 10, 'float64', '5' ); // $ExpectError - filledarrayBy( 10, 'float64', 1.0 ); // $ExpectError - filledarrayBy( 10, 'float64', false ); // $ExpectError - filledarrayBy( 10, 'float64', true ); // $ExpectError - filledarrayBy( 10, 'float64', null ); // $ExpectError - filledarrayBy( 10, 'float64', undefined ); // $ExpectError - filledarrayBy( 10, 'float64', [] ); // $ExpectError - filledarrayBy( 10, 'float64', {} ); // $ExpectError - - filledarrayBy( 10, 'float64', '5', {} ); // $ExpectError - filledarrayBy( 10, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( 10, 'float64', false, {} ); // $ExpectError - filledarrayBy( 10, 'float64', true, {} ); // $ExpectError - filledarrayBy( 10, 'float64', null, {} ); // $ExpectError - filledarrayBy( 10, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( 10, 'float64', [], {} ); // $ExpectError - filledarrayBy( 10, 'float64', {}, {} ); // $ExpectError - - const x = new Float64Array( 10 ); - filledarrayBy( x, '5' ); // $ExpectError - filledarrayBy( x, 1.0 ); // $ExpectError - filledarrayBy( x, false ); // $ExpectError - filledarrayBy( x, true ); // $ExpectError - filledarrayBy( x, null ); // $ExpectError - filledarrayBy( x, undefined ); // $ExpectError - filledarrayBy( x, [] ); // $ExpectError - filledarrayBy( x, {} ); // $ExpectError - - filledarrayBy( x, '5', {} ); // $ExpectError - filledarrayBy( x, 1.0, {} ); // $ExpectError - filledarrayBy( x, false, {} ); // $ExpectError - filledarrayBy( x, true, {} ); // $ExpectError - filledarrayBy( x, null, {} ); // $ExpectError - filledarrayBy( x, undefined, {} ); // $ExpectError - filledarrayBy( x, [], {} ); // $ExpectError - filledarrayBy( x, {}, {} ); // $ExpectError - - filledarrayBy( x, 'float64', '5' ); // $ExpectError - filledarrayBy( x, 'float64', 1.0 ); // $ExpectError - filledarrayBy( x, 'float64', false ); // $ExpectError - filledarrayBy( x, 'float64', true ); // $ExpectError - filledarrayBy( x, 'float64', null ); // $ExpectError - filledarrayBy( x, 'float64', undefined ); // $ExpectError - filledarrayBy( x, 'float64', [] ); // $ExpectError - filledarrayBy( x, 'float64', {} ); // $ExpectError - - filledarrayBy( x, 'float64', '5', {} ); // $ExpectError - filledarrayBy( x, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( x, 'float64', false, {} ); // $ExpectError - filledarrayBy( x, 'float64', true, {} ); // $ExpectError - filledarrayBy( x, 'float64', null, {} ); // $ExpectError - filledarrayBy( x, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( x, 'float64', [], {} ); // $ExpectError - filledarrayBy( x, 'float64', {}, {} ); // $ExpectError - - const y = [ 2.0, 2.0, 2.0 ]; - filledarrayBy( y, '5' ); // $ExpectError - filledarrayBy( y, 1.0 ); // $ExpectError - filledarrayBy( y, false ); // $ExpectError - filledarrayBy( y, true ); // $ExpectError - filledarrayBy( y, null ); // $ExpectError - filledarrayBy( y, undefined ); // $ExpectError - filledarrayBy( y, [] ); // $ExpectError - filledarrayBy( y, {} ); // $ExpectError - - filledarrayBy( y, '5', {} ); // $ExpectError - filledarrayBy( y, 1.0, {} ); // $ExpectError - filledarrayBy( y, false, {} ); // $ExpectError - filledarrayBy( y, true, {} ); // $ExpectError - filledarrayBy( y, null, {} ); // $ExpectError - filledarrayBy( y, undefined, {} ); // $ExpectError - filledarrayBy( y, [], {} ); // $ExpectError - filledarrayBy( y, {}, {} ); // $ExpectError - - filledarrayBy( y, 'float64', '5' ); // $ExpectError - filledarrayBy( y, 'float64', 1.0 ); // $ExpectError - filledarrayBy( y, 'float64', false ); // $ExpectError - filledarrayBy( y, 'float64', true ); // $ExpectError - filledarrayBy( y, 'float64', null ); // $ExpectError - filledarrayBy( y, 'float64', undefined ); // $ExpectError - filledarrayBy( y, 'float64', [] ); // $ExpectError - filledarrayBy( y, 'float64', {} ); // $ExpectError - - filledarrayBy( y, 'float64', '5', {} ); // $ExpectError - filledarrayBy( y, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( y, 'float64', false, {} ); // $ExpectError - filledarrayBy( y, 'float64', true, {} ); // $ExpectError - filledarrayBy( y, 'float64', null, {} ); // $ExpectError - filledarrayBy( y, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( y, 'float64', [], {} ); // $ExpectError - filledarrayBy( y, 'float64', {}, {} ); // $ExpectError - - const it = iterator(); - filledarrayBy( it, '5' ); // $ExpectError - filledarrayBy( it, 1.0 ); // $ExpectError - filledarrayBy( it, false ); // $ExpectError - filledarrayBy( it, true ); // $ExpectError - filledarrayBy( it, null ); // $ExpectError - filledarrayBy( it, undefined ); // $ExpectError - filledarrayBy( it, [] ); // $ExpectError - filledarrayBy( it, {} ); // $ExpectError - - filledarrayBy( it, '5', {} ); // $ExpectError - filledarrayBy( it, 1.0, {} ); // $ExpectError - filledarrayBy( it, false, {} ); // $ExpectError - filledarrayBy( it, true, {} ); // $ExpectError - filledarrayBy( it, null, {} ); // $ExpectError - filledarrayBy( it, undefined, {} ); // $ExpectError - filledarrayBy( it, [], {} ); // $ExpectError - filledarrayBy( it, {}, {} ); // $ExpectError - - filledarrayBy( it, 'float64', '5' ); // $ExpectError - filledarrayBy( it, 'float64', 1.0 ); // $ExpectError - filledarrayBy( it, 'float64', false ); // $ExpectError - filledarrayBy( it, 'float64', true ); // $ExpectError - filledarrayBy( it, 'float64', null ); // $ExpectError - filledarrayBy( it, 'float64', undefined ); // $ExpectError - filledarrayBy( it, 'float64', [] ); // $ExpectError - filledarrayBy( it, 'float64', {} ); // $ExpectError - - filledarrayBy( it, 'float64', '5', {} ); // $ExpectError - filledarrayBy( it, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( it, 'float64', false, {} ); // $ExpectError - filledarrayBy( it, 'float64', true, {} ); // $ExpectError - filledarrayBy( it, 'float64', null, {} ); // $ExpectError - filledarrayBy( it, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( it, 'float64', [], {} ); // $ExpectError - filledarrayBy( it, 'float64', {}, {} ); // $ExpectError - - const buf = new ArrayBuffer( 32 ); - filledarrayBy( buf, '5' ); // $ExpectError - filledarrayBy( buf, 1.0 ); // $ExpectError - filledarrayBy( buf, false ); // $ExpectError - filledarrayBy( buf, true ); // $ExpectError - filledarrayBy( buf, null ); // $ExpectError - filledarrayBy( buf, undefined ); // $ExpectError - filledarrayBy( buf, [] ); // $ExpectError - filledarrayBy( buf, {} ); // $ExpectError - - filledarrayBy( buf, '5', {} ); // $ExpectError - filledarrayBy( buf, 1.0, {} ); // $ExpectError - filledarrayBy( buf, false, {} ); // $ExpectError - filledarrayBy( buf, true, {} ); // $ExpectError - filledarrayBy( buf, null, {} ); // $ExpectError - filledarrayBy( buf, undefined, {} ); // $ExpectError - filledarrayBy( buf, [], {} ); // $ExpectError - filledarrayBy( buf, {}, {} ); // $ExpectError - - filledarrayBy( buf, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 'float64', false ); // $ExpectError - filledarrayBy( buf, 'float64', true ); // $ExpectError - filledarrayBy( buf, 'float64', null ); // $ExpectError - filledarrayBy( buf, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 'float64', {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5' ); // $ExpectError - filledarrayBy( buf, 8, 1.0 ); // $ExpectError - filledarrayBy( buf, 8, false ); // $ExpectError - filledarrayBy( buf, 8, true ); // $ExpectError - filledarrayBy( buf, 8, null ); // $ExpectError - filledarrayBy( buf, 8, undefined ); // $ExpectError - filledarrayBy( buf, 8, [] ); // $ExpectError - filledarrayBy( buf, 8, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, false, {} ); // $ExpectError - filledarrayBy( buf, 8, true, {} ); // $ExpectError - filledarrayBy( buf, 8, null, {} ); // $ExpectError - filledarrayBy( buf, 8, undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, [], {} ); // $ExpectError - filledarrayBy( buf, 8, {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 8, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 'float64', false ); // $ExpectError - filledarrayBy( buf, 8, 'float64', true ); // $ExpectError - filledarrayBy( buf, 8, 'float64', null ); // $ExpectError - filledarrayBy( buf, 8, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 8, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 8, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 8, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, '5' ); // $ExpectError - filledarrayBy( buf, 8, 2, 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 2, false ); // $ExpectError - filledarrayBy( buf, 8, 2, true ); // $ExpectError - filledarrayBy( buf, 8, 2, null ); // $ExpectError - filledarrayBy( buf, 8, 2, undefined ); // $ExpectError - filledarrayBy( buf, 8, 2, [] ); // $ExpectError - filledarrayBy( buf, 8, 2, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, false, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, true, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, null, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, [], {} ); // $ExpectError - filledarrayBy( buf, 8, 2, {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', false ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', true ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', null ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', {}, {} ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid length, typed array, array-like object, `ArrayBuffer`, or iterable argument... -{ - filledarrayBy( false, clbk ); // $ExpectError - filledarrayBy( true, clbk ); // $ExpectError - filledarrayBy( null, clbk ); // $ExpectError - filledarrayBy( {}, clbk ); // $ExpectError - - filledarrayBy( false, clbk, {} ); // $ExpectError - filledarrayBy( true, clbk, {} ); // $ExpectError - filledarrayBy( null, clbk, {} ); // $ExpectError - filledarrayBy( {}, clbk, {} ); // $ExpectError - - filledarrayBy( false, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 'float64', clbk ); // $ExpectError - - filledarrayBy( false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, clbk ); // $ExpectError - filledarrayBy( 1.0, 8, clbk ); // $ExpectError - filledarrayBy( false, 8, clbk ); // $ExpectError - filledarrayBy( true, 8, clbk ); // $ExpectError - filledarrayBy( null, 8, clbk ); // $ExpectError - filledarrayBy( undefined, 8, clbk ); // $ExpectError - filledarrayBy( [], 8, clbk ); // $ExpectError - filledarrayBy( {}, 8, clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, clbk ); // $ExpectError - - filledarrayBy( '5', 8, clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, clbk, {} ); // $ExpectError - filledarrayBy( false, 8, clbk, {} ); // $ExpectError - filledarrayBy( true, 8, clbk, {} ); // $ExpectError - filledarrayBy( null, 8, clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, clbk, {} ); // $ExpectError - filledarrayBy( [], 8, clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 'float64', clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( false, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( [], 8, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 'float64', clbk ); // $ExpectError - - filledarrayBy( '5', 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 2, clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 2, clbk ); // $ExpectError - filledarrayBy( false, 8, 2, clbk ); // $ExpectError - filledarrayBy( true, 8, 2, clbk ); // $ExpectError - filledarrayBy( null, 8, 2, clbk ); // $ExpectError - filledarrayBy( undefined, 8, 2, clbk ); // $ExpectError - filledarrayBy( [], 8, 2, clbk ); // $ExpectError - filledarrayBy( {}, 8, 2, clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, clbk ); // $ExpectError - - filledarrayBy( '5', 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( false, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( [], 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, 'float64', clbk ); // $ExpectError - - filledarrayBy( '5', 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a byte offset argument which is not a number... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, false, clbk ); // $ExpectError - filledarrayBy( buf, true, clbk ); // $ExpectError - filledarrayBy( buf, null, clbk ); // $ExpectError - filledarrayBy( buf, [], clbk ); // $ExpectError - filledarrayBy( buf, {}, clbk ); // $ExpectError - - filledarrayBy( buf, false, clbk, {} ); // $ExpectError - filledarrayBy( buf, true, clbk, {} ); // $ExpectError - filledarrayBy( buf, null, clbk, {} ); // $ExpectError - filledarrayBy( buf, [], clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, clbk, {} ); // $ExpectError - - filledarrayBy( buf, '5', 'float64', clbk ); // $ExpectError - filledarrayBy( buf, false, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, true, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, null, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, [], 'float64', clbk ); // $ExpectError - filledarrayBy( buf, {}, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, '5', 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( buf, false, 2, clbk ); // $ExpectError - filledarrayBy( buf, true, 2, clbk ); // $ExpectError - filledarrayBy( buf, null, 2, clbk ); // $ExpectError - filledarrayBy( buf, [], 2, clbk ); // $ExpectError - filledarrayBy( buf, {}, 2, clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, clbk ); // $ExpectError - - filledarrayBy( buf, false, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, clbk, {} ); // $ExpectError - - filledarrayBy( buf, '5', 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, false, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, true, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, null, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, undefined, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, [], 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, {}, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, '5', 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, false, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, undefined, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a view length argument which is not a number... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, 8, false, clbk ); // $ExpectError - filledarrayBy( buf, 8, true, clbk ); // $ExpectError - filledarrayBy( buf, 8, null, clbk ); // $ExpectError - filledarrayBy( buf, 8, [], clbk ); // $ExpectError - filledarrayBy( buf, 8, {}, clbk ); // $ExpectError - - filledarrayBy( buf, 8, false, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, true, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, null, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, [], clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, {}, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, clbk, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5', 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, false, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, true, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, null, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, [], 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, {}, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, 8, '5', 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, [], 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, {}, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided too many arguments... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, 8, 2, 'float64', 1, clbk, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 997a381..0000000 --- a/examples/index.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ).factory; -var dtypes = require( '@stdlib/array-typed-real-dtypes' ); -var filledarrayBy = require( './../lib' ); - -// Create a pseudorandom number generator: -var rand = discreteUniform( 0, 100 ); - -// Get a list of array data types: -var dt = dtypes(); - -// Generate filled arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = filledarrayBy( 10, dt[ i ], rand ); - console.log( arr ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 764e40e..cb63cd1 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, RealOrComplexTypedArray, BooleanArray, DataType } from '@stdlib/types/array'; import { IterableIterator } from '@stdlib/types/iter'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..668c2f7 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@v0.0.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-ctors@v0.3.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill-by@v0.2.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled-by@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@v0.2.2-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.3.0-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";var v=f(),g=j.get("dtypes.default");function c(){var f,j,c,b,y,x,u,E;if(0===(j=arguments.length))return new(y=d(g))(0);if(r(c=arguments[0])){if(j>1)throw new TypeError(w("00h05"));if(null===(y=d(c)))throw new TypeError(w("00h2Y",c));return new y(0)}if(j<2)throw new TypeError(w("00h05"));if(h(arguments[j-=1]))if(h(arguments[j-1])){if(f=arguments[j],b=arguments[j-=1],0===j)throw new TypeError(w("00h05"))}else b=arguments[j];else{if(!(j>=2))throw new TypeError(w("00h05"));if(f=arguments[j],!h(b=arguments[j-=1]))throw new TypeError(w("00h2b",b))}if((j-=1)>=0&&r(arguments[j])?(c=arguments[j],j-=1):c=g,null===(y=d(c)))throw new TypeError(w("00h2Y",c));if("generic"===c){if(E=arguments[0],0===j){if(e(E)?u=E:i(E)&&(u=E.length),void 0!==u)return m(u,b,f);if(n(E))throw new Error(w("00h04"));if(o(E)){if(!1===v)throw new TypeError(w("00h2Z",E));if(!h(E[p]))throw new TypeError(w("00h2a",E));if(E=E[p](),!h(E.next))throw new TypeError(w("00h2a",E));return function(r,e,t){var s,i;for(s=[],i=-1;!r.next().done;)i+=1,s.push(e.call(t,i));return s}(E,b,f)}throw new TypeError(w("00h2a",E))}if(n(E))throw new Error(w("00h04"));throw new TypeError(w("00h2a",E))}if(0===j)if(i(E=arguments[0]))x=new y(E.length);else if(n(E))x=new y(E);else if(e(E))x=new y(E);else{if(!o(E))throw new TypeError(w("00h2a",E));if(!1===v)throw new TypeError(w("00h2Z",E));if(!h(E[p]))throw new TypeError(w("00h2a",E));if(E=E[p](),!h(E.next))throw new TypeError(w("00h2a",E));x=new y(a(E))}else x=1===j?new y(arguments[0],arguments[1]):new y(arguments[0],arguments[1],arguments[2]);return x.length>0&&(t(c)||s(c)?function(r,e,t){var s;for(s=0;s\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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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( format('00h05') );\n\t\t}\n\t\tctor = ctors( dtype );\n\t\tif ( ctor === null ) {\n\t\t\tthrow new TypeError( format( '00h2Y', 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( format('00h05') );\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( format('00h05') );\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( '00h2b', 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( format('00h05') );\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( '00h2Y', 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( format('00h04') );\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( '00h2Z', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00h2a', 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( '00h2a', 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( '00h2a', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format('00h04') );\n\t\t}\n\t\tthrow new TypeError( format( '00h2a', 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( '00h2Z', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00h2a', 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( '00h2a', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00h2a', 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\nexport default filledarrayBy;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","DEFAULT_DTYPE","defaults","get","filledarrayBy","thisArg","nargs","dtype","clbk","ctor","arr","len","arg","arguments","length","ctors","isString","TypeError","format","isFunction","isNonNegativeInteger","isCollection","filledArray","isArrayBuffer","Error","isObject","ITERATOR_SYMBOL","next","it","i","done","push","call","filledArrayIterator","iterLength","isComplexDataType","isBooleanDataType","set","filledAccessors","gfillBy","value","aidx"],"mappings":";;sjDA0CA,IAAIA,EAAsBC,IACtBC,EAAgBC,EAASC,IAAK,kBA2MlC,SAASC,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAKJ,GAAe,KAHfN,EAAQO,UAAUC,QAKjB,OAAO,IADPL,EAAOM,EAAOd,IACG,GAIlB,GAAKe,EADLT,EAAQM,UAAW,IACM,CAExB,GAAKP,EAAQ,EACZ,MAAM,IAAIW,UAAWC,EAAO,UAG7B,GAAc,QADdT,EAAOM,EAAOR,IAEb,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,OAAO,IAAIE,EAAM,EACjB,CAED,GAAKH,EAAQ,EACZ,MAAM,IAAIW,UAAWC,EAAO,UAM7B,GAAKC,EAAYN,UAHjBP,GAAS,IAKR,GAAKa,EAAYN,UAAWP,EAAM,KAMjC,GALAD,EAAUQ,UAAWP,GAErBE,EAAOK,UADPP,GAAS,GAIM,IAAVA,EACJ,MAAM,IAAIW,UAAWC,EAAO,eAI7BV,EAAOK,UAAWP,OAIf,MAAKA,GAAS,GAUlB,MAAM,IAAIW,UAAWC,EAAO,UAN5B,GAHAb,EAAUQ,UAAWP,IAGfa,EADNX,EAAOK,UADPP,GAAS,IAGR,MAAM,IAAIW,UAAWC,EAAQ,QAASV,GAMvC,CAUD,IARAF,GAAS,IACK,GAAKU,EAAUH,UAAWP,KACvCC,EAAQM,UAAWP,GACnBA,GAAS,GAETC,EAAQN,EAGK,QADdQ,EAAOM,EAAOR,IAEb,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,GAAe,YAAVA,EAAsB,CAE1B,GADAK,EAAMC,UAAW,GACF,IAAVP,EAAc,CAMlB,GALKc,EAAsBR,GAC1BD,EAAMC,EACKS,EAAcT,KACzBD,EAAMC,EAAIE,aAEE,IAARH,EACJ,OAAOW,EAAaX,EAAKH,EAAMH,GAEhC,GAAKkB,EAAeX,GACnB,MAAM,IAAIY,MAAON,EAAO,UAEzB,GAAKO,EAAUb,GAAQ,CACtB,IAA6B,IAAxBb,EACJ,MAAM,IAAIkB,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAYP,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLP,EAAYP,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvC,OAvSJ,SAA8BgB,EAAIpB,EAAMH,GACvC,IAAIK,EACAmB,EAKJ,IAFAnB,EAAM,GACNmB,GAAK,GAEAD,EAAGD,OACAG,MAGPD,GAAK,EACLnB,EAAIqB,KAAMvB,EAAKwB,KAAM3B,EAASwB,IAE/B,OAAOnB,CACR,CAuRWuB,CAAqBrB,EAAKJ,EAAMH,EACvC,CACD,MAAM,IAAIY,UAAWC,EAAQ,QAASN,GACzC,CAAS,GAAKW,EAAeX,GAC1B,MAAM,IAAIY,MAAON,EAAO,UAEzB,MAAM,IAAID,UAAWC,EAAQ,QAASN,GACtC,CACD,GAAe,IAAVN,EAEJ,GAAKe,EADLT,EAAMC,UAAW,IAEhBH,EAAM,IAAID,EAAMG,EAAIE,aACd,GAAKS,EAAeX,GAC1BF,EAAM,IAAID,EAAMG,QACV,GAAKQ,EAAsBR,GACjCF,EAAM,IAAID,EAAMG,OACV,KAAKa,EAAUb,GAarB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAZtC,IAA6B,IAAxBb,EACJ,MAAM,IAAIkB,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAYP,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLP,EAAYP,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvCF,EAAM,IAAID,EAAMyB,EAAYtB,GAG5B,MAEDF,EADqB,IAAVJ,EACL,IAAIG,EAAMI,UAAU,GAAIA,UAAU,IAElC,IAAIJ,EAAMI,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKH,EAAII,OAAS,IACZqB,EAAmB5B,IAAW6B,EAAmB7B,GAjTxD,SAA0BG,EAAKF,EAAMH,GACpC,IAAIwB,EACJ,IAAMA,EAAI,EAAGA,EAAInB,EAAII,OAAQe,IAC5BnB,EAAI2B,IAAK7B,EAAKwB,KAAM3B,EAASwB,GAAKA,EAGpC,CA4SGS,CAAiB5B,EAAKF,EAAMH,GAE5BkC,EAAS7B,EAAII,OAAQJ,EAAK,GAe5B,SAAmB8B,EAAOC,GACzB,OAAOjC,EAAKwB,KAAM3B,EAASoC,EAC3B,KAdM/B,CAeR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d115cf0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,192 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -/** -* Create a filled array according to a provided callback function. -* -* @module @stdlib/array-filled-by -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* var arr = filledarrayBy(); -* // returns -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'generic', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( [ 0.5, 0.5 ], clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1; -* } -* -* var arr = filledarrayBy( [ 5, -3 ], 'int32', clbk ); -* // returns [ 1, 1 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk1() { -* return 10; -* } -* -* function clbk2() { -* return 1.0; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, clbk2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk1() { -* return 1.0; -* } -* -* function clbk2() { -* return 2; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, 'uint32', clbk2 ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 'float32', clbk ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, clbk ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, 'int32', clbk ); -* // returns [ 1, 1 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index ed1aa9a..0000000 --- a/lib/main.js +++ /dev/null @@ -1,416 +0,0 @@ -/** -* @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 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' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var ctors = require( '@stdlib/array-ctors' ); -var gfillBy = require( '@stdlib/blas-ext-base-gfill-by' ); -var filledArray = require( '@stdlib/array-base-filled-by' ); -var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var iterLength = require( '@stdlib/iter-length' ); -var defaults = require( '@stdlib/array-defaults' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport(); -var DEFAULT_DTYPE = defaults.get( 'dtypes.default' ); - - -// FUNCTIONS // - -/** -* Creates a filled "generic" array from an iterator. -* -* @private -* @param {Iterable} it - iterator -* @param {Callback} clbk - callback function -* @param {*} thisArg - callback function execution context -* @returns {Array} filled array -*/ -function filledArrayIterator( it, clbk, thisArg ) { - var arr; - var i; - var v; - - arr = []; - i = -1; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - i += 1; - arr.push( clbk.call( thisArg, i ) ); - } - return arr; -} - -/** -* Fills an array exposing accessors for getting and setting array elements. -* -* @private -* @param {Collection} arr - input array -* @param {Callback} clbk - callback function -* @param {*} thisArg - callback function execution context -* @returns {Collection} input array -*/ -function filledAccessors( arr, clbk, thisArg ) { - var i; - for ( i = 0; i < arr.length; i++ ) { - arr.set( clbk.call( thisArg, i ), i ); - } - return arr; -} - - -// MAIN // - -/** -* Creates a filled array according to a provided callback function. -* -* @param {(NonNegativeInteger|TypedArray|ArrayLikeObject|ArrayBuffer|Iterable)} [arg] - a length, typed array, array-like object, buffer, or iterable -* @param {NonNegativeInteger} [byteOffset=0] - byte offset -* @param {NonNegativeInteger} [length] - view length -* @param {string} [dtype="float64"] - data type -* @param {Callback} [clbk] - callback to invoke -* @param {*} [thisArg] - callback execution context -* @throws {TypeError} must provide a recognized data type -* @throws {TypeError} must provide a length, typed array, array-like object, buffer, or iterable -* @throws {TypeError} callback argument must be a function. -* @throws {Error} creating a generic array from an `ArrayBuffer` is not supported -* @returns {(TypedArray|Array)} array or typed array -* -* @example -* var arr = filledarrayBy(); -* // returns -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'generic', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( [ 0.5, 0.5 ], clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1; -* } -* -* var arr = filledarrayBy( [ 5, -3 ], 'int32', clbk ); -* // returns [ 1, 1 ] -* -* @example -* function clbk1() { -* return 10; -* } -* -* function clbk2() { -* return 1.0; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, clbk2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk1() { -* return 1.0; -* } -* -* function clbk2() { -* return 2; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, 'uint32', clbk2 ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 'float32', clbk ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, clbk ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, 'int32', clbk ); -* // returns [ 1, 1 ] -*/ -function filledarrayBy() { - var thisArg; - var nargs; - var dtype; - var clbk; - var ctor; - var arr; - var len; - var arg; - - nargs = arguments.length; - - // If we weren't provided any arguments, return an empty array... - if ( nargs === 0 ) { - ctor = ctors( DEFAULT_DTYPE ); - return new ctor( 0 ); - } - // Check if we were provided a dtype as the first argument... - dtype = arguments[ 0 ]; - if ( isString( dtype ) ) { - // Invoking this function with arguments `f( dtype, clbk[, thisArg] )` is not allowed (otherwise, we'd need to also allow `f( clbk[, thisArg] )`)... - if ( nargs > 1 ) { - throw new TypeError( format('00h05') ); - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '00h2Y', dtype ) ); - } - // Return an empty array having the specified dtype: - return new ctor( 0 ); - } - // For all other supported invocations, we need at least two arguments... - if ( nargs < 2 ) { - throw new TypeError( format('00h05') ); - } - // At this point, we need to do some argument juggling... - nargs -= 1; // henceforth, the number of available arguments is `nargs+1` - - // Determine whether the last argument is a callback or "this" context... - if ( isFunction( arguments[ nargs ] ) ) { - // 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... - if ( isFunction( arguments[ nargs-1 ] ) ) { - thisArg = arguments[ nargs ]; - nargs -= 1; - clbk = arguments[ nargs ]; - - // Check if we were provided only a callback and a "this" context.. - if ( nargs === 0 ) { - throw new TypeError( format('00h05') ); - } - } else { - // "this" context is left undefined... - clbk = arguments[ nargs ]; - } - } - // 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... - else if ( nargs >= 2 ) { - thisArg = arguments[ nargs ]; - nargs -= 1; - clbk = arguments[ nargs ]; - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '00h2b', clbk ) ); - } - } - // If were were only provided 2 arguments and the last argument was not a function, we've been provided an insufficient number of arguments... - else { - throw new TypeError( format('00h05') ); - } - // Now that we've processed the callback arguments, let's continue working backward to see if we've been provided a `dtype` argument... - nargs -= 1; - if ( nargs >= 0 && isString( arguments[ nargs ] ) ) { - dtype = arguments[ nargs ]; - nargs -= 1; - } else { - dtype = DEFAULT_DTYPE; - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '00h2Y', dtype ) ); - } - // At this point, we've resolved the output array data type, and now we can actually create the output array... - if ( dtype === 'generic' ) { - arg = arguments[ 0 ]; - if ( nargs === 0 ) { - if ( isNonNegativeInteger( arg ) ) { - len = arg; - } else if ( isCollection( arg ) ) { - len = arg.length; - } - if ( len !== void 0 ) { - return filledArray( len, clbk, thisArg ); - } - if ( isArrayBuffer( arg ) ) { - throw new Error( format('00h04') ); - } - if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( '00h2Z', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00h2a', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00h2a', arg ) ); - } - return filledArrayIterator( arg, clbk, thisArg ); - } - throw new TypeError( format( '00h2a', arg ) ); - } else if ( isArrayBuffer( arg ) ) { - throw new Error( format('00h04') ); - } - throw new TypeError( format( '00h2a', arg ) ); - } - if ( nargs === 0 ) { // length || array-like || ArrayBuffer || iterable - arg = arguments[ 0 ]; - if ( isCollection( arg ) ) { - arr = new ctor( arg.length ); - } else if ( isArrayBuffer( arg ) ) { - arr = new ctor( arg ); - } else if ( isNonNegativeInteger( arg ) ) { - arr = new ctor( arg ); - } else if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( '00h2Z', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00h2a', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00h2a', arg ) ); - } - arr = new ctor( iterLength( arg ) ); - } else { - throw new TypeError( format( '00h2a', arg ) ); - } - } else if ( nargs === 1 ) { - arr = new ctor( arguments[0], arguments[1] ); // (ArrayBuffer, byteOffset) - } else { - arr = new ctor( arguments[0], arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset, length) - } - if ( arr.length > 0 ) { - if ( isComplexDataType( dtype ) || isBooleanDataType( dtype ) ) { - filledAccessors( arr, clbk, thisArg ); - } else { - gfillBy( arr.length, arr, 1, callback ); - } - } - return arr; - - /** - * Callback which wraps a provided callback and is invoked for each array element. - * - * @private - * @param {*} value - element value - * @param {NonNegativeInteger} aidx - array index - * @param {NonNegativeInteger} sidx - strided index - * @param {Collection} array - input array/collection - * @returns {*} callback return value - */ - function callback( value, aidx ) { - return clbk.call( thisArg, aidx ); - } -} - - -// EXPORTS // - -module.exports = filledarrayBy; diff --git a/package.json b/package.json index b5ac3ab..b16be36 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Create a filled array according to a provided callback function.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,75 +13,6 @@ "bugs": { "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.2", - "@stdlib/array-ctors": "^0.3.0", - "@stdlib/array-defaults": "^0.3.0", - "@stdlib/assert-has-iterator-symbol-support": "^0.2.2", - "@stdlib/assert-is-arraybuffer": "^0.2.2", - "@stdlib/assert-is-collection": "^0.2.2", - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer": "^0.2.2", - "@stdlib/assert-is-object": "^0.2.2", - "@stdlib/assert-is-string": "^0.2.2", - "@stdlib/blas-ext-base-gfill-by": "^0.2.1", - "@stdlib/iter-length": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/symbol-iterator": "^0.2.2", - "@stdlib/types": "^0.4.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-bool": "^0.1.0", - "@stdlib/array-buffer": "^0.2.2", - "@stdlib/array-complex128": "^0.3.0", - "@stdlib/array-complex64": "^0.3.0", - "@stdlib/array-float32": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/array-int16": "^0.2.2", - "@stdlib/array-int32": "^0.2.2", - "@stdlib/array-int8": "^0.2.2", - "@stdlib/array-typed-real-dtypes": "^0.2.2", - "@stdlib/array-uint16": "^0.2.2", - "@stdlib/array-uint32": "^0.2.2", - "@stdlib/array-uint8": "^0.2.2", - "@stdlib/array-uint8c": "^0.2.2", - "@stdlib/assert-instance-of": "^0.2.2", - "@stdlib/assert-is-array": "^0.2.2", - "@stdlib/assert-is-typed-array": "^0.2.2", - "@stdlib/assert-is-typed-array-like": "^0.2.2", - "@stdlib/complex-float32-ctor": "^0.0.2", - "@stdlib/complex-float64-ctor": "^0.0.3", - "@stdlib/iter-constant": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/random-base-discrete-uniform": "^0.2.1", - "@stdlib/strided-base-reinterpret-boolean": "^0.0.2", - "@stdlib/strided-base-reinterpret-complex128": "^0.2.2", - "@stdlib/strided-base-reinterpret-complex64": "^0.2.1", - "@stdlib/utils-constant-function": "^0.2.2", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..e4cee9c --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index ca0cf25..0000000 --- a/test/test.js +++ /dev/null @@ -1,4397 +0,0 @@ -/** -* @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. -*/ - -/* eslint-disable max-len */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -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' ); -var iterConstant = require( '@stdlib/iter-constant' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var filledarrayBy = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': !hasIteratorSymbolSupport() -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof filledarrayBy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if only provided callback arguments', function test( t ) { - t.throws( clbk1, TypeError, 'throws an error' ); - t.throws( clbk2, TypeError, 'throws an error' ); - t.throws( clbk3, TypeError, 'throws an error' ); - t.end(); - - function clbk1() { - filledarrayBy( constantFunction( 1.0 ) ); - } - - function clbk2() { - filledarrayBy( constantFunction( 1.0 ), {} ); - } - - function clbk3() { - filledarrayBy( constantFunction( 1.0 ), constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (only argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (typed array; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (array-like object)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (array-like object; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 8 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 8 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, 1, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (iterator)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( iterConstant( 1.0 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (iterator; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( iterConstant( 1.0 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if only provided data type and callback arguments', function test( t ) { - t.throws( clbk1, TypeError, 'throws an error' ); - t.throws( clbk2, TypeError, 'throws an error' ); - t.throws( clbk3, TypeError, 'throws an error' ); - t.end(); - - function clbk1() { - filledarrayBy( 'float64', constantFunction( 1.0 ) ); - } - - function clbk2() { - filledarrayBy( 'float64', constantFunction( 1.0 ), {} ); - } - - function clbk3() { - filledarrayBy( 'float64', constantFunction( 1.0 ), constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (array-like object)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (array-like object; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, 1, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, 1, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (no iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (no iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (non-function iterator symbol property)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (non-function iterator symbol property; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (`next` property is not a function)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ) ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (`next` property is not a function; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ), {} ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (no iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (no iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (non-function iterator symbol property)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (non-function iterator symbol property; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (`next` property is not a function)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ) ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (`next` property is not a function; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ), {} ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 1, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 1, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function returns a filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - arr = filledarrayBy(); - - t.strictEqual( instanceOf( arr, Float64Array ), 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=float64)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - arr = filledarrayBy( 'float64' ); - - t.strictEqual( instanceOf( arr, Float64Array ), 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=float32)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( 0 ); - arr = filledarrayBy( 'float32' ); - - t.strictEqual( instanceOf( arr, Float32Array ), 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=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; - - expected = new Complex128Array( 0 ); - arr = filledarrayBy( 'complex128' ); - - t.strictEqual( instanceOf( arr, Complex128Array ), 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=complex64)', function test( t ) { - var expected; - var arr; - - expected = new Complex64Array( 0 ); - arr = filledarrayBy( 'complex64' ); - - t.strictEqual( instanceOf( arr, Complex64Array ), 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=int32)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( 0 ); - arr = filledarrayBy( 'int32' ); - - t.strictEqual( instanceOf( arr, Int32Array ), 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=uint32)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( 0 ); - arr = filledarrayBy( 'uint32' ); - - t.strictEqual( instanceOf( arr, Uint32Array ), 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=int16)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( 0 ); - arr = filledarrayBy( 'int16' ); - - t.strictEqual( instanceOf( arr, Int16Array ), 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=uint16)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( 0 ); - arr = filledarrayBy( 'uint16' ); - - t.strictEqual( instanceOf( arr, Uint16Array ), 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=int8)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( 0 ); - arr = filledarrayBy( 'int8' ); - - t.strictEqual( instanceOf( arr, Int8Array ), 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=uint8)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( 0 ); - arr = filledarrayBy( 'uint8' ); - - t.strictEqual( instanceOf( arr, Uint8Array ), 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=uint8c)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( 0 ); - arr = filledarrayBy( 'uint8c' ); - - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), 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=generic)', function test( t ) { - var expected; - var arr; - - expected = []; - arr = filledarrayBy( 'generic' ); - - t.strictEqual( instanceOf( arr, Array ), 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 (default, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, length=0)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array(); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 0, clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, clbk, ctx ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (default, length; thisArg=function)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, clbk, context ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this(); // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } - - function context() { - ctx.count += 1; - } -}); - -tape( 'the function returns a filled array (dtype=float64, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, 'float64', clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, length; thisArg=function)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, 'float64', clbk, context ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this(); // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } - - function context() { - ctx.count += 1; - } -}); - -tape( 'the function returns a filled array (dtype=float32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, 'float32', clbk ); - - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - 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; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = filledarrayBy( 5, 'complex128', clbk ); - - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = filledarrayBy( 5, 'complex64', clbk ); - - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int32Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int32', clbk ); - - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint32Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint32', clbk ); - - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int16Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int16', clbk ); - - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint16', clbk ); - - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int8Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int8', clbk ); - - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint8', clbk ); - - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint8c', clbk ); - - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = [ 1, 1, 1, 1, 1 ]; - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'generic', clbk ); - - t.strictEqual( instanceOf( arr, Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - 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; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = [ 1.0, 2.0 ]; - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = [ 1.0, 2.0 ]; - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int32', clbk ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, typed array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, typed array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - 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; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = new Float64Array( [ 1.0, 2.0 ] ); - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = new Float64Array( [ 1.0, 2.0 ] ); - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (default, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - 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; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer, byteoffset; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer, byteoffset; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - 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; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 48 ); - out = filledarrayBy( buf, 16, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 24 ); - out = filledarrayBy( buf, 8, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int32', clbk ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint8c', clbk ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - 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; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 64 ); - out = filledarrayBy( buf, 16, 2, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset, length)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 1, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 1, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled array (default, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, iterator; thisArg)', opts, function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - ctx = { - 'count': 0 - }; - indices = []; - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, iterator; thisArg)', opts, function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - ctx = { - 'count': 0 - }; - indices = []; - out = filledarrayBy( arr, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - 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; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = iterConstant( new Complex128( 3.0, 3.0 ), { - 'iter': 2 - }); - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = iterConstant( new Complex64( 3.0, 3.0 ), { - 'iter': 2 - }); - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); From a23c16d41e22b61a6ffc9a1278ca0d9542661dfd Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 24 Feb 2025 01:29:20 +0000 Subject: [PATCH 075/117] Transform error messages --- lib/main.js | 38 +++++++++++++++++++------------------- package.json | 2 +- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/lib/main.js b/lib/main.js index b322cfe..ed1aa9a 100644 --- a/lib/main.js +++ b/lib/main.js @@ -35,7 +35,7 @@ var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-supp var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); var iterLength = require( '@stdlib/iter-length' ); var defaults = require( '@stdlib/array-defaults' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -266,18 +266,18 @@ function filledarrayBy() { if ( isString( dtype ) ) { // Invoking this function with arguments `f( dtype, clbk[, thisArg] )` is not allowed (otherwise, we'd need to also allow `f( clbk[, thisArg] )`)... if ( nargs > 1 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format('00h05') ); } ctor = ctors( dtype ); if ( ctor === null ) { - throw new TypeError( format( 'invalid argument. Must provide a recognized data type. Value: `%s`.', dtype ) ); + throw new TypeError( format( '00h2Y', dtype ) ); } // Return an empty array having the specified dtype: return new ctor( 0 ); } // For all other supported invocations, we need at least two arguments... if ( nargs < 2 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format('00h05') ); } // At this point, we need to do some argument juggling... nargs -= 1; // henceforth, the number of available arguments is `nargs+1` @@ -292,7 +292,7 @@ function filledarrayBy() { // Check if we were provided only a callback and a "this" context.. if ( nargs === 0 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format('00h05') ); } } else { // "this" context is left undefined... @@ -305,12 +305,12 @@ function filledarrayBy() { nargs -= 1; clbk = arguments[ nargs ]; if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '00h2b', clbk ) ); } } // If were were only provided 2 arguments and the last argument was not a function, we've been provided an insufficient number of arguments... else { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format('00h05') ); } // Now that we've processed the callback arguments, let's continue working backward to see if we've been provided a `dtype` argument... nargs -= 1; @@ -322,7 +322,7 @@ function filledarrayBy() { } ctor = ctors( dtype ); if ( ctor === null ) { - throw new TypeError( format( 'invalid argument. Must provide a recognized data type. Value: `%s`.', dtype ) ); + throw new TypeError( format( '00h2Y', dtype ) ); } // At this point, we've resolved the output array data type, and now we can actually create the output array... if ( dtype === 'generic' ) { @@ -337,26 +337,26 @@ function filledarrayBy() { return filledArray( len, clbk, thisArg ); } if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format('00h04') ); } if ( isObject( arg ) ) { if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2Z', arg ) ); } if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } arg = arg[ ITERATOR_SYMBOL ](); if ( !isFunction( arg.next ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } return filledArrayIterator( arg, clbk, thisArg ); } - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } else if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format('00h04') ); } - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } if ( nargs === 0 ) { // length || array-like || ArrayBuffer || iterable arg = arguments[ 0 ]; @@ -368,18 +368,18 @@ function filledarrayBy() { arr = new ctor( arg ); } else if ( isObject( arg ) ) { if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2Z', arg ) ); } if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } arg = arg[ ITERATOR_SYMBOL ](); if ( !isFunction( arg.next ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } arr = new ctor( iterLength( arg ) ); } else { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } } else if ( nargs === 1 ) { arr = new ctor( arguments[0], arguments[1] ); // (ArrayBuffer, byteOffset) diff --git a/package.json b/package.json index 42e92b1..b5ac3ab 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "@stdlib/assert-is-string": "^0.2.2", "@stdlib/blas-ext-base-gfill-by": "^0.2.1", "@stdlib/iter-length": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/symbol-iterator": "^0.2.2", "@stdlib/types": "^0.4.3", "@stdlib/error-tools-fmtprodmsg": "^0.2.2" From 7b42798cc7f1c935c315333604ffd390850e135d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 24 Feb 2025 02:02:25 +0000 Subject: [PATCH 076/117] Remove files --- index.d.ts | 322 ---- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5169 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index cb63cd1..0000000 --- a/index.d.ts +++ /dev/null @@ -1,322 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, RealOrComplexTypedArray, BooleanArray, DataType } from '@stdlib/types/array'; -import { IterableIterator } from '@stdlib/types/iter'; - -/** -* Array or typed array. -*/ -type ArrayOrTypedArray = Array | RealOrComplexTypedArray | BooleanArray; - -/** -* Nullary callback function. -* -* @returns fill value -*/ -type Nullary = () => any; - -/** -* Unary callback function. -* -* @param i - current array index -* @returns fill value -*/ -type Unary = ( i: number ) => any; - -/** -* Callback function. -* -* @param i - current array index -* @returns fill value -*/ -type Callback = Nullary | Unary; - -/** -* Creates a filled array according to a provided callback function and having a specified data type. -* -* @param dtype - data type -* @returns filled array -* -* @example -* var arr = filledarrayBy(); -* // returns -* -* @example -* var arr = filledarrayBy( 'float32' ); -* // returns -*/ -declare function filledarrayBy( dtype?: DataType ): ArrayOrTypedArray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Creates a filled array according to a provided callback function and having a specified `length`. -* -* @param length - array length -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* -* var arr = filledarrayBy( 5, constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( length: number, clbk: Callback, thisArg?: any ): ArrayOrTypedArray; - -/** -* Creates a filled array according to a provided callback function and having a specified `length`. -* -* @param length - array length -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* -* var arr = filledarrayBy( 5, 'float64', constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( length: number, dtype: DataType, clbk: Callback, thisArg?: any ): ArrayOrTypedArray; - -/** -* Creates a filled array from another `array` according to a provided callback function. -* -* @param array - typed array or array-like object -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* -* 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; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Creates a filled array from another `array` according to a provided callback function. -* -* @param array - typed array or array-like object -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* -* 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; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Creates a filled array from an iterable according to a callback function. -* -* @param iterable - iterable -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var iterConstant = require( '@stdlib/iter-constant' ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarrayBy( it, constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( iterable: IterableIterator, clbk: Callback, thisArg?: any ): ArrayOrTypedArray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Creates a filled array from an iterable according to a callback function. -* -* @param iterable - iterable -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var iterConstant = require( '@stdlib/iter-constant' ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarrayBy( it, 'float64', constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( iterable: IterableIterator, dtype: DataType, clbk: 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. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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 | BooleanArray; - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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 | BooleanArray; - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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 | BooleanArray; - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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 | BooleanArray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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 | BooleanArray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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 | BooleanArray; // eslint-disable-line @typescript-eslint/unified-signatures - - -// EXPORTS // - -export = filledarrayBy; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 668c2f7..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@v0.0.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-ctors@v0.3.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill-by@v0.2.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled-by@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@v0.2.2-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.3.0-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";var v=f(),g=j.get("dtypes.default");function c(){var f,j,c,b,y,x,u,E;if(0===(j=arguments.length))return new(y=d(g))(0);if(r(c=arguments[0])){if(j>1)throw new TypeError(w("00h05"));if(null===(y=d(c)))throw new TypeError(w("00h2Y",c));return new y(0)}if(j<2)throw new TypeError(w("00h05"));if(h(arguments[j-=1]))if(h(arguments[j-1])){if(f=arguments[j],b=arguments[j-=1],0===j)throw new TypeError(w("00h05"))}else b=arguments[j];else{if(!(j>=2))throw new TypeError(w("00h05"));if(f=arguments[j],!h(b=arguments[j-=1]))throw new TypeError(w("00h2b",b))}if((j-=1)>=0&&r(arguments[j])?(c=arguments[j],j-=1):c=g,null===(y=d(c)))throw new TypeError(w("00h2Y",c));if("generic"===c){if(E=arguments[0],0===j){if(e(E)?u=E:i(E)&&(u=E.length),void 0!==u)return m(u,b,f);if(n(E))throw new Error(w("00h04"));if(o(E)){if(!1===v)throw new TypeError(w("00h2Z",E));if(!h(E[p]))throw new TypeError(w("00h2a",E));if(E=E[p](),!h(E.next))throw new TypeError(w("00h2a",E));return function(r,e,t){var s,i;for(s=[],i=-1;!r.next().done;)i+=1,s.push(e.call(t,i));return s}(E,b,f)}throw new TypeError(w("00h2a",E))}if(n(E))throw new Error(w("00h04"));throw new TypeError(w("00h2a",E))}if(0===j)if(i(E=arguments[0]))x=new y(E.length);else if(n(E))x=new y(E);else if(e(E))x=new y(E);else{if(!o(E))throw new TypeError(w("00h2a",E));if(!1===v)throw new TypeError(w("00h2Z",E));if(!h(E[p]))throw new TypeError(w("00h2a",E));if(E=E[p](),!h(E.next))throw new TypeError(w("00h2a",E));x=new y(a(E))}else x=1===j?new y(arguments[0],arguments[1]):new y(arguments[0],arguments[1],arguments[2]);return x.length>0&&(t(c)||s(c)?function(r,e,t){var s;for(s=0;s\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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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( format('00h05') );\n\t\t}\n\t\tctor = ctors( dtype );\n\t\tif ( ctor === null ) {\n\t\t\tthrow new TypeError( format( '00h2Y', 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( format('00h05') );\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( format('00h05') );\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( '00h2b', 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( format('00h05') );\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( '00h2Y', 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( format('00h04') );\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( '00h2Z', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00h2a', 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( '00h2a', 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( '00h2a', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format('00h04') );\n\t\t}\n\t\tthrow new TypeError( format( '00h2a', 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( '00h2Z', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00h2a', 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( '00h2a', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00h2a', 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\nexport default filledarrayBy;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","DEFAULT_DTYPE","defaults","get","filledarrayBy","thisArg","nargs","dtype","clbk","ctor","arr","len","arg","arguments","length","ctors","isString","TypeError","format","isFunction","isNonNegativeInteger","isCollection","filledArray","isArrayBuffer","Error","isObject","ITERATOR_SYMBOL","next","it","i","done","push","call","filledArrayIterator","iterLength","isComplexDataType","isBooleanDataType","set","filledAccessors","gfillBy","value","aidx"],"mappings":";;sjDA0CA,IAAIA,EAAsBC,IACtBC,EAAgBC,EAASC,IAAK,kBA2MlC,SAASC,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAKJ,GAAe,KAHfN,EAAQO,UAAUC,QAKjB,OAAO,IADPL,EAAOM,EAAOd,IACG,GAIlB,GAAKe,EADLT,EAAQM,UAAW,IACM,CAExB,GAAKP,EAAQ,EACZ,MAAM,IAAIW,UAAWC,EAAO,UAG7B,GAAc,QADdT,EAAOM,EAAOR,IAEb,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,OAAO,IAAIE,EAAM,EACjB,CAED,GAAKH,EAAQ,EACZ,MAAM,IAAIW,UAAWC,EAAO,UAM7B,GAAKC,EAAYN,UAHjBP,GAAS,IAKR,GAAKa,EAAYN,UAAWP,EAAM,KAMjC,GALAD,EAAUQ,UAAWP,GAErBE,EAAOK,UADPP,GAAS,GAIM,IAAVA,EACJ,MAAM,IAAIW,UAAWC,EAAO,eAI7BV,EAAOK,UAAWP,OAIf,MAAKA,GAAS,GAUlB,MAAM,IAAIW,UAAWC,EAAO,UAN5B,GAHAb,EAAUQ,UAAWP,IAGfa,EADNX,EAAOK,UADPP,GAAS,IAGR,MAAM,IAAIW,UAAWC,EAAQ,QAASV,GAMvC,CAUD,IARAF,GAAS,IACK,GAAKU,EAAUH,UAAWP,KACvCC,EAAQM,UAAWP,GACnBA,GAAS,GAETC,EAAQN,EAGK,QADdQ,EAAOM,EAAOR,IAEb,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,GAAe,YAAVA,EAAsB,CAE1B,GADAK,EAAMC,UAAW,GACF,IAAVP,EAAc,CAMlB,GALKc,EAAsBR,GAC1BD,EAAMC,EACKS,EAAcT,KACzBD,EAAMC,EAAIE,aAEE,IAARH,EACJ,OAAOW,EAAaX,EAAKH,EAAMH,GAEhC,GAAKkB,EAAeX,GACnB,MAAM,IAAIY,MAAON,EAAO,UAEzB,GAAKO,EAAUb,GAAQ,CACtB,IAA6B,IAAxBb,EACJ,MAAM,IAAIkB,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAYP,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLP,EAAYP,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvC,OAvSJ,SAA8BgB,EAAIpB,EAAMH,GACvC,IAAIK,EACAmB,EAKJ,IAFAnB,EAAM,GACNmB,GAAK,GAEAD,EAAGD,OACAG,MAGPD,GAAK,EACLnB,EAAIqB,KAAMvB,EAAKwB,KAAM3B,EAASwB,IAE/B,OAAOnB,CACR,CAuRWuB,CAAqBrB,EAAKJ,EAAMH,EACvC,CACD,MAAM,IAAIY,UAAWC,EAAQ,QAASN,GACzC,CAAS,GAAKW,EAAeX,GAC1B,MAAM,IAAIY,MAAON,EAAO,UAEzB,MAAM,IAAID,UAAWC,EAAQ,QAASN,GACtC,CACD,GAAe,IAAVN,EAEJ,GAAKe,EADLT,EAAMC,UAAW,IAEhBH,EAAM,IAAID,EAAMG,EAAIE,aACd,GAAKS,EAAeX,GAC1BF,EAAM,IAAID,EAAMG,QACV,GAAKQ,EAAsBR,GACjCF,EAAM,IAAID,EAAMG,OACV,KAAKa,EAAUb,GAarB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAZtC,IAA6B,IAAxBb,EACJ,MAAM,IAAIkB,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAYP,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLP,EAAYP,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvCF,EAAM,IAAID,EAAMyB,EAAYtB,GAG5B,MAEDF,EADqB,IAAVJ,EACL,IAAIG,EAAMI,UAAU,GAAIA,UAAU,IAElC,IAAIJ,EAAMI,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKH,EAAII,OAAS,IACZqB,EAAmB5B,IAAW6B,EAAmB7B,GAjTxD,SAA0BG,EAAKF,EAAMH,GACpC,IAAIwB,EACJ,IAAMA,EAAI,EAAGA,EAAInB,EAAII,OAAQe,IAC5BnB,EAAI2B,IAAK7B,EAAKwB,KAAM3B,EAASwB,GAAKA,EAGpC,CA4SGS,CAAiB5B,EAAKF,EAAMH,GAE5BkC,EAAS7B,EAAII,OAAQJ,EAAK,GAe5B,SAAmB8B,EAAOC,GACzB,OAAOjC,EAAKwB,KAAM3B,EAASoC,EAC3B,KAdM/B,CAeR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index e4cee9c..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 5131d660d7460ced3353db271a6f9f484e7e90cc Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 24 Feb 2025 02:02:54 +0000 Subject: [PATCH 077/117] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 194 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 191 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 49 +- SECURITY.md | 5 - benchmark/benchmark.js | 341 -- benchmark/benchmark.length.bool.js | 97 - benchmark/benchmark.length.complex128.js | 98 - benchmark/benchmark.length.complex64.js | 98 - benchmark/benchmark.length.float32.js | 97 - benchmark/benchmark.length.float64.js | 97 - benchmark/benchmark.length.generic.js | 97 - benchmark/benchmark.length.int16.js | 97 - benchmark/benchmark.length.int32.js | 97 - benchmark/benchmark.length.int8.js | 97 - benchmark/benchmark.length.uint16.js | 97 - benchmark/benchmark.length.uint32.js | 97 - benchmark/benchmark.length.uint8.js | 97 - benchmark/benchmark.length.uint8c.js | 97 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 36 - dist/index.js.map | 7 - docs/repl.txt | 157 - docs/types/test.ts | 606 --- examples/index.js | 37 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 192 - lib/main.js | 416 -- package.json | 96 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 4397 ---------------- 57 files changed, 4870 insertions(+), 11148 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.length.bool.js delete mode 100644 benchmark/benchmark.length.complex128.js delete mode 100644 benchmark/benchmark.length.complex64.js delete mode 100644 benchmark/benchmark.length.float32.js delete mode 100644 benchmark/benchmark.length.float64.js delete mode 100644 benchmark/benchmark.length.generic.js delete mode 100644 benchmark/benchmark.length.int16.js delete mode 100644 benchmark/benchmark.length.int32.js delete mode 100644 benchmark/benchmark.length.int8.js delete mode 100644 benchmark/benchmark.length.uint16.js delete mode 100644 benchmark/benchmark.length.uint32.js delete mode 100644 benchmark/benchmark.length.uint8.js delete mode 100644 benchmark/benchmark.length.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 849b19b..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-02-24T01:18:24.374Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 2d6aaee..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/contributing/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index f988046..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index b2c1f9c..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '42 6 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -278,7 +269,7 @@ for ( i = 0; i < dt.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -347,13 +338,13 @@ Copyright © 2016-2025. 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/dtypes]: https://github.com/stdlib-js/array-dtypes/tree/esm -[@stdlib/array/filled]: https://github.com/stdlib-js/array-filled +[@stdlib/array/filled]: https://github.com/stdlib-js/array-filled/tree/esm -[@stdlib/array/typed]: https://github.com/stdlib-js/array-typed +[@stdlib/array/typed]: https://github.com/stdlib-js/array-typed/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 17cfb5a..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,341 +0,0 @@ -/** -* @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 isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); -var isArray = require( '@stdlib/assert-is-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var Complex64 = require( '@stdlib/complex-float32-ctor' ); -var Complex128 = require( '@stdlib/complex-float64-ctor' ); -var pkg = require( './../package.json' ).name; -var filledarrayBy = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 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=float64', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'float64', 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=float32', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'float32', 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=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; - var i; - - clbk = constantFunction( new Complex128( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'complex128', 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=complex64', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( new Complex64( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'complex64', 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=int32', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int32', 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=uint32', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint32', 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=int16', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int16', 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=uint16', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint16', 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=int8', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int8', 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=uint8', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint8', 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=uint8c', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint8c', 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=generic', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'generic', clbk ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.length.bool.js b/benchmark/benchmark.length.bool.js deleted file mode 100644 index 3cdd152..0000000 --- a/benchmark/benchmark.length.bool.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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/benchmark/benchmark.length.complex128.js b/benchmark/benchmark.length.complex128.js deleted file mode 100644 index 122bc7c..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 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 Complex128 = require( '@stdlib/complex-float64-ctor' ); -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( new Complex128( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'complex128', 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=complex128,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.complex64.js b/benchmark/benchmark.length.complex64.js deleted file mode 100644 index e7a2d74..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 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 Complex64 = require( '@stdlib/complex-float32-ctor' ); -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( new Complex64( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'complex64', 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=complex64,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.float32.js b/benchmark/benchmark.length.float32.js deleted file mode 100644 index d2b2ba7..0000000 --- a/benchmark/benchmark.length.float32.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'float32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=float32,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.float64.js b/benchmark/benchmark.length.float64.js deleted file mode 100644 index 65064e3..0000000 --- a/benchmark/benchmark.length.float64.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'float64', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=float64,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.generic.js b/benchmark/benchmark.length.generic.js deleted file mode 100644 index eb87dfa..0000000 --- a/benchmark/benchmark.length.generic.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isArray = require( '@stdlib/assert-is-array' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'generic', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isArray( 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=generic,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int16.js b/benchmark/benchmark.length.int16.js deleted file mode 100644 index 914ff7c..0000000 --- a/benchmark/benchmark.length.int16.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int16', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=int16,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int32.js b/benchmark/benchmark.length.int32.js deleted file mode 100644 index cc0f678..0000000 --- a/benchmark/benchmark.length.int32.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=int32,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int8.js b/benchmark/benchmark.length.int8.js deleted file mode 100644 index 77553b0..0000000 --- a/benchmark/benchmark.length.int8.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int8', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=int8,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint16.js b/benchmark/benchmark.length.uint16.js deleted file mode 100644 index c68efdd..0000000 --- a/benchmark/benchmark.length.uint16.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint16', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint16,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint32.js b/benchmark/benchmark.length.uint32.js deleted file mode 100644 index 27c1742..0000000 --- a/benchmark/benchmark.length.uint32.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint32,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint8.js b/benchmark/benchmark.length.uint8.js deleted file mode 100644 index 2a26be4..0000000 --- a/benchmark/benchmark.length.uint8.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint8', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint8,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint8c.js b/benchmark/benchmark.length.uint8c.js deleted file mode 100644 index dd6e8c2..0000000 --- a/benchmark/benchmark.length.uint8c.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint8c', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint8c,len='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index c138144..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by" -%% click B href "https://github.com/stdlib-js/array-filled-by/tree/main" -%% click C href "https://github.com/stdlib-js/array-filled-by/tree/production" -%% click D href "https://github.com/stdlib-js/array-filled-by/tree/esm" -%% click E href "https://github.com/stdlib-js/array-filled-by/tree/deno" -%% click F href "https://github.com/stdlib-js/array-filled-by/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by -[production-url]: https://github.com/stdlib-js/array-filled-by/tree/production -[deno-url]: https://github.com/stdlib-js/array-filled-by/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-filled-by/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-filled-by/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-filled-by/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-filled-by/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-filled-by/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 188fc9b..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import filledarrayBy from '../docs/types/index'; -export = filledarrayBy; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 65ae3db..0000000 --- a/dist/index.js +++ /dev/null @@ -1,36 +0,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 deleted file mode 100644 index e88f9aa..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "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,YACjDC,EAAuB,QAAS,uCAAwC,EAAE,YAC1EC,EAAoB,QAAS,+DAAgE,EAC7FC,EAAoB,QAAS,gDAAiD,EAC9EC,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,EAAQ,UAAU,OAGbA,IAAU,EACd,OAAAE,EAAOrB,EAAOS,CAAc,EACrB,IAAIY,EAAM,CAAE,EAIpB,GADAD,EAAQ,UAAW,CAAE,EAChB5B,EAAU4B,CAAM,EAAI,CAExB,GAAKD,EAAQ,EACZ,MAAM,IAAI,UAAW,2FAA4F,EAGlH,GADAE,EAAOrB,EAAOoB,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWd,EAAQ,sEAAuEa,CAAM,CAAE,EAG7G,OAAO,IAAIC,EAAM,CAAE,CACpB,CAEA,GAAKF,EAAQ,EACZ,MAAM,IAAI,UAAW,2FAA4F,EAMlH,GAHAA,GAAS,EAGJpB,EAAY,UAAWoB,CAAM,CAAE,EAEnC,GAAKpB,EAAY,UAAWoB,EAAM,CAAE,CAAE,GAMrC,GALAN,EAAU,UAAWM,CAAM,EAC3BA,GAAS,EACTP,EAAO,UAAWO,CAAM,EAGnBA,IAAU,EACd,MAAM,IAAI,UAAW,2FAA4F,OAIlHP,EAAO,UAAWO,CAAM,UAIhBA,GAAS,GAIlB,GAHAN,EAAU,UAAWM,CAAM,EAC3BA,GAAS,EACTP,EAAO,UAAWO,CAAM,EACnB,CAACpB,EAAYa,CAAK,EACtB,MAAM,IAAI,UAAWL,EAAQ,uEAAwEK,CAAK,CAAE,MAK7G,OAAM,IAAI,UAAW,2FAA4F,EAWlH,GARAO,GAAS,EACJA,GAAS,GAAK3B,EAAU,UAAW2B,CAAM,CAAE,GAC/CC,EAAQ,UAAWD,CAAM,EACzBA,GAAS,GAETC,EAAQX,EAETY,EAAOrB,EAAOoB,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWd,EAAQ,sEAAuEa,CAAM,CAAE,EAG7G,GAAKA,IAAU,UAAY,CAE1B,GADAG,EAAM,UAAW,CAAE,EACdJ,IAAU,EAAI,CAMlB,GALK1B,EAAsB8B,CAAI,EAC9BD,EAAMC,EACK3B,EAAc2B,CAAI,IAC7BD,EAAMC,EAAI,QAEND,IAAQ,OACZ,OAAOpB,EAAaoB,EAAKV,EAAMC,CAAQ,EAExC,GAAKhB,EAAe0B,CAAI,EACvB,MAAM,IAAI,MAAO,mFAAoF,EAEtG,GAAKzB,EAAUyB,CAAI,EAAI,CACtB,GAAKf,IAAwB,GAC5B,MAAM,IAAI,UAAWD,EAAQ,sIAAuIgB,CAAI,CAAE,EAE3K,GAAK,CAACxB,EAAYwB,EAAKnB,CAAgB,CAAE,EACxC,MAAM,IAAI,UAAWG,EAAQ,wGAAyGgB,CAAI,CAAE,EAG7I,GADAA,EAAMA,EAAKnB,CAAgB,EAAE,EACxB,CAACL,EAAYwB,EAAI,IAAK,EAC1B,MAAM,IAAI,UAAWhB,EAAQ,wGAAyGgB,CAAI,CAAE,EAE7I,OAAOb,EAAqBa,EAAKX,EAAMC,CAAQ,CAChD,CACA,MAAM,IAAI,UAAWN,EAAQ,wGAAyGgB,CAAI,CAAE,CAC7I,SAAY1B,EAAe0B,CAAI,EAC9B,MAAM,IAAI,MAAO,mFAAoF,EAEtG,MAAM,IAAI,UAAWhB,EAAQ,wGAAyGgB,CAAI,CAAE,CAC7I,CACA,GAAKJ,IAAU,EAEd,GADAI,EAAM,UAAW,CAAE,EACd3B,EAAc2B,CAAI,EACtBT,EAAM,IAAIO,EAAME,EAAI,MAAO,UAChB1B,EAAe0B,CAAI,EAC9BT,EAAM,IAAIO,EAAME,CAAI,UACT9B,EAAsB8B,CAAI,EACrCT,EAAM,IAAIO,EAAME,CAAI,UACTzB,EAAUyB,CAAI,EAAI,CAC7B,GAAKf,IAAwB,GAC5B,MAAM,IAAI,UAAWD,EAAQ,sIAAuIgB,CAAI,CAAE,EAE3K,GAAK,CAACxB,EAAYwB,EAAKnB,CAAgB,CAAE,EACxC,MAAM,IAAI,UAAWG,EAAQ,wGAAyGgB,CAAI,CAAE,EAG7I,GADAA,EAAMA,EAAKnB,CAAgB,EAAE,EACxB,CAACL,EAAYwB,EAAI,IAAK,EAC1B,MAAM,IAAI,UAAWhB,EAAQ,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,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 deleted file mode 100644 index 06f3146..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,157 +0,0 @@ - -{{alias}}( [dtype] ) - Creates a filled array. - - Parameters - ---------- - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr = {{alias}}() - - > arr = {{alias}}( 'float32' ) - - - -{{alias}}( length[, dtype], clbk[, thisArg] ) - Returns a filled array according to a provided callback function and having - a specified length. - - Parameters - ---------- - length: integer - Array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > function clbk() { return 1.0; }; - > var arr = {{alias}}( 5, clbk ) - [ 1.0, 1.0, 1.0, 1.0, 1.0 ] - > arr = {{alias}}( 5, 'int32', clbk ) - [ 1, 1, 1, 1, 1 ] - - -{{alias}}( array[, dtype], clbk[, thisArg] ) - Creates a filled array from another array (or array-like object) according - to a provided callback function. - - Parameters - ---------- - array: ArrayLikeObject - Array from which to generate another array. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias}}( [ 0.5, 0.5, 0.5 ], {{alias:@stdlib/utils/constant-function}}( 2.0 ) ) - [ 2.0, 2.0, 2.0 ] - > var arr2 = {{alias}}( arr1, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( iterable[, dtype], clbk[, thisArg] ) - Creates a filled array from an iterable according to a provided callback - function. - - Parameters - ---------- - iterable: Iterable - Iterable from which to generate an array. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias:@stdlib/iter/constant}}( 3.0, {'iter': 3} ); - > var arr2 = {{alias}}( arr1, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( buffer[, byteOffset[, length]][, dtype], clbk[, thisArg] ) - Returns a filled typed array view of an ArrayBuffer according to a provided - callback function. - - The 'generic' array data type is *not* supported. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( buf, 0, 4, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0, 1.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index bb876ed..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,606 +0,0 @@ -/* -* @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. -*/ - -/// - -import { IterableIterator } from '@stdlib/types/iter'; -import filledarrayBy = require( './index' ); - - -/** -* Returns an iterator protocol-compliant object. -* -* @returns iterator protocol-compliant object -*/ -function iterator(): IterableIterator { - const obj: IterableIterator = { - [Symbol.iterator]: iterator, - 'next': next - }; - return obj; -} - -/** -* Implements the iterator protocol `next` method. -* -* @returns iterator protocol-compliant object -*/ -function next(): any { - return { - 'value': 1.0, - 'done': false - }; -} - -/** -* Callback function. -* -* @param i - current array index -* @returns return value -*/ -function clbk( i: number ): number { - return i; -} - - -// TESTS // - -// The function returns an array or typed array... -{ - filledarrayBy(); // $ExpectType ArrayOrTypedArray - filledarrayBy( 'float32' ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( 10, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( 10, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( 10, 'int32', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( 10, 'int32', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const x = new Float64Array( 10 ); - filledarrayBy( x, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( x, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( x, 'uint8', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( x, 'uint8', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const y = [ 2.0, 2.0, 2.0 ]; - filledarrayBy( y, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( y, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( y, 'float64', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( y, 'float64', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const it = iterator(); - filledarrayBy( it, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( it, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( it, 'uint8c', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( it, 'uint8c', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const buf = new ArrayBuffer( 32 ); - filledarrayBy( buf, clbk ); // $ExpectType RealOrComplexTypedArray | BooleanArray - filledarrayBy( buf, clbk, {} ); // $ExpectType RealOrComplexTypedArray | BooleanArray - - filledarrayBy( buf, 'uint32', clbk ); // $ExpectType RealOrComplexTypedArray | BooleanArray - filledarrayBy( buf, 'uint32', clbk, {} ); // $ExpectType RealOrComplexTypedArray | BooleanArray - - filledarrayBy( buf, 8, clbk ); // $ExpectType RealOrComplexTypedArray | BooleanArray - filledarrayBy( buf, 8, clbk, {} ); // $ExpectType RealOrComplexTypedArray | BooleanArray - - filledarrayBy( buf, 8, 'uint16', clbk ); // $ExpectType RealOrComplexTypedArray | BooleanArray - filledarrayBy( buf, 8, 'uint16', clbk, {} ); // $ExpectType RealOrComplexTypedArray | BooleanArray - - filledarrayBy( buf, 8, 2, clbk ); // $ExpectType RealOrComplexTypedArray | BooleanArray - filledarrayBy( buf, 8, 2, clbk, {} ); // $ExpectType RealOrComplexTypedArray | BooleanArray - - filledarrayBy( buf, 8, 2, 'int16', clbk ); // $ExpectType RealOrComplexTypedArray | BooleanArray - filledarrayBy( buf, 8, 2, 'int16', clbk, {} ); // $ExpectType RealOrComplexTypedArray | BooleanArray -} - -// The compiler throws an error if a callback function argument is not a function... -{ - filledarrayBy( 'float64', '5' ); // $ExpectError - filledarrayBy( 'float64', 1.0 ); // $ExpectError - filledarrayBy( 'float64', false ); // $ExpectError - filledarrayBy( 'float64', true ); // $ExpectError - filledarrayBy( 'float64', null ); // $ExpectError - filledarrayBy( 'float64', undefined ); // $ExpectError - filledarrayBy( 'float64', [] ); // $ExpectError - filledarrayBy( 'float64', {} ); // $ExpectError - - filledarrayBy( 'float64', '5', {} ); // $ExpectError - filledarrayBy( 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( 'float64', false, {} ); // $ExpectError - filledarrayBy( 'float64', true, {} ); // $ExpectError - filledarrayBy( 'float64', null, {} ); // $ExpectError - filledarrayBy( 'float64', undefined, {} ); // $ExpectError - filledarrayBy( 'float64', [], {} ); // $ExpectError - filledarrayBy( 'float64', {}, {} ); // $ExpectError - - filledarrayBy( 10, '5' ); // $ExpectError - filledarrayBy( 10, 1.0 ); // $ExpectError - filledarrayBy( 10, false ); // $ExpectError - filledarrayBy( 10, true ); // $ExpectError - filledarrayBy( 10, null ); // $ExpectError - filledarrayBy( 10, undefined ); // $ExpectError - filledarrayBy( 10, [] ); // $ExpectError - filledarrayBy( 10, {} ); // $ExpectError - - filledarrayBy( 10, '5', {} ); // $ExpectError - filledarrayBy( 10, 1.0, {} ); // $ExpectError - filledarrayBy( 10, false, {} ); // $ExpectError - filledarrayBy( 10, true, {} ); // $ExpectError - filledarrayBy( 10, null, {} ); // $ExpectError - filledarrayBy( 10, undefined, {} ); // $ExpectError - filledarrayBy( 10, [], {} ); // $ExpectError - filledarrayBy( 10, {}, {} ); // $ExpectError - - filledarrayBy( 10, 'float64', '5' ); // $ExpectError - filledarrayBy( 10, 'float64', 1.0 ); // $ExpectError - filledarrayBy( 10, 'float64', false ); // $ExpectError - filledarrayBy( 10, 'float64', true ); // $ExpectError - filledarrayBy( 10, 'float64', null ); // $ExpectError - filledarrayBy( 10, 'float64', undefined ); // $ExpectError - filledarrayBy( 10, 'float64', [] ); // $ExpectError - filledarrayBy( 10, 'float64', {} ); // $ExpectError - - filledarrayBy( 10, 'float64', '5', {} ); // $ExpectError - filledarrayBy( 10, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( 10, 'float64', false, {} ); // $ExpectError - filledarrayBy( 10, 'float64', true, {} ); // $ExpectError - filledarrayBy( 10, 'float64', null, {} ); // $ExpectError - filledarrayBy( 10, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( 10, 'float64', [], {} ); // $ExpectError - filledarrayBy( 10, 'float64', {}, {} ); // $ExpectError - - const x = new Float64Array( 10 ); - filledarrayBy( x, '5' ); // $ExpectError - filledarrayBy( x, 1.0 ); // $ExpectError - filledarrayBy( x, false ); // $ExpectError - filledarrayBy( x, true ); // $ExpectError - filledarrayBy( x, null ); // $ExpectError - filledarrayBy( x, undefined ); // $ExpectError - filledarrayBy( x, [] ); // $ExpectError - filledarrayBy( x, {} ); // $ExpectError - - filledarrayBy( x, '5', {} ); // $ExpectError - filledarrayBy( x, 1.0, {} ); // $ExpectError - filledarrayBy( x, false, {} ); // $ExpectError - filledarrayBy( x, true, {} ); // $ExpectError - filledarrayBy( x, null, {} ); // $ExpectError - filledarrayBy( x, undefined, {} ); // $ExpectError - filledarrayBy( x, [], {} ); // $ExpectError - filledarrayBy( x, {}, {} ); // $ExpectError - - filledarrayBy( x, 'float64', '5' ); // $ExpectError - filledarrayBy( x, 'float64', 1.0 ); // $ExpectError - filledarrayBy( x, 'float64', false ); // $ExpectError - filledarrayBy( x, 'float64', true ); // $ExpectError - filledarrayBy( x, 'float64', null ); // $ExpectError - filledarrayBy( x, 'float64', undefined ); // $ExpectError - filledarrayBy( x, 'float64', [] ); // $ExpectError - filledarrayBy( x, 'float64', {} ); // $ExpectError - - filledarrayBy( x, 'float64', '5', {} ); // $ExpectError - filledarrayBy( x, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( x, 'float64', false, {} ); // $ExpectError - filledarrayBy( x, 'float64', true, {} ); // $ExpectError - filledarrayBy( x, 'float64', null, {} ); // $ExpectError - filledarrayBy( x, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( x, 'float64', [], {} ); // $ExpectError - filledarrayBy( x, 'float64', {}, {} ); // $ExpectError - - const y = [ 2.0, 2.0, 2.0 ]; - filledarrayBy( y, '5' ); // $ExpectError - filledarrayBy( y, 1.0 ); // $ExpectError - filledarrayBy( y, false ); // $ExpectError - filledarrayBy( y, true ); // $ExpectError - filledarrayBy( y, null ); // $ExpectError - filledarrayBy( y, undefined ); // $ExpectError - filledarrayBy( y, [] ); // $ExpectError - filledarrayBy( y, {} ); // $ExpectError - - filledarrayBy( y, '5', {} ); // $ExpectError - filledarrayBy( y, 1.0, {} ); // $ExpectError - filledarrayBy( y, false, {} ); // $ExpectError - filledarrayBy( y, true, {} ); // $ExpectError - filledarrayBy( y, null, {} ); // $ExpectError - filledarrayBy( y, undefined, {} ); // $ExpectError - filledarrayBy( y, [], {} ); // $ExpectError - filledarrayBy( y, {}, {} ); // $ExpectError - - filledarrayBy( y, 'float64', '5' ); // $ExpectError - filledarrayBy( y, 'float64', 1.0 ); // $ExpectError - filledarrayBy( y, 'float64', false ); // $ExpectError - filledarrayBy( y, 'float64', true ); // $ExpectError - filledarrayBy( y, 'float64', null ); // $ExpectError - filledarrayBy( y, 'float64', undefined ); // $ExpectError - filledarrayBy( y, 'float64', [] ); // $ExpectError - filledarrayBy( y, 'float64', {} ); // $ExpectError - - filledarrayBy( y, 'float64', '5', {} ); // $ExpectError - filledarrayBy( y, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( y, 'float64', false, {} ); // $ExpectError - filledarrayBy( y, 'float64', true, {} ); // $ExpectError - filledarrayBy( y, 'float64', null, {} ); // $ExpectError - filledarrayBy( y, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( y, 'float64', [], {} ); // $ExpectError - filledarrayBy( y, 'float64', {}, {} ); // $ExpectError - - const it = iterator(); - filledarrayBy( it, '5' ); // $ExpectError - filledarrayBy( it, 1.0 ); // $ExpectError - filledarrayBy( it, false ); // $ExpectError - filledarrayBy( it, true ); // $ExpectError - filledarrayBy( it, null ); // $ExpectError - filledarrayBy( it, undefined ); // $ExpectError - filledarrayBy( it, [] ); // $ExpectError - filledarrayBy( it, {} ); // $ExpectError - - filledarrayBy( it, '5', {} ); // $ExpectError - filledarrayBy( it, 1.0, {} ); // $ExpectError - filledarrayBy( it, false, {} ); // $ExpectError - filledarrayBy( it, true, {} ); // $ExpectError - filledarrayBy( it, null, {} ); // $ExpectError - filledarrayBy( it, undefined, {} ); // $ExpectError - filledarrayBy( it, [], {} ); // $ExpectError - filledarrayBy( it, {}, {} ); // $ExpectError - - filledarrayBy( it, 'float64', '5' ); // $ExpectError - filledarrayBy( it, 'float64', 1.0 ); // $ExpectError - filledarrayBy( it, 'float64', false ); // $ExpectError - filledarrayBy( it, 'float64', true ); // $ExpectError - filledarrayBy( it, 'float64', null ); // $ExpectError - filledarrayBy( it, 'float64', undefined ); // $ExpectError - filledarrayBy( it, 'float64', [] ); // $ExpectError - filledarrayBy( it, 'float64', {} ); // $ExpectError - - filledarrayBy( it, 'float64', '5', {} ); // $ExpectError - filledarrayBy( it, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( it, 'float64', false, {} ); // $ExpectError - filledarrayBy( it, 'float64', true, {} ); // $ExpectError - filledarrayBy( it, 'float64', null, {} ); // $ExpectError - filledarrayBy( it, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( it, 'float64', [], {} ); // $ExpectError - filledarrayBy( it, 'float64', {}, {} ); // $ExpectError - - const buf = new ArrayBuffer( 32 ); - filledarrayBy( buf, '5' ); // $ExpectError - filledarrayBy( buf, 1.0 ); // $ExpectError - filledarrayBy( buf, false ); // $ExpectError - filledarrayBy( buf, true ); // $ExpectError - filledarrayBy( buf, null ); // $ExpectError - filledarrayBy( buf, undefined ); // $ExpectError - filledarrayBy( buf, [] ); // $ExpectError - filledarrayBy( buf, {} ); // $ExpectError - - filledarrayBy( buf, '5', {} ); // $ExpectError - filledarrayBy( buf, 1.0, {} ); // $ExpectError - filledarrayBy( buf, false, {} ); // $ExpectError - filledarrayBy( buf, true, {} ); // $ExpectError - filledarrayBy( buf, null, {} ); // $ExpectError - filledarrayBy( buf, undefined, {} ); // $ExpectError - filledarrayBy( buf, [], {} ); // $ExpectError - filledarrayBy( buf, {}, {} ); // $ExpectError - - filledarrayBy( buf, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 'float64', false ); // $ExpectError - filledarrayBy( buf, 'float64', true ); // $ExpectError - filledarrayBy( buf, 'float64', null ); // $ExpectError - filledarrayBy( buf, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 'float64', {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5' ); // $ExpectError - filledarrayBy( buf, 8, 1.0 ); // $ExpectError - filledarrayBy( buf, 8, false ); // $ExpectError - filledarrayBy( buf, 8, true ); // $ExpectError - filledarrayBy( buf, 8, null ); // $ExpectError - filledarrayBy( buf, 8, undefined ); // $ExpectError - filledarrayBy( buf, 8, [] ); // $ExpectError - filledarrayBy( buf, 8, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, false, {} ); // $ExpectError - filledarrayBy( buf, 8, true, {} ); // $ExpectError - filledarrayBy( buf, 8, null, {} ); // $ExpectError - filledarrayBy( buf, 8, undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, [], {} ); // $ExpectError - filledarrayBy( buf, 8, {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 8, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 'float64', false ); // $ExpectError - filledarrayBy( buf, 8, 'float64', true ); // $ExpectError - filledarrayBy( buf, 8, 'float64', null ); // $ExpectError - filledarrayBy( buf, 8, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 8, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 8, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 8, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, '5' ); // $ExpectError - filledarrayBy( buf, 8, 2, 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 2, false ); // $ExpectError - filledarrayBy( buf, 8, 2, true ); // $ExpectError - filledarrayBy( buf, 8, 2, null ); // $ExpectError - filledarrayBy( buf, 8, 2, undefined ); // $ExpectError - filledarrayBy( buf, 8, 2, [] ); // $ExpectError - filledarrayBy( buf, 8, 2, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, false, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, true, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, null, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, [], {} ); // $ExpectError - filledarrayBy( buf, 8, 2, {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', false ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', true ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', null ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', {}, {} ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid length, typed array, array-like object, `ArrayBuffer`, or iterable argument... -{ - filledarrayBy( false, clbk ); // $ExpectError - filledarrayBy( true, clbk ); // $ExpectError - filledarrayBy( null, clbk ); // $ExpectError - filledarrayBy( {}, clbk ); // $ExpectError - - filledarrayBy( false, clbk, {} ); // $ExpectError - filledarrayBy( true, clbk, {} ); // $ExpectError - filledarrayBy( null, clbk, {} ); // $ExpectError - filledarrayBy( {}, clbk, {} ); // $ExpectError - - filledarrayBy( false, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 'float64', clbk ); // $ExpectError - - filledarrayBy( false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, clbk ); // $ExpectError - filledarrayBy( 1.0, 8, clbk ); // $ExpectError - filledarrayBy( false, 8, clbk ); // $ExpectError - filledarrayBy( true, 8, clbk ); // $ExpectError - filledarrayBy( null, 8, clbk ); // $ExpectError - filledarrayBy( undefined, 8, clbk ); // $ExpectError - filledarrayBy( [], 8, clbk ); // $ExpectError - filledarrayBy( {}, 8, clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, clbk ); // $ExpectError - - filledarrayBy( '5', 8, clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, clbk, {} ); // $ExpectError - filledarrayBy( false, 8, clbk, {} ); // $ExpectError - filledarrayBy( true, 8, clbk, {} ); // $ExpectError - filledarrayBy( null, 8, clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, clbk, {} ); // $ExpectError - filledarrayBy( [], 8, clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 'float64', clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( false, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( [], 8, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 'float64', clbk ); // $ExpectError - - filledarrayBy( '5', 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 2, clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 2, clbk ); // $ExpectError - filledarrayBy( false, 8, 2, clbk ); // $ExpectError - filledarrayBy( true, 8, 2, clbk ); // $ExpectError - filledarrayBy( null, 8, 2, clbk ); // $ExpectError - filledarrayBy( undefined, 8, 2, clbk ); // $ExpectError - filledarrayBy( [], 8, 2, clbk ); // $ExpectError - filledarrayBy( {}, 8, 2, clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, clbk ); // $ExpectError - - filledarrayBy( '5', 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( false, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( [], 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, 'float64', clbk ); // $ExpectError - - filledarrayBy( '5', 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a byte offset argument which is not a number... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, false, clbk ); // $ExpectError - filledarrayBy( buf, true, clbk ); // $ExpectError - filledarrayBy( buf, null, clbk ); // $ExpectError - filledarrayBy( buf, [], clbk ); // $ExpectError - filledarrayBy( buf, {}, clbk ); // $ExpectError - - filledarrayBy( buf, false, clbk, {} ); // $ExpectError - filledarrayBy( buf, true, clbk, {} ); // $ExpectError - filledarrayBy( buf, null, clbk, {} ); // $ExpectError - filledarrayBy( buf, [], clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, clbk, {} ); // $ExpectError - - filledarrayBy( buf, '5', 'float64', clbk ); // $ExpectError - filledarrayBy( buf, false, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, true, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, null, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, [], 'float64', clbk ); // $ExpectError - filledarrayBy( buf, {}, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, '5', 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( buf, false, 2, clbk ); // $ExpectError - filledarrayBy( buf, true, 2, clbk ); // $ExpectError - filledarrayBy( buf, null, 2, clbk ); // $ExpectError - filledarrayBy( buf, [], 2, clbk ); // $ExpectError - filledarrayBy( buf, {}, 2, clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, clbk ); // $ExpectError - - filledarrayBy( buf, false, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, clbk, {} ); // $ExpectError - - filledarrayBy( buf, '5', 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, false, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, true, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, null, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, undefined, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, [], 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, {}, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, '5', 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, false, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, undefined, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a view length argument which is not a number... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, 8, false, clbk ); // $ExpectError - filledarrayBy( buf, 8, true, clbk ); // $ExpectError - filledarrayBy( buf, 8, null, clbk ); // $ExpectError - filledarrayBy( buf, 8, [], clbk ); // $ExpectError - filledarrayBy( buf, 8, {}, clbk ); // $ExpectError - - filledarrayBy( buf, 8, false, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, true, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, null, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, [], clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, {}, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, clbk, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5', 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, false, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, true, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, null, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, [], 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, {}, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, 8, '5', 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, [], 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, {}, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided too many arguments... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, 8, 2, 'float64', 1, clbk, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 997a381..0000000 --- a/examples/index.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ).factory; -var dtypes = require( '@stdlib/array-typed-real-dtypes' ); -var filledarrayBy = require( './../lib' ); - -// Create a pseudorandom number generator: -var rand = discreteUniform( 0, 100 ); - -// Get a list of array data types: -var dt = dtypes(); - -// Generate filled arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = filledarrayBy( 10, dt[ i ], rand ); - console.log( arr ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 764e40e..cb63cd1 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, RealOrComplexTypedArray, BooleanArray, DataType } from '@stdlib/types/array'; import { IterableIterator } from '@stdlib/types/iter'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..668c2f7 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@v0.0.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-ctors@v0.3.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill-by@v0.2.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled-by@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@v0.2.2-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.3.0-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";var v=f(),g=j.get("dtypes.default");function c(){var f,j,c,b,y,x,u,E;if(0===(j=arguments.length))return new(y=d(g))(0);if(r(c=arguments[0])){if(j>1)throw new TypeError(w("00h05"));if(null===(y=d(c)))throw new TypeError(w("00h2Y",c));return new y(0)}if(j<2)throw new TypeError(w("00h05"));if(h(arguments[j-=1]))if(h(arguments[j-1])){if(f=arguments[j],b=arguments[j-=1],0===j)throw new TypeError(w("00h05"))}else b=arguments[j];else{if(!(j>=2))throw new TypeError(w("00h05"));if(f=arguments[j],!h(b=arguments[j-=1]))throw new TypeError(w("00h2b",b))}if((j-=1)>=0&&r(arguments[j])?(c=arguments[j],j-=1):c=g,null===(y=d(c)))throw new TypeError(w("00h2Y",c));if("generic"===c){if(E=arguments[0],0===j){if(e(E)?u=E:i(E)&&(u=E.length),void 0!==u)return m(u,b,f);if(n(E))throw new Error(w("00h04"));if(o(E)){if(!1===v)throw new TypeError(w("00h2Z",E));if(!h(E[p]))throw new TypeError(w("00h2a",E));if(E=E[p](),!h(E.next))throw new TypeError(w("00h2a",E));return function(r,e,t){var s,i;for(s=[],i=-1;!r.next().done;)i+=1,s.push(e.call(t,i));return s}(E,b,f)}throw new TypeError(w("00h2a",E))}if(n(E))throw new Error(w("00h04"));throw new TypeError(w("00h2a",E))}if(0===j)if(i(E=arguments[0]))x=new y(E.length);else if(n(E))x=new y(E);else if(e(E))x=new y(E);else{if(!o(E))throw new TypeError(w("00h2a",E));if(!1===v)throw new TypeError(w("00h2Z",E));if(!h(E[p]))throw new TypeError(w("00h2a",E));if(E=E[p](),!h(E.next))throw new TypeError(w("00h2a",E));x=new y(a(E))}else x=1===j?new y(arguments[0],arguments[1]):new y(arguments[0],arguments[1],arguments[2]);return x.length>0&&(t(c)||s(c)?function(r,e,t){var s;for(s=0;s\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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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( format('00h05') );\n\t\t}\n\t\tctor = ctors( dtype );\n\t\tif ( ctor === null ) {\n\t\t\tthrow new TypeError( format( '00h2Y', 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( format('00h05') );\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( format('00h05') );\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( '00h2b', 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( format('00h05') );\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( '00h2Y', 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( format('00h04') );\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( '00h2Z', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00h2a', 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( '00h2a', 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( '00h2a', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format('00h04') );\n\t\t}\n\t\tthrow new TypeError( format( '00h2a', 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( '00h2Z', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00h2a', 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( '00h2a', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00h2a', 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\nexport default filledarrayBy;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","DEFAULT_DTYPE","defaults","get","filledarrayBy","thisArg","nargs","dtype","clbk","ctor","arr","len","arg","arguments","length","ctors","isString","TypeError","format","isFunction","isNonNegativeInteger","isCollection","filledArray","isArrayBuffer","Error","isObject","ITERATOR_SYMBOL","next","it","i","done","push","call","filledArrayIterator","iterLength","isComplexDataType","isBooleanDataType","set","filledAccessors","gfillBy","value","aidx"],"mappings":";;sjDA0CA,IAAIA,EAAsBC,IACtBC,EAAgBC,EAASC,IAAK,kBA2MlC,SAASC,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAKJ,GAAe,KAHfN,EAAQO,UAAUC,QAKjB,OAAO,IADPL,EAAOM,EAAOd,IACG,GAIlB,GAAKe,EADLT,EAAQM,UAAW,IACM,CAExB,GAAKP,EAAQ,EACZ,MAAM,IAAIW,UAAWC,EAAO,UAG7B,GAAc,QADdT,EAAOM,EAAOR,IAEb,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,OAAO,IAAIE,EAAM,EACjB,CAED,GAAKH,EAAQ,EACZ,MAAM,IAAIW,UAAWC,EAAO,UAM7B,GAAKC,EAAYN,UAHjBP,GAAS,IAKR,GAAKa,EAAYN,UAAWP,EAAM,KAMjC,GALAD,EAAUQ,UAAWP,GAErBE,EAAOK,UADPP,GAAS,GAIM,IAAVA,EACJ,MAAM,IAAIW,UAAWC,EAAO,eAI7BV,EAAOK,UAAWP,OAIf,MAAKA,GAAS,GAUlB,MAAM,IAAIW,UAAWC,EAAO,UAN5B,GAHAb,EAAUQ,UAAWP,IAGfa,EADNX,EAAOK,UADPP,GAAS,IAGR,MAAM,IAAIW,UAAWC,EAAQ,QAASV,GAMvC,CAUD,IARAF,GAAS,IACK,GAAKU,EAAUH,UAAWP,KACvCC,EAAQM,UAAWP,GACnBA,GAAS,GAETC,EAAQN,EAGK,QADdQ,EAAOM,EAAOR,IAEb,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,GAAe,YAAVA,EAAsB,CAE1B,GADAK,EAAMC,UAAW,GACF,IAAVP,EAAc,CAMlB,GALKc,EAAsBR,GAC1BD,EAAMC,EACKS,EAAcT,KACzBD,EAAMC,EAAIE,aAEE,IAARH,EACJ,OAAOW,EAAaX,EAAKH,EAAMH,GAEhC,GAAKkB,EAAeX,GACnB,MAAM,IAAIY,MAAON,EAAO,UAEzB,GAAKO,EAAUb,GAAQ,CACtB,IAA6B,IAAxBb,EACJ,MAAM,IAAIkB,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAYP,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLP,EAAYP,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvC,OAvSJ,SAA8BgB,EAAIpB,EAAMH,GACvC,IAAIK,EACAmB,EAKJ,IAFAnB,EAAM,GACNmB,GAAK,GAEAD,EAAGD,OACAG,MAGPD,GAAK,EACLnB,EAAIqB,KAAMvB,EAAKwB,KAAM3B,EAASwB,IAE/B,OAAOnB,CACR,CAuRWuB,CAAqBrB,EAAKJ,EAAMH,EACvC,CACD,MAAM,IAAIY,UAAWC,EAAQ,QAASN,GACzC,CAAS,GAAKW,EAAeX,GAC1B,MAAM,IAAIY,MAAON,EAAO,UAEzB,MAAM,IAAID,UAAWC,EAAQ,QAASN,GACtC,CACD,GAAe,IAAVN,EAEJ,GAAKe,EADLT,EAAMC,UAAW,IAEhBH,EAAM,IAAID,EAAMG,EAAIE,aACd,GAAKS,EAAeX,GAC1BF,EAAM,IAAID,EAAMG,QACV,GAAKQ,EAAsBR,GACjCF,EAAM,IAAID,EAAMG,OACV,KAAKa,EAAUb,GAarB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAZtC,IAA6B,IAAxBb,EACJ,MAAM,IAAIkB,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAYP,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLP,EAAYP,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvCF,EAAM,IAAID,EAAMyB,EAAYtB,GAG5B,MAEDF,EADqB,IAAVJ,EACL,IAAIG,EAAMI,UAAU,GAAIA,UAAU,IAElC,IAAIJ,EAAMI,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKH,EAAII,OAAS,IACZqB,EAAmB5B,IAAW6B,EAAmB7B,GAjTxD,SAA0BG,EAAKF,EAAMH,GACpC,IAAIwB,EACJ,IAAMA,EAAI,EAAGA,EAAInB,EAAII,OAAQe,IAC5BnB,EAAI2B,IAAK7B,EAAKwB,KAAM3B,EAASwB,GAAKA,EAGpC,CA4SGS,CAAiB5B,EAAKF,EAAMH,GAE5BkC,EAAS7B,EAAII,OAAQJ,EAAK,GAe5B,SAAmB8B,EAAOC,GACzB,OAAOjC,EAAKwB,KAAM3B,EAASoC,EAC3B,KAdM/B,CAeR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d115cf0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,192 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -/** -* Create a filled array according to a provided callback function. -* -* @module @stdlib/array-filled-by -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* var arr = filledarrayBy(); -* // returns -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'generic', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( [ 0.5, 0.5 ], clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1; -* } -* -* var arr = filledarrayBy( [ 5, -3 ], 'int32', clbk ); -* // returns [ 1, 1 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk1() { -* return 10; -* } -* -* function clbk2() { -* return 1.0; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, clbk2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk1() { -* return 1.0; -* } -* -* function clbk2() { -* return 2; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, 'uint32', clbk2 ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 'float32', clbk ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, clbk ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, 'int32', clbk ); -* // returns [ 1, 1 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index ed1aa9a..0000000 --- a/lib/main.js +++ /dev/null @@ -1,416 +0,0 @@ -/** -* @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 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' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var ctors = require( '@stdlib/array-ctors' ); -var gfillBy = require( '@stdlib/blas-ext-base-gfill-by' ); -var filledArray = require( '@stdlib/array-base-filled-by' ); -var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var iterLength = require( '@stdlib/iter-length' ); -var defaults = require( '@stdlib/array-defaults' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport(); -var DEFAULT_DTYPE = defaults.get( 'dtypes.default' ); - - -// FUNCTIONS // - -/** -* Creates a filled "generic" array from an iterator. -* -* @private -* @param {Iterable} it - iterator -* @param {Callback} clbk - callback function -* @param {*} thisArg - callback function execution context -* @returns {Array} filled array -*/ -function filledArrayIterator( it, clbk, thisArg ) { - var arr; - var i; - var v; - - arr = []; - i = -1; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - i += 1; - arr.push( clbk.call( thisArg, i ) ); - } - return arr; -} - -/** -* Fills an array exposing accessors for getting and setting array elements. -* -* @private -* @param {Collection} arr - input array -* @param {Callback} clbk - callback function -* @param {*} thisArg - callback function execution context -* @returns {Collection} input array -*/ -function filledAccessors( arr, clbk, thisArg ) { - var i; - for ( i = 0; i < arr.length; i++ ) { - arr.set( clbk.call( thisArg, i ), i ); - } - return arr; -} - - -// MAIN // - -/** -* Creates a filled array according to a provided callback function. -* -* @param {(NonNegativeInteger|TypedArray|ArrayLikeObject|ArrayBuffer|Iterable)} [arg] - a length, typed array, array-like object, buffer, or iterable -* @param {NonNegativeInteger} [byteOffset=0] - byte offset -* @param {NonNegativeInteger} [length] - view length -* @param {string} [dtype="float64"] - data type -* @param {Callback} [clbk] - callback to invoke -* @param {*} [thisArg] - callback execution context -* @throws {TypeError} must provide a recognized data type -* @throws {TypeError} must provide a length, typed array, array-like object, buffer, or iterable -* @throws {TypeError} callback argument must be a function. -* @throws {Error} creating a generic array from an `ArrayBuffer` is not supported -* @returns {(TypedArray|Array)} array or typed array -* -* @example -* var arr = filledarrayBy(); -* // returns -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'generic', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( [ 0.5, 0.5 ], clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1; -* } -* -* var arr = filledarrayBy( [ 5, -3 ], 'int32', clbk ); -* // returns [ 1, 1 ] -* -* @example -* function clbk1() { -* return 10; -* } -* -* function clbk2() { -* return 1.0; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, clbk2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk1() { -* return 1.0; -* } -* -* function clbk2() { -* return 2; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, 'uint32', clbk2 ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 'float32', clbk ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, clbk ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, 'int32', clbk ); -* // returns [ 1, 1 ] -*/ -function filledarrayBy() { - var thisArg; - var nargs; - var dtype; - var clbk; - var ctor; - var arr; - var len; - var arg; - - nargs = arguments.length; - - // If we weren't provided any arguments, return an empty array... - if ( nargs === 0 ) { - ctor = ctors( DEFAULT_DTYPE ); - return new ctor( 0 ); - } - // Check if we were provided a dtype as the first argument... - dtype = arguments[ 0 ]; - if ( isString( dtype ) ) { - // Invoking this function with arguments `f( dtype, clbk[, thisArg] )` is not allowed (otherwise, we'd need to also allow `f( clbk[, thisArg] )`)... - if ( nargs > 1 ) { - throw new TypeError( format('00h05') ); - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '00h2Y', dtype ) ); - } - // Return an empty array having the specified dtype: - return new ctor( 0 ); - } - // For all other supported invocations, we need at least two arguments... - if ( nargs < 2 ) { - throw new TypeError( format('00h05') ); - } - // At this point, we need to do some argument juggling... - nargs -= 1; // henceforth, the number of available arguments is `nargs+1` - - // Determine whether the last argument is a callback or "this" context... - if ( isFunction( arguments[ nargs ] ) ) { - // 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... - if ( isFunction( arguments[ nargs-1 ] ) ) { - thisArg = arguments[ nargs ]; - nargs -= 1; - clbk = arguments[ nargs ]; - - // Check if we were provided only a callback and a "this" context.. - if ( nargs === 0 ) { - throw new TypeError( format('00h05') ); - } - } else { - // "this" context is left undefined... - clbk = arguments[ nargs ]; - } - } - // 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... - else if ( nargs >= 2 ) { - thisArg = arguments[ nargs ]; - nargs -= 1; - clbk = arguments[ nargs ]; - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '00h2b', clbk ) ); - } - } - // If were were only provided 2 arguments and the last argument was not a function, we've been provided an insufficient number of arguments... - else { - throw new TypeError( format('00h05') ); - } - // Now that we've processed the callback arguments, let's continue working backward to see if we've been provided a `dtype` argument... - nargs -= 1; - if ( nargs >= 0 && isString( arguments[ nargs ] ) ) { - dtype = arguments[ nargs ]; - nargs -= 1; - } else { - dtype = DEFAULT_DTYPE; - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '00h2Y', dtype ) ); - } - // At this point, we've resolved the output array data type, and now we can actually create the output array... - if ( dtype === 'generic' ) { - arg = arguments[ 0 ]; - if ( nargs === 0 ) { - if ( isNonNegativeInteger( arg ) ) { - len = arg; - } else if ( isCollection( arg ) ) { - len = arg.length; - } - if ( len !== void 0 ) { - return filledArray( len, clbk, thisArg ); - } - if ( isArrayBuffer( arg ) ) { - throw new Error( format('00h04') ); - } - if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( '00h2Z', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00h2a', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00h2a', arg ) ); - } - return filledArrayIterator( arg, clbk, thisArg ); - } - throw new TypeError( format( '00h2a', arg ) ); - } else if ( isArrayBuffer( arg ) ) { - throw new Error( format('00h04') ); - } - throw new TypeError( format( '00h2a', arg ) ); - } - if ( nargs === 0 ) { // length || array-like || ArrayBuffer || iterable - arg = arguments[ 0 ]; - if ( isCollection( arg ) ) { - arr = new ctor( arg.length ); - } else if ( isArrayBuffer( arg ) ) { - arr = new ctor( arg ); - } else if ( isNonNegativeInteger( arg ) ) { - arr = new ctor( arg ); - } else if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( '00h2Z', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00h2a', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00h2a', arg ) ); - } - arr = new ctor( iterLength( arg ) ); - } else { - throw new TypeError( format( '00h2a', arg ) ); - } - } else if ( nargs === 1 ) { - arr = new ctor( arguments[0], arguments[1] ); // (ArrayBuffer, byteOffset) - } else { - arr = new ctor( arguments[0], arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset, length) - } - if ( arr.length > 0 ) { - if ( isComplexDataType( dtype ) || isBooleanDataType( dtype ) ) { - filledAccessors( arr, clbk, thisArg ); - } else { - gfillBy( arr.length, arr, 1, callback ); - } - } - return arr; - - /** - * Callback which wraps a provided callback and is invoked for each array element. - * - * @private - * @param {*} value - element value - * @param {NonNegativeInteger} aidx - array index - * @param {NonNegativeInteger} sidx - strided index - * @param {Collection} array - input array/collection - * @returns {*} callback return value - */ - function callback( value, aidx ) { - return clbk.call( thisArg, aidx ); - } -} - - -// EXPORTS // - -module.exports = filledarrayBy; diff --git a/package.json b/package.json index b5ac3ab..b16be36 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Create a filled array according to a provided callback function.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,75 +13,6 @@ "bugs": { "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.2", - "@stdlib/array-ctors": "^0.3.0", - "@stdlib/array-defaults": "^0.3.0", - "@stdlib/assert-has-iterator-symbol-support": "^0.2.2", - "@stdlib/assert-is-arraybuffer": "^0.2.2", - "@stdlib/assert-is-collection": "^0.2.2", - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer": "^0.2.2", - "@stdlib/assert-is-object": "^0.2.2", - "@stdlib/assert-is-string": "^0.2.2", - "@stdlib/blas-ext-base-gfill-by": "^0.2.1", - "@stdlib/iter-length": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/symbol-iterator": "^0.2.2", - "@stdlib/types": "^0.4.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-bool": "^0.1.0", - "@stdlib/array-buffer": "^0.2.2", - "@stdlib/array-complex128": "^0.3.0", - "@stdlib/array-complex64": "^0.3.0", - "@stdlib/array-float32": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/array-int16": "^0.2.2", - "@stdlib/array-int32": "^0.2.2", - "@stdlib/array-int8": "^0.2.2", - "@stdlib/array-typed-real-dtypes": "^0.2.2", - "@stdlib/array-uint16": "^0.2.2", - "@stdlib/array-uint32": "^0.2.2", - "@stdlib/array-uint8": "^0.2.2", - "@stdlib/array-uint8c": "^0.2.2", - "@stdlib/assert-instance-of": "^0.2.2", - "@stdlib/assert-is-array": "^0.2.2", - "@stdlib/assert-is-typed-array": "^0.2.2", - "@stdlib/assert-is-typed-array-like": "^0.2.2", - "@stdlib/complex-float32-ctor": "^0.0.2", - "@stdlib/complex-float64-ctor": "^0.0.3", - "@stdlib/iter-constant": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/random-base-discrete-uniform": "^0.2.1", - "@stdlib/strided-base-reinterpret-boolean": "^0.0.2", - "@stdlib/strided-base-reinterpret-complex128": "^0.2.2", - "@stdlib/strided-base-reinterpret-complex64": "^0.2.1", - "@stdlib/utils-constant-function": "^0.2.2", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..e4cee9c --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index ca0cf25..0000000 --- a/test/test.js +++ /dev/null @@ -1,4397 +0,0 @@ -/** -* @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. -*/ - -/* eslint-disable max-len */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -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' ); -var iterConstant = require( '@stdlib/iter-constant' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var filledarrayBy = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': !hasIteratorSymbolSupport() -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof filledarrayBy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if only provided callback arguments', function test( t ) { - t.throws( clbk1, TypeError, 'throws an error' ); - t.throws( clbk2, TypeError, 'throws an error' ); - t.throws( clbk3, TypeError, 'throws an error' ); - t.end(); - - function clbk1() { - filledarrayBy( constantFunction( 1.0 ) ); - } - - function clbk2() { - filledarrayBy( constantFunction( 1.0 ), {} ); - } - - function clbk3() { - filledarrayBy( constantFunction( 1.0 ), constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (only argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (typed array; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (array-like object)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (array-like object; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 8 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 8 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, 1, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (iterator)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( iterConstant( 1.0 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (iterator; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( iterConstant( 1.0 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if only provided data type and callback arguments', function test( t ) { - t.throws( clbk1, TypeError, 'throws an error' ); - t.throws( clbk2, TypeError, 'throws an error' ); - t.throws( clbk3, TypeError, 'throws an error' ); - t.end(); - - function clbk1() { - filledarrayBy( 'float64', constantFunction( 1.0 ) ); - } - - function clbk2() { - filledarrayBy( 'float64', constantFunction( 1.0 ), {} ); - } - - function clbk3() { - filledarrayBy( 'float64', constantFunction( 1.0 ), constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (array-like object)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (array-like object; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, 1, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, 1, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (no iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (no iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (non-function iterator symbol property)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (non-function iterator symbol property; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (`next` property is not a function)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ) ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (`next` property is not a function; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ), {} ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (no iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (no iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (non-function iterator symbol property)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (non-function iterator symbol property; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (`next` property is not a function)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ) ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (`next` property is not a function; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ), {} ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 1, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 1, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function returns a filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - arr = filledarrayBy(); - - t.strictEqual( instanceOf( arr, Float64Array ), 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=float64)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - arr = filledarrayBy( 'float64' ); - - t.strictEqual( instanceOf( arr, Float64Array ), 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=float32)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( 0 ); - arr = filledarrayBy( 'float32' ); - - t.strictEqual( instanceOf( arr, Float32Array ), 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=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; - - expected = new Complex128Array( 0 ); - arr = filledarrayBy( 'complex128' ); - - t.strictEqual( instanceOf( arr, Complex128Array ), 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=complex64)', function test( t ) { - var expected; - var arr; - - expected = new Complex64Array( 0 ); - arr = filledarrayBy( 'complex64' ); - - t.strictEqual( instanceOf( arr, Complex64Array ), 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=int32)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( 0 ); - arr = filledarrayBy( 'int32' ); - - t.strictEqual( instanceOf( arr, Int32Array ), 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=uint32)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( 0 ); - arr = filledarrayBy( 'uint32' ); - - t.strictEqual( instanceOf( arr, Uint32Array ), 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=int16)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( 0 ); - arr = filledarrayBy( 'int16' ); - - t.strictEqual( instanceOf( arr, Int16Array ), 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=uint16)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( 0 ); - arr = filledarrayBy( 'uint16' ); - - t.strictEqual( instanceOf( arr, Uint16Array ), 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=int8)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( 0 ); - arr = filledarrayBy( 'int8' ); - - t.strictEqual( instanceOf( arr, Int8Array ), 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=uint8)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( 0 ); - arr = filledarrayBy( 'uint8' ); - - t.strictEqual( instanceOf( arr, Uint8Array ), 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=uint8c)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( 0 ); - arr = filledarrayBy( 'uint8c' ); - - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), 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=generic)', function test( t ) { - var expected; - var arr; - - expected = []; - arr = filledarrayBy( 'generic' ); - - t.strictEqual( instanceOf( arr, Array ), 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 (default, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, length=0)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array(); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 0, clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, clbk, ctx ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (default, length; thisArg=function)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, clbk, context ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this(); // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } - - function context() { - ctx.count += 1; - } -}); - -tape( 'the function returns a filled array (dtype=float64, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, 'float64', clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, length; thisArg=function)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, 'float64', clbk, context ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this(); // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } - - function context() { - ctx.count += 1; - } -}); - -tape( 'the function returns a filled array (dtype=float32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, 'float32', clbk ); - - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - 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; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = filledarrayBy( 5, 'complex128', clbk ); - - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = filledarrayBy( 5, 'complex64', clbk ); - - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int32Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int32', clbk ); - - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint32Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint32', clbk ); - - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int16Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int16', clbk ); - - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint16', clbk ); - - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int8Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int8', clbk ); - - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint8', clbk ); - - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint8c', clbk ); - - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = [ 1, 1, 1, 1, 1 ]; - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'generic', clbk ); - - t.strictEqual( instanceOf( arr, Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - 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; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = [ 1.0, 2.0 ]; - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = [ 1.0, 2.0 ]; - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int32', clbk ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, typed array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, typed array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - 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; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = new Float64Array( [ 1.0, 2.0 ] ); - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = new Float64Array( [ 1.0, 2.0 ] ); - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (default, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - 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; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer, byteoffset; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer, byteoffset; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - 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; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 48 ); - out = filledarrayBy( buf, 16, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 24 ); - out = filledarrayBy( buf, 8, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int32', clbk ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint8c', clbk ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - 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; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 64 ); - out = filledarrayBy( buf, 16, 2, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset, length)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 1, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 1, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled array (default, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, iterator; thisArg)', opts, function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - ctx = { - 'count': 0 - }; - indices = []; - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, iterator; thisArg)', opts, function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - ctx = { - 'count': 0 - }; - indices = []; - out = filledarrayBy( arr, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - 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; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = iterConstant( new Complex128( 3.0, 3.0 ), { - 'iter': 2 - }); - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = iterConstant( new Complex64( 3.0, 3.0 ), { - 'iter': 2 - }); - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); From f3678fb756c6bbd83053f14f5bfe13ff36367d65 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 10 Mar 2025 01:23:24 +0000 Subject: [PATCH 078/117] Transform error messages --- lib/main.js | 38 +++++++++++++++++++------------------- package.json | 2 +- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/lib/main.js b/lib/main.js index b322cfe..ed1aa9a 100644 --- a/lib/main.js +++ b/lib/main.js @@ -35,7 +35,7 @@ var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-supp var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); var iterLength = require( '@stdlib/iter-length' ); var defaults = require( '@stdlib/array-defaults' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -266,18 +266,18 @@ function filledarrayBy() { if ( isString( dtype ) ) { // Invoking this function with arguments `f( dtype, clbk[, thisArg] )` is not allowed (otherwise, we'd need to also allow `f( clbk[, thisArg] )`)... if ( nargs > 1 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format('00h05') ); } ctor = ctors( dtype ); if ( ctor === null ) { - throw new TypeError( format( 'invalid argument. Must provide a recognized data type. Value: `%s`.', dtype ) ); + throw new TypeError( format( '00h2Y', dtype ) ); } // Return an empty array having the specified dtype: return new ctor( 0 ); } // For all other supported invocations, we need at least two arguments... if ( nargs < 2 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format('00h05') ); } // At this point, we need to do some argument juggling... nargs -= 1; // henceforth, the number of available arguments is `nargs+1` @@ -292,7 +292,7 @@ function filledarrayBy() { // Check if we were provided only a callback and a "this" context.. if ( nargs === 0 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format('00h05') ); } } else { // "this" context is left undefined... @@ -305,12 +305,12 @@ function filledarrayBy() { nargs -= 1; clbk = arguments[ nargs ]; if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '00h2b', clbk ) ); } } // If were were only provided 2 arguments and the last argument was not a function, we've been provided an insufficient number of arguments... else { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format('00h05') ); } // Now that we've processed the callback arguments, let's continue working backward to see if we've been provided a `dtype` argument... nargs -= 1; @@ -322,7 +322,7 @@ function filledarrayBy() { } ctor = ctors( dtype ); if ( ctor === null ) { - throw new TypeError( format( 'invalid argument. Must provide a recognized data type. Value: `%s`.', dtype ) ); + throw new TypeError( format( '00h2Y', dtype ) ); } // At this point, we've resolved the output array data type, and now we can actually create the output array... if ( dtype === 'generic' ) { @@ -337,26 +337,26 @@ function filledarrayBy() { return filledArray( len, clbk, thisArg ); } if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format('00h04') ); } if ( isObject( arg ) ) { if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2Z', arg ) ); } if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } arg = arg[ ITERATOR_SYMBOL ](); if ( !isFunction( arg.next ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } return filledArrayIterator( arg, clbk, thisArg ); } - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } else if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format('00h04') ); } - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } if ( nargs === 0 ) { // length || array-like || ArrayBuffer || iterable arg = arguments[ 0 ]; @@ -368,18 +368,18 @@ function filledarrayBy() { arr = new ctor( arg ); } else if ( isObject( arg ) ) { if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2Z', arg ) ); } if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } arg = arg[ ITERATOR_SYMBOL ](); if ( !isFunction( arg.next ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } arr = new ctor( iterLength( arg ) ); } else { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } } else if ( nargs === 1 ) { arr = new ctor( arguments[0], arguments[1] ); // (ArrayBuffer, byteOffset) diff --git a/package.json b/package.json index 42e92b1..b5ac3ab 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "@stdlib/assert-is-string": "^0.2.2", "@stdlib/blas-ext-base-gfill-by": "^0.2.1", "@stdlib/iter-length": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/symbol-iterator": "^0.2.2", "@stdlib/types": "^0.4.3", "@stdlib/error-tools-fmtprodmsg": "^0.2.2" From 3ce8c9225dd313d2f01e8a9e5df77984fa5a930c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 10 Mar 2025 01:52:26 +0000 Subject: [PATCH 079/117] Remove files --- index.d.ts | 322 ---- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5169 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index cb63cd1..0000000 --- a/index.d.ts +++ /dev/null @@ -1,322 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, RealOrComplexTypedArray, BooleanArray, DataType } from '@stdlib/types/array'; -import { IterableIterator } from '@stdlib/types/iter'; - -/** -* Array or typed array. -*/ -type ArrayOrTypedArray = Array | RealOrComplexTypedArray | BooleanArray; - -/** -* Nullary callback function. -* -* @returns fill value -*/ -type Nullary = () => any; - -/** -* Unary callback function. -* -* @param i - current array index -* @returns fill value -*/ -type Unary = ( i: number ) => any; - -/** -* Callback function. -* -* @param i - current array index -* @returns fill value -*/ -type Callback = Nullary | Unary; - -/** -* Creates a filled array according to a provided callback function and having a specified data type. -* -* @param dtype - data type -* @returns filled array -* -* @example -* var arr = filledarrayBy(); -* // returns -* -* @example -* var arr = filledarrayBy( 'float32' ); -* // returns -*/ -declare function filledarrayBy( dtype?: DataType ): ArrayOrTypedArray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Creates a filled array according to a provided callback function and having a specified `length`. -* -* @param length - array length -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* -* var arr = filledarrayBy( 5, constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( length: number, clbk: Callback, thisArg?: any ): ArrayOrTypedArray; - -/** -* Creates a filled array according to a provided callback function and having a specified `length`. -* -* @param length - array length -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* -* var arr = filledarrayBy( 5, 'float64', constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( length: number, dtype: DataType, clbk: Callback, thisArg?: any ): ArrayOrTypedArray; - -/** -* Creates a filled array from another `array` according to a provided callback function. -* -* @param array - typed array or array-like object -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* -* 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; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Creates a filled array from another `array` according to a provided callback function. -* -* @param array - typed array or array-like object -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* -* 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; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Creates a filled array from an iterable according to a callback function. -* -* @param iterable - iterable -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var iterConstant = require( '@stdlib/iter-constant' ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarrayBy( it, constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( iterable: IterableIterator, clbk: Callback, thisArg?: any ): ArrayOrTypedArray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Creates a filled array from an iterable according to a callback function. -* -* @param iterable - iterable -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var iterConstant = require( '@stdlib/iter-constant' ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarrayBy( it, 'float64', constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( iterable: IterableIterator, dtype: DataType, clbk: 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. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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 | BooleanArray; - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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 | BooleanArray; - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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 | BooleanArray; - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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 | BooleanArray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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 | BooleanArray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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 | BooleanArray; // eslint-disable-line @typescript-eslint/unified-signatures - - -// EXPORTS // - -export = filledarrayBy; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 668c2f7..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@v0.0.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-ctors@v0.3.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill-by@v0.2.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled-by@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@v0.2.2-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.3.0-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";var v=f(),g=j.get("dtypes.default");function c(){var f,j,c,b,y,x,u,E;if(0===(j=arguments.length))return new(y=d(g))(0);if(r(c=arguments[0])){if(j>1)throw new TypeError(w("00h05"));if(null===(y=d(c)))throw new TypeError(w("00h2Y",c));return new y(0)}if(j<2)throw new TypeError(w("00h05"));if(h(arguments[j-=1]))if(h(arguments[j-1])){if(f=arguments[j],b=arguments[j-=1],0===j)throw new TypeError(w("00h05"))}else b=arguments[j];else{if(!(j>=2))throw new TypeError(w("00h05"));if(f=arguments[j],!h(b=arguments[j-=1]))throw new TypeError(w("00h2b",b))}if((j-=1)>=0&&r(arguments[j])?(c=arguments[j],j-=1):c=g,null===(y=d(c)))throw new TypeError(w("00h2Y",c));if("generic"===c){if(E=arguments[0],0===j){if(e(E)?u=E:i(E)&&(u=E.length),void 0!==u)return m(u,b,f);if(n(E))throw new Error(w("00h04"));if(o(E)){if(!1===v)throw new TypeError(w("00h2Z",E));if(!h(E[p]))throw new TypeError(w("00h2a",E));if(E=E[p](),!h(E.next))throw new TypeError(w("00h2a",E));return function(r,e,t){var s,i;for(s=[],i=-1;!r.next().done;)i+=1,s.push(e.call(t,i));return s}(E,b,f)}throw new TypeError(w("00h2a",E))}if(n(E))throw new Error(w("00h04"));throw new TypeError(w("00h2a",E))}if(0===j)if(i(E=arguments[0]))x=new y(E.length);else if(n(E))x=new y(E);else if(e(E))x=new y(E);else{if(!o(E))throw new TypeError(w("00h2a",E));if(!1===v)throw new TypeError(w("00h2Z",E));if(!h(E[p]))throw new TypeError(w("00h2a",E));if(E=E[p](),!h(E.next))throw new TypeError(w("00h2a",E));x=new y(a(E))}else x=1===j?new y(arguments[0],arguments[1]):new y(arguments[0],arguments[1],arguments[2]);return x.length>0&&(t(c)||s(c)?function(r,e,t){var s;for(s=0;s\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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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( format('00h05') );\n\t\t}\n\t\tctor = ctors( dtype );\n\t\tif ( ctor === null ) {\n\t\t\tthrow new TypeError( format( '00h2Y', 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( format('00h05') );\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( format('00h05') );\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( '00h2b', 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( format('00h05') );\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( '00h2Y', 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( format('00h04') );\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( '00h2Z', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00h2a', 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( '00h2a', 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( '00h2a', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format('00h04') );\n\t\t}\n\t\tthrow new TypeError( format( '00h2a', 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( '00h2Z', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00h2a', 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( '00h2a', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00h2a', 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\nexport default filledarrayBy;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","DEFAULT_DTYPE","defaults","get","filledarrayBy","thisArg","nargs","dtype","clbk","ctor","arr","len","arg","arguments","length","ctors","isString","TypeError","format","isFunction","isNonNegativeInteger","isCollection","filledArray","isArrayBuffer","Error","isObject","ITERATOR_SYMBOL","next","it","i","done","push","call","filledArrayIterator","iterLength","isComplexDataType","isBooleanDataType","set","filledAccessors","gfillBy","value","aidx"],"mappings":";;sjDA0CA,IAAIA,EAAsBC,IACtBC,EAAgBC,EAASC,IAAK,kBA2MlC,SAASC,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAKJ,GAAe,KAHfN,EAAQO,UAAUC,QAKjB,OAAO,IADPL,EAAOM,EAAOd,IACG,GAIlB,GAAKe,EADLT,EAAQM,UAAW,IACM,CAExB,GAAKP,EAAQ,EACZ,MAAM,IAAIW,UAAWC,EAAO,UAG7B,GAAc,QADdT,EAAOM,EAAOR,IAEb,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,OAAO,IAAIE,EAAM,EACjB,CAED,GAAKH,EAAQ,EACZ,MAAM,IAAIW,UAAWC,EAAO,UAM7B,GAAKC,EAAYN,UAHjBP,GAAS,IAKR,GAAKa,EAAYN,UAAWP,EAAM,KAMjC,GALAD,EAAUQ,UAAWP,GAErBE,EAAOK,UADPP,GAAS,GAIM,IAAVA,EACJ,MAAM,IAAIW,UAAWC,EAAO,eAI7BV,EAAOK,UAAWP,OAIf,MAAKA,GAAS,GAUlB,MAAM,IAAIW,UAAWC,EAAO,UAN5B,GAHAb,EAAUQ,UAAWP,IAGfa,EADNX,EAAOK,UADPP,GAAS,IAGR,MAAM,IAAIW,UAAWC,EAAQ,QAASV,GAMvC,CAUD,IARAF,GAAS,IACK,GAAKU,EAAUH,UAAWP,KACvCC,EAAQM,UAAWP,GACnBA,GAAS,GAETC,EAAQN,EAGK,QADdQ,EAAOM,EAAOR,IAEb,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,GAAe,YAAVA,EAAsB,CAE1B,GADAK,EAAMC,UAAW,GACF,IAAVP,EAAc,CAMlB,GALKc,EAAsBR,GAC1BD,EAAMC,EACKS,EAAcT,KACzBD,EAAMC,EAAIE,aAEE,IAARH,EACJ,OAAOW,EAAaX,EAAKH,EAAMH,GAEhC,GAAKkB,EAAeX,GACnB,MAAM,IAAIY,MAAON,EAAO,UAEzB,GAAKO,EAAUb,GAAQ,CACtB,IAA6B,IAAxBb,EACJ,MAAM,IAAIkB,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAYP,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLP,EAAYP,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvC,OAvSJ,SAA8BgB,EAAIpB,EAAMH,GACvC,IAAIK,EACAmB,EAKJ,IAFAnB,EAAM,GACNmB,GAAK,GAEAD,EAAGD,OACAG,MAGPD,GAAK,EACLnB,EAAIqB,KAAMvB,EAAKwB,KAAM3B,EAASwB,IAE/B,OAAOnB,CACR,CAuRWuB,CAAqBrB,EAAKJ,EAAMH,EACvC,CACD,MAAM,IAAIY,UAAWC,EAAQ,QAASN,GACzC,CAAS,GAAKW,EAAeX,GAC1B,MAAM,IAAIY,MAAON,EAAO,UAEzB,MAAM,IAAID,UAAWC,EAAQ,QAASN,GACtC,CACD,GAAe,IAAVN,EAEJ,GAAKe,EADLT,EAAMC,UAAW,IAEhBH,EAAM,IAAID,EAAMG,EAAIE,aACd,GAAKS,EAAeX,GAC1BF,EAAM,IAAID,EAAMG,QACV,GAAKQ,EAAsBR,GACjCF,EAAM,IAAID,EAAMG,OACV,KAAKa,EAAUb,GAarB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAZtC,IAA6B,IAAxBb,EACJ,MAAM,IAAIkB,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAYP,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLP,EAAYP,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvCF,EAAM,IAAID,EAAMyB,EAAYtB,GAG5B,MAEDF,EADqB,IAAVJ,EACL,IAAIG,EAAMI,UAAU,GAAIA,UAAU,IAElC,IAAIJ,EAAMI,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKH,EAAII,OAAS,IACZqB,EAAmB5B,IAAW6B,EAAmB7B,GAjTxD,SAA0BG,EAAKF,EAAMH,GACpC,IAAIwB,EACJ,IAAMA,EAAI,EAAGA,EAAInB,EAAII,OAAQe,IAC5BnB,EAAI2B,IAAK7B,EAAKwB,KAAM3B,EAASwB,GAAKA,EAGpC,CA4SGS,CAAiB5B,EAAKF,EAAMH,GAE5BkC,EAAS7B,EAAII,OAAQJ,EAAK,GAe5B,SAAmB8B,EAAOC,GACzB,OAAOjC,EAAKwB,KAAM3B,EAASoC,EAC3B,KAdM/B,CAeR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index e4cee9c..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From cddfdf0c080dc02b83563644139af85bd359fdf7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 10 Mar 2025 01:52:52 +0000 Subject: [PATCH 080/117] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 194 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 191 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 49 +- SECURITY.md | 5 - benchmark/benchmark.js | 341 -- benchmark/benchmark.length.bool.js | 97 - benchmark/benchmark.length.complex128.js | 98 - benchmark/benchmark.length.complex64.js | 98 - benchmark/benchmark.length.float32.js | 97 - benchmark/benchmark.length.float64.js | 97 - benchmark/benchmark.length.generic.js | 97 - benchmark/benchmark.length.int16.js | 97 - benchmark/benchmark.length.int32.js | 97 - benchmark/benchmark.length.int8.js | 97 - benchmark/benchmark.length.uint16.js | 97 - benchmark/benchmark.length.uint32.js | 97 - benchmark/benchmark.length.uint8.js | 97 - benchmark/benchmark.length.uint8c.js | 97 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 36 - dist/index.js.map | 7 - docs/repl.txt | 157 - docs/types/test.ts | 606 --- examples/index.js | 37 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 192 - lib/main.js | 416 -- package.json | 96 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 4397 ---------------- 57 files changed, 4870 insertions(+), 11148 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.length.bool.js delete mode 100644 benchmark/benchmark.length.complex128.js delete mode 100644 benchmark/benchmark.length.complex64.js delete mode 100644 benchmark/benchmark.length.float32.js delete mode 100644 benchmark/benchmark.length.float64.js delete mode 100644 benchmark/benchmark.length.generic.js delete mode 100644 benchmark/benchmark.length.int16.js delete mode 100644 benchmark/benchmark.length.int32.js delete mode 100644 benchmark/benchmark.length.int8.js delete mode 100644 benchmark/benchmark.length.uint16.js delete mode 100644 benchmark/benchmark.length.uint32.js delete mode 100644 benchmark/benchmark.length.uint8.js delete mode 100644 benchmark/benchmark.length.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 922eb10..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-03-10T01:13:29.897Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 2d6aaee..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/contributing/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index f988046..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index b2c1f9c..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '42 6 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -278,7 +269,7 @@ for ( i = 0; i < dt.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -347,13 +338,13 @@ Copyright © 2016-2025. 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/dtypes]: https://github.com/stdlib-js/array-dtypes/tree/esm -[@stdlib/array/filled]: https://github.com/stdlib-js/array-filled +[@stdlib/array/filled]: https://github.com/stdlib-js/array-filled/tree/esm -[@stdlib/array/typed]: https://github.com/stdlib-js/array-typed +[@stdlib/array/typed]: https://github.com/stdlib-js/array-typed/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 17cfb5a..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,341 +0,0 @@ -/** -* @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 isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); -var isArray = require( '@stdlib/assert-is-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var Complex64 = require( '@stdlib/complex-float32-ctor' ); -var Complex128 = require( '@stdlib/complex-float64-ctor' ); -var pkg = require( './../package.json' ).name; -var filledarrayBy = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 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=float64', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'float64', 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=float32', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'float32', 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=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; - var i; - - clbk = constantFunction( new Complex128( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'complex128', 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=complex64', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( new Complex64( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'complex64', 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=int32', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int32', 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=uint32', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint32', 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=int16', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int16', 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=uint16', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint16', 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=int8', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int8', 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=uint8', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint8', 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=uint8c', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint8c', 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=generic', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'generic', clbk ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.length.bool.js b/benchmark/benchmark.length.bool.js deleted file mode 100644 index 3cdd152..0000000 --- a/benchmark/benchmark.length.bool.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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/benchmark/benchmark.length.complex128.js b/benchmark/benchmark.length.complex128.js deleted file mode 100644 index 122bc7c..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 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 Complex128 = require( '@stdlib/complex-float64-ctor' ); -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( new Complex128( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'complex128', 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=complex128,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.complex64.js b/benchmark/benchmark.length.complex64.js deleted file mode 100644 index e7a2d74..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 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 Complex64 = require( '@stdlib/complex-float32-ctor' ); -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( new Complex64( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'complex64', 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=complex64,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.float32.js b/benchmark/benchmark.length.float32.js deleted file mode 100644 index d2b2ba7..0000000 --- a/benchmark/benchmark.length.float32.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'float32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=float32,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.float64.js b/benchmark/benchmark.length.float64.js deleted file mode 100644 index 65064e3..0000000 --- a/benchmark/benchmark.length.float64.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'float64', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=float64,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.generic.js b/benchmark/benchmark.length.generic.js deleted file mode 100644 index eb87dfa..0000000 --- a/benchmark/benchmark.length.generic.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isArray = require( '@stdlib/assert-is-array' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'generic', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isArray( 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=generic,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int16.js b/benchmark/benchmark.length.int16.js deleted file mode 100644 index 914ff7c..0000000 --- a/benchmark/benchmark.length.int16.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int16', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=int16,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int32.js b/benchmark/benchmark.length.int32.js deleted file mode 100644 index cc0f678..0000000 --- a/benchmark/benchmark.length.int32.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=int32,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int8.js b/benchmark/benchmark.length.int8.js deleted file mode 100644 index 77553b0..0000000 --- a/benchmark/benchmark.length.int8.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int8', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=int8,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint16.js b/benchmark/benchmark.length.uint16.js deleted file mode 100644 index c68efdd..0000000 --- a/benchmark/benchmark.length.uint16.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint16', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint16,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint32.js b/benchmark/benchmark.length.uint32.js deleted file mode 100644 index 27c1742..0000000 --- a/benchmark/benchmark.length.uint32.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint32,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint8.js b/benchmark/benchmark.length.uint8.js deleted file mode 100644 index 2a26be4..0000000 --- a/benchmark/benchmark.length.uint8.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint8', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint8,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint8c.js b/benchmark/benchmark.length.uint8c.js deleted file mode 100644 index dd6e8c2..0000000 --- a/benchmark/benchmark.length.uint8c.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint8c', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint8c,len='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index c138144..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by" -%% click B href "https://github.com/stdlib-js/array-filled-by/tree/main" -%% click C href "https://github.com/stdlib-js/array-filled-by/tree/production" -%% click D href "https://github.com/stdlib-js/array-filled-by/tree/esm" -%% click E href "https://github.com/stdlib-js/array-filled-by/tree/deno" -%% click F href "https://github.com/stdlib-js/array-filled-by/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by -[production-url]: https://github.com/stdlib-js/array-filled-by/tree/production -[deno-url]: https://github.com/stdlib-js/array-filled-by/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-filled-by/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-filled-by/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-filled-by/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-filled-by/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-filled-by/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 188fc9b..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import filledarrayBy from '../docs/types/index'; -export = filledarrayBy; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 65ae3db..0000000 --- a/dist/index.js +++ /dev/null @@ -1,36 +0,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 deleted file mode 100644 index e88f9aa..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "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,YACjDC,EAAuB,QAAS,uCAAwC,EAAE,YAC1EC,EAAoB,QAAS,+DAAgE,EAC7FC,EAAoB,QAAS,gDAAiD,EAC9EC,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,EAAQ,UAAU,OAGbA,IAAU,EACd,OAAAE,EAAOrB,EAAOS,CAAc,EACrB,IAAIY,EAAM,CAAE,EAIpB,GADAD,EAAQ,UAAW,CAAE,EAChB5B,EAAU4B,CAAM,EAAI,CAExB,GAAKD,EAAQ,EACZ,MAAM,IAAI,UAAW,2FAA4F,EAGlH,GADAE,EAAOrB,EAAOoB,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWd,EAAQ,sEAAuEa,CAAM,CAAE,EAG7G,OAAO,IAAIC,EAAM,CAAE,CACpB,CAEA,GAAKF,EAAQ,EACZ,MAAM,IAAI,UAAW,2FAA4F,EAMlH,GAHAA,GAAS,EAGJpB,EAAY,UAAWoB,CAAM,CAAE,EAEnC,GAAKpB,EAAY,UAAWoB,EAAM,CAAE,CAAE,GAMrC,GALAN,EAAU,UAAWM,CAAM,EAC3BA,GAAS,EACTP,EAAO,UAAWO,CAAM,EAGnBA,IAAU,EACd,MAAM,IAAI,UAAW,2FAA4F,OAIlHP,EAAO,UAAWO,CAAM,UAIhBA,GAAS,GAIlB,GAHAN,EAAU,UAAWM,CAAM,EAC3BA,GAAS,EACTP,EAAO,UAAWO,CAAM,EACnB,CAACpB,EAAYa,CAAK,EACtB,MAAM,IAAI,UAAWL,EAAQ,uEAAwEK,CAAK,CAAE,MAK7G,OAAM,IAAI,UAAW,2FAA4F,EAWlH,GARAO,GAAS,EACJA,GAAS,GAAK3B,EAAU,UAAW2B,CAAM,CAAE,GAC/CC,EAAQ,UAAWD,CAAM,EACzBA,GAAS,GAETC,EAAQX,EAETY,EAAOrB,EAAOoB,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWd,EAAQ,sEAAuEa,CAAM,CAAE,EAG7G,GAAKA,IAAU,UAAY,CAE1B,GADAG,EAAM,UAAW,CAAE,EACdJ,IAAU,EAAI,CAMlB,GALK1B,EAAsB8B,CAAI,EAC9BD,EAAMC,EACK3B,EAAc2B,CAAI,IAC7BD,EAAMC,EAAI,QAEND,IAAQ,OACZ,OAAOpB,EAAaoB,EAAKV,EAAMC,CAAQ,EAExC,GAAKhB,EAAe0B,CAAI,EACvB,MAAM,IAAI,MAAO,mFAAoF,EAEtG,GAAKzB,EAAUyB,CAAI,EAAI,CACtB,GAAKf,IAAwB,GAC5B,MAAM,IAAI,UAAWD,EAAQ,sIAAuIgB,CAAI,CAAE,EAE3K,GAAK,CAACxB,EAAYwB,EAAKnB,CAAgB,CAAE,EACxC,MAAM,IAAI,UAAWG,EAAQ,wGAAyGgB,CAAI,CAAE,EAG7I,GADAA,EAAMA,EAAKnB,CAAgB,EAAE,EACxB,CAACL,EAAYwB,EAAI,IAAK,EAC1B,MAAM,IAAI,UAAWhB,EAAQ,wGAAyGgB,CAAI,CAAE,EAE7I,OAAOb,EAAqBa,EAAKX,EAAMC,CAAQ,CAChD,CACA,MAAM,IAAI,UAAWN,EAAQ,wGAAyGgB,CAAI,CAAE,CAC7I,SAAY1B,EAAe0B,CAAI,EAC9B,MAAM,IAAI,MAAO,mFAAoF,EAEtG,MAAM,IAAI,UAAWhB,EAAQ,wGAAyGgB,CAAI,CAAE,CAC7I,CACA,GAAKJ,IAAU,EAEd,GADAI,EAAM,UAAW,CAAE,EACd3B,EAAc2B,CAAI,EACtBT,EAAM,IAAIO,EAAME,EAAI,MAAO,UAChB1B,EAAe0B,CAAI,EAC9BT,EAAM,IAAIO,EAAME,CAAI,UACT9B,EAAsB8B,CAAI,EACrCT,EAAM,IAAIO,EAAME,CAAI,UACTzB,EAAUyB,CAAI,EAAI,CAC7B,GAAKf,IAAwB,GAC5B,MAAM,IAAI,UAAWD,EAAQ,sIAAuIgB,CAAI,CAAE,EAE3K,GAAK,CAACxB,EAAYwB,EAAKnB,CAAgB,CAAE,EACxC,MAAM,IAAI,UAAWG,EAAQ,wGAAyGgB,CAAI,CAAE,EAG7I,GADAA,EAAMA,EAAKnB,CAAgB,EAAE,EACxB,CAACL,EAAYwB,EAAI,IAAK,EAC1B,MAAM,IAAI,UAAWhB,EAAQ,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,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 deleted file mode 100644 index 06f3146..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,157 +0,0 @@ - -{{alias}}( [dtype] ) - Creates a filled array. - - Parameters - ---------- - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr = {{alias}}() - - > arr = {{alias}}( 'float32' ) - - - -{{alias}}( length[, dtype], clbk[, thisArg] ) - Returns a filled array according to a provided callback function and having - a specified length. - - Parameters - ---------- - length: integer - Array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > function clbk() { return 1.0; }; - > var arr = {{alias}}( 5, clbk ) - [ 1.0, 1.0, 1.0, 1.0, 1.0 ] - > arr = {{alias}}( 5, 'int32', clbk ) - [ 1, 1, 1, 1, 1 ] - - -{{alias}}( array[, dtype], clbk[, thisArg] ) - Creates a filled array from another array (or array-like object) according - to a provided callback function. - - Parameters - ---------- - array: ArrayLikeObject - Array from which to generate another array. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias}}( [ 0.5, 0.5, 0.5 ], {{alias:@stdlib/utils/constant-function}}( 2.0 ) ) - [ 2.0, 2.0, 2.0 ] - > var arr2 = {{alias}}( arr1, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( iterable[, dtype], clbk[, thisArg] ) - Creates a filled array from an iterable according to a provided callback - function. - - Parameters - ---------- - iterable: Iterable - Iterable from which to generate an array. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias:@stdlib/iter/constant}}( 3.0, {'iter': 3} ); - > var arr2 = {{alias}}( arr1, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( buffer[, byteOffset[, length]][, dtype], clbk[, thisArg] ) - Returns a filled typed array view of an ArrayBuffer according to a provided - callback function. - - The 'generic' array data type is *not* supported. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( buf, 0, 4, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0, 1.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index bb876ed..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,606 +0,0 @@ -/* -* @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. -*/ - -/// - -import { IterableIterator } from '@stdlib/types/iter'; -import filledarrayBy = require( './index' ); - - -/** -* Returns an iterator protocol-compliant object. -* -* @returns iterator protocol-compliant object -*/ -function iterator(): IterableIterator { - const obj: IterableIterator = { - [Symbol.iterator]: iterator, - 'next': next - }; - return obj; -} - -/** -* Implements the iterator protocol `next` method. -* -* @returns iterator protocol-compliant object -*/ -function next(): any { - return { - 'value': 1.0, - 'done': false - }; -} - -/** -* Callback function. -* -* @param i - current array index -* @returns return value -*/ -function clbk( i: number ): number { - return i; -} - - -// TESTS // - -// The function returns an array or typed array... -{ - filledarrayBy(); // $ExpectType ArrayOrTypedArray - filledarrayBy( 'float32' ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( 10, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( 10, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( 10, 'int32', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( 10, 'int32', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const x = new Float64Array( 10 ); - filledarrayBy( x, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( x, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( x, 'uint8', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( x, 'uint8', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const y = [ 2.0, 2.0, 2.0 ]; - filledarrayBy( y, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( y, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( y, 'float64', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( y, 'float64', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const it = iterator(); - filledarrayBy( it, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( it, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( it, 'uint8c', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( it, 'uint8c', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const buf = new ArrayBuffer( 32 ); - filledarrayBy( buf, clbk ); // $ExpectType RealOrComplexTypedArray | BooleanArray - filledarrayBy( buf, clbk, {} ); // $ExpectType RealOrComplexTypedArray | BooleanArray - - filledarrayBy( buf, 'uint32', clbk ); // $ExpectType RealOrComplexTypedArray | BooleanArray - filledarrayBy( buf, 'uint32', clbk, {} ); // $ExpectType RealOrComplexTypedArray | BooleanArray - - filledarrayBy( buf, 8, clbk ); // $ExpectType RealOrComplexTypedArray | BooleanArray - filledarrayBy( buf, 8, clbk, {} ); // $ExpectType RealOrComplexTypedArray | BooleanArray - - filledarrayBy( buf, 8, 'uint16', clbk ); // $ExpectType RealOrComplexTypedArray | BooleanArray - filledarrayBy( buf, 8, 'uint16', clbk, {} ); // $ExpectType RealOrComplexTypedArray | BooleanArray - - filledarrayBy( buf, 8, 2, clbk ); // $ExpectType RealOrComplexTypedArray | BooleanArray - filledarrayBy( buf, 8, 2, clbk, {} ); // $ExpectType RealOrComplexTypedArray | BooleanArray - - filledarrayBy( buf, 8, 2, 'int16', clbk ); // $ExpectType RealOrComplexTypedArray | BooleanArray - filledarrayBy( buf, 8, 2, 'int16', clbk, {} ); // $ExpectType RealOrComplexTypedArray | BooleanArray -} - -// The compiler throws an error if a callback function argument is not a function... -{ - filledarrayBy( 'float64', '5' ); // $ExpectError - filledarrayBy( 'float64', 1.0 ); // $ExpectError - filledarrayBy( 'float64', false ); // $ExpectError - filledarrayBy( 'float64', true ); // $ExpectError - filledarrayBy( 'float64', null ); // $ExpectError - filledarrayBy( 'float64', undefined ); // $ExpectError - filledarrayBy( 'float64', [] ); // $ExpectError - filledarrayBy( 'float64', {} ); // $ExpectError - - filledarrayBy( 'float64', '5', {} ); // $ExpectError - filledarrayBy( 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( 'float64', false, {} ); // $ExpectError - filledarrayBy( 'float64', true, {} ); // $ExpectError - filledarrayBy( 'float64', null, {} ); // $ExpectError - filledarrayBy( 'float64', undefined, {} ); // $ExpectError - filledarrayBy( 'float64', [], {} ); // $ExpectError - filledarrayBy( 'float64', {}, {} ); // $ExpectError - - filledarrayBy( 10, '5' ); // $ExpectError - filledarrayBy( 10, 1.0 ); // $ExpectError - filledarrayBy( 10, false ); // $ExpectError - filledarrayBy( 10, true ); // $ExpectError - filledarrayBy( 10, null ); // $ExpectError - filledarrayBy( 10, undefined ); // $ExpectError - filledarrayBy( 10, [] ); // $ExpectError - filledarrayBy( 10, {} ); // $ExpectError - - filledarrayBy( 10, '5', {} ); // $ExpectError - filledarrayBy( 10, 1.0, {} ); // $ExpectError - filledarrayBy( 10, false, {} ); // $ExpectError - filledarrayBy( 10, true, {} ); // $ExpectError - filledarrayBy( 10, null, {} ); // $ExpectError - filledarrayBy( 10, undefined, {} ); // $ExpectError - filledarrayBy( 10, [], {} ); // $ExpectError - filledarrayBy( 10, {}, {} ); // $ExpectError - - filledarrayBy( 10, 'float64', '5' ); // $ExpectError - filledarrayBy( 10, 'float64', 1.0 ); // $ExpectError - filledarrayBy( 10, 'float64', false ); // $ExpectError - filledarrayBy( 10, 'float64', true ); // $ExpectError - filledarrayBy( 10, 'float64', null ); // $ExpectError - filledarrayBy( 10, 'float64', undefined ); // $ExpectError - filledarrayBy( 10, 'float64', [] ); // $ExpectError - filledarrayBy( 10, 'float64', {} ); // $ExpectError - - filledarrayBy( 10, 'float64', '5', {} ); // $ExpectError - filledarrayBy( 10, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( 10, 'float64', false, {} ); // $ExpectError - filledarrayBy( 10, 'float64', true, {} ); // $ExpectError - filledarrayBy( 10, 'float64', null, {} ); // $ExpectError - filledarrayBy( 10, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( 10, 'float64', [], {} ); // $ExpectError - filledarrayBy( 10, 'float64', {}, {} ); // $ExpectError - - const x = new Float64Array( 10 ); - filledarrayBy( x, '5' ); // $ExpectError - filledarrayBy( x, 1.0 ); // $ExpectError - filledarrayBy( x, false ); // $ExpectError - filledarrayBy( x, true ); // $ExpectError - filledarrayBy( x, null ); // $ExpectError - filledarrayBy( x, undefined ); // $ExpectError - filledarrayBy( x, [] ); // $ExpectError - filledarrayBy( x, {} ); // $ExpectError - - filledarrayBy( x, '5', {} ); // $ExpectError - filledarrayBy( x, 1.0, {} ); // $ExpectError - filledarrayBy( x, false, {} ); // $ExpectError - filledarrayBy( x, true, {} ); // $ExpectError - filledarrayBy( x, null, {} ); // $ExpectError - filledarrayBy( x, undefined, {} ); // $ExpectError - filledarrayBy( x, [], {} ); // $ExpectError - filledarrayBy( x, {}, {} ); // $ExpectError - - filledarrayBy( x, 'float64', '5' ); // $ExpectError - filledarrayBy( x, 'float64', 1.0 ); // $ExpectError - filledarrayBy( x, 'float64', false ); // $ExpectError - filledarrayBy( x, 'float64', true ); // $ExpectError - filledarrayBy( x, 'float64', null ); // $ExpectError - filledarrayBy( x, 'float64', undefined ); // $ExpectError - filledarrayBy( x, 'float64', [] ); // $ExpectError - filledarrayBy( x, 'float64', {} ); // $ExpectError - - filledarrayBy( x, 'float64', '5', {} ); // $ExpectError - filledarrayBy( x, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( x, 'float64', false, {} ); // $ExpectError - filledarrayBy( x, 'float64', true, {} ); // $ExpectError - filledarrayBy( x, 'float64', null, {} ); // $ExpectError - filledarrayBy( x, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( x, 'float64', [], {} ); // $ExpectError - filledarrayBy( x, 'float64', {}, {} ); // $ExpectError - - const y = [ 2.0, 2.0, 2.0 ]; - filledarrayBy( y, '5' ); // $ExpectError - filledarrayBy( y, 1.0 ); // $ExpectError - filledarrayBy( y, false ); // $ExpectError - filledarrayBy( y, true ); // $ExpectError - filledarrayBy( y, null ); // $ExpectError - filledarrayBy( y, undefined ); // $ExpectError - filledarrayBy( y, [] ); // $ExpectError - filledarrayBy( y, {} ); // $ExpectError - - filledarrayBy( y, '5', {} ); // $ExpectError - filledarrayBy( y, 1.0, {} ); // $ExpectError - filledarrayBy( y, false, {} ); // $ExpectError - filledarrayBy( y, true, {} ); // $ExpectError - filledarrayBy( y, null, {} ); // $ExpectError - filledarrayBy( y, undefined, {} ); // $ExpectError - filledarrayBy( y, [], {} ); // $ExpectError - filledarrayBy( y, {}, {} ); // $ExpectError - - filledarrayBy( y, 'float64', '5' ); // $ExpectError - filledarrayBy( y, 'float64', 1.0 ); // $ExpectError - filledarrayBy( y, 'float64', false ); // $ExpectError - filledarrayBy( y, 'float64', true ); // $ExpectError - filledarrayBy( y, 'float64', null ); // $ExpectError - filledarrayBy( y, 'float64', undefined ); // $ExpectError - filledarrayBy( y, 'float64', [] ); // $ExpectError - filledarrayBy( y, 'float64', {} ); // $ExpectError - - filledarrayBy( y, 'float64', '5', {} ); // $ExpectError - filledarrayBy( y, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( y, 'float64', false, {} ); // $ExpectError - filledarrayBy( y, 'float64', true, {} ); // $ExpectError - filledarrayBy( y, 'float64', null, {} ); // $ExpectError - filledarrayBy( y, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( y, 'float64', [], {} ); // $ExpectError - filledarrayBy( y, 'float64', {}, {} ); // $ExpectError - - const it = iterator(); - filledarrayBy( it, '5' ); // $ExpectError - filledarrayBy( it, 1.0 ); // $ExpectError - filledarrayBy( it, false ); // $ExpectError - filledarrayBy( it, true ); // $ExpectError - filledarrayBy( it, null ); // $ExpectError - filledarrayBy( it, undefined ); // $ExpectError - filledarrayBy( it, [] ); // $ExpectError - filledarrayBy( it, {} ); // $ExpectError - - filledarrayBy( it, '5', {} ); // $ExpectError - filledarrayBy( it, 1.0, {} ); // $ExpectError - filledarrayBy( it, false, {} ); // $ExpectError - filledarrayBy( it, true, {} ); // $ExpectError - filledarrayBy( it, null, {} ); // $ExpectError - filledarrayBy( it, undefined, {} ); // $ExpectError - filledarrayBy( it, [], {} ); // $ExpectError - filledarrayBy( it, {}, {} ); // $ExpectError - - filledarrayBy( it, 'float64', '5' ); // $ExpectError - filledarrayBy( it, 'float64', 1.0 ); // $ExpectError - filledarrayBy( it, 'float64', false ); // $ExpectError - filledarrayBy( it, 'float64', true ); // $ExpectError - filledarrayBy( it, 'float64', null ); // $ExpectError - filledarrayBy( it, 'float64', undefined ); // $ExpectError - filledarrayBy( it, 'float64', [] ); // $ExpectError - filledarrayBy( it, 'float64', {} ); // $ExpectError - - filledarrayBy( it, 'float64', '5', {} ); // $ExpectError - filledarrayBy( it, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( it, 'float64', false, {} ); // $ExpectError - filledarrayBy( it, 'float64', true, {} ); // $ExpectError - filledarrayBy( it, 'float64', null, {} ); // $ExpectError - filledarrayBy( it, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( it, 'float64', [], {} ); // $ExpectError - filledarrayBy( it, 'float64', {}, {} ); // $ExpectError - - const buf = new ArrayBuffer( 32 ); - filledarrayBy( buf, '5' ); // $ExpectError - filledarrayBy( buf, 1.0 ); // $ExpectError - filledarrayBy( buf, false ); // $ExpectError - filledarrayBy( buf, true ); // $ExpectError - filledarrayBy( buf, null ); // $ExpectError - filledarrayBy( buf, undefined ); // $ExpectError - filledarrayBy( buf, [] ); // $ExpectError - filledarrayBy( buf, {} ); // $ExpectError - - filledarrayBy( buf, '5', {} ); // $ExpectError - filledarrayBy( buf, 1.0, {} ); // $ExpectError - filledarrayBy( buf, false, {} ); // $ExpectError - filledarrayBy( buf, true, {} ); // $ExpectError - filledarrayBy( buf, null, {} ); // $ExpectError - filledarrayBy( buf, undefined, {} ); // $ExpectError - filledarrayBy( buf, [], {} ); // $ExpectError - filledarrayBy( buf, {}, {} ); // $ExpectError - - filledarrayBy( buf, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 'float64', false ); // $ExpectError - filledarrayBy( buf, 'float64', true ); // $ExpectError - filledarrayBy( buf, 'float64', null ); // $ExpectError - filledarrayBy( buf, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 'float64', {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5' ); // $ExpectError - filledarrayBy( buf, 8, 1.0 ); // $ExpectError - filledarrayBy( buf, 8, false ); // $ExpectError - filledarrayBy( buf, 8, true ); // $ExpectError - filledarrayBy( buf, 8, null ); // $ExpectError - filledarrayBy( buf, 8, undefined ); // $ExpectError - filledarrayBy( buf, 8, [] ); // $ExpectError - filledarrayBy( buf, 8, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, false, {} ); // $ExpectError - filledarrayBy( buf, 8, true, {} ); // $ExpectError - filledarrayBy( buf, 8, null, {} ); // $ExpectError - filledarrayBy( buf, 8, undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, [], {} ); // $ExpectError - filledarrayBy( buf, 8, {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 8, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 'float64', false ); // $ExpectError - filledarrayBy( buf, 8, 'float64', true ); // $ExpectError - filledarrayBy( buf, 8, 'float64', null ); // $ExpectError - filledarrayBy( buf, 8, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 8, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 8, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 8, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, '5' ); // $ExpectError - filledarrayBy( buf, 8, 2, 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 2, false ); // $ExpectError - filledarrayBy( buf, 8, 2, true ); // $ExpectError - filledarrayBy( buf, 8, 2, null ); // $ExpectError - filledarrayBy( buf, 8, 2, undefined ); // $ExpectError - filledarrayBy( buf, 8, 2, [] ); // $ExpectError - filledarrayBy( buf, 8, 2, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, false, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, true, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, null, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, [], {} ); // $ExpectError - filledarrayBy( buf, 8, 2, {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', false ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', true ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', null ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', {}, {} ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid length, typed array, array-like object, `ArrayBuffer`, or iterable argument... -{ - filledarrayBy( false, clbk ); // $ExpectError - filledarrayBy( true, clbk ); // $ExpectError - filledarrayBy( null, clbk ); // $ExpectError - filledarrayBy( {}, clbk ); // $ExpectError - - filledarrayBy( false, clbk, {} ); // $ExpectError - filledarrayBy( true, clbk, {} ); // $ExpectError - filledarrayBy( null, clbk, {} ); // $ExpectError - filledarrayBy( {}, clbk, {} ); // $ExpectError - - filledarrayBy( false, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 'float64', clbk ); // $ExpectError - - filledarrayBy( false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, clbk ); // $ExpectError - filledarrayBy( 1.0, 8, clbk ); // $ExpectError - filledarrayBy( false, 8, clbk ); // $ExpectError - filledarrayBy( true, 8, clbk ); // $ExpectError - filledarrayBy( null, 8, clbk ); // $ExpectError - filledarrayBy( undefined, 8, clbk ); // $ExpectError - filledarrayBy( [], 8, clbk ); // $ExpectError - filledarrayBy( {}, 8, clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, clbk ); // $ExpectError - - filledarrayBy( '5', 8, clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, clbk, {} ); // $ExpectError - filledarrayBy( false, 8, clbk, {} ); // $ExpectError - filledarrayBy( true, 8, clbk, {} ); // $ExpectError - filledarrayBy( null, 8, clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, clbk, {} ); // $ExpectError - filledarrayBy( [], 8, clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 'float64', clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( false, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( [], 8, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 'float64', clbk ); // $ExpectError - - filledarrayBy( '5', 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 2, clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 2, clbk ); // $ExpectError - filledarrayBy( false, 8, 2, clbk ); // $ExpectError - filledarrayBy( true, 8, 2, clbk ); // $ExpectError - filledarrayBy( null, 8, 2, clbk ); // $ExpectError - filledarrayBy( undefined, 8, 2, clbk ); // $ExpectError - filledarrayBy( [], 8, 2, clbk ); // $ExpectError - filledarrayBy( {}, 8, 2, clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, clbk ); // $ExpectError - - filledarrayBy( '5', 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( false, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( [], 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, 'float64', clbk ); // $ExpectError - - filledarrayBy( '5', 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a byte offset argument which is not a number... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, false, clbk ); // $ExpectError - filledarrayBy( buf, true, clbk ); // $ExpectError - filledarrayBy( buf, null, clbk ); // $ExpectError - filledarrayBy( buf, [], clbk ); // $ExpectError - filledarrayBy( buf, {}, clbk ); // $ExpectError - - filledarrayBy( buf, false, clbk, {} ); // $ExpectError - filledarrayBy( buf, true, clbk, {} ); // $ExpectError - filledarrayBy( buf, null, clbk, {} ); // $ExpectError - filledarrayBy( buf, [], clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, clbk, {} ); // $ExpectError - - filledarrayBy( buf, '5', 'float64', clbk ); // $ExpectError - filledarrayBy( buf, false, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, true, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, null, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, [], 'float64', clbk ); // $ExpectError - filledarrayBy( buf, {}, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, '5', 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( buf, false, 2, clbk ); // $ExpectError - filledarrayBy( buf, true, 2, clbk ); // $ExpectError - filledarrayBy( buf, null, 2, clbk ); // $ExpectError - filledarrayBy( buf, [], 2, clbk ); // $ExpectError - filledarrayBy( buf, {}, 2, clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, clbk ); // $ExpectError - - filledarrayBy( buf, false, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, clbk, {} ); // $ExpectError - - filledarrayBy( buf, '5', 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, false, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, true, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, null, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, undefined, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, [], 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, {}, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, '5', 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, false, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, undefined, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a view length argument which is not a number... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, 8, false, clbk ); // $ExpectError - filledarrayBy( buf, 8, true, clbk ); // $ExpectError - filledarrayBy( buf, 8, null, clbk ); // $ExpectError - filledarrayBy( buf, 8, [], clbk ); // $ExpectError - filledarrayBy( buf, 8, {}, clbk ); // $ExpectError - - filledarrayBy( buf, 8, false, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, true, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, null, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, [], clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, {}, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, clbk, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5', 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, false, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, true, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, null, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, [], 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, {}, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, 8, '5', 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, [], 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, {}, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided too many arguments... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, 8, 2, 'float64', 1, clbk, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 997a381..0000000 --- a/examples/index.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ).factory; -var dtypes = require( '@stdlib/array-typed-real-dtypes' ); -var filledarrayBy = require( './../lib' ); - -// Create a pseudorandom number generator: -var rand = discreteUniform( 0, 100 ); - -// Get a list of array data types: -var dt = dtypes(); - -// Generate filled arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = filledarrayBy( 10, dt[ i ], rand ); - console.log( arr ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 764e40e..cb63cd1 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, RealOrComplexTypedArray, BooleanArray, DataType } from '@stdlib/types/array'; import { IterableIterator } from '@stdlib/types/iter'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..668c2f7 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@v0.0.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-ctors@v0.3.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill-by@v0.2.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled-by@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@v0.2.2-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.3.0-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";var v=f(),g=j.get("dtypes.default");function c(){var f,j,c,b,y,x,u,E;if(0===(j=arguments.length))return new(y=d(g))(0);if(r(c=arguments[0])){if(j>1)throw new TypeError(w("00h05"));if(null===(y=d(c)))throw new TypeError(w("00h2Y",c));return new y(0)}if(j<2)throw new TypeError(w("00h05"));if(h(arguments[j-=1]))if(h(arguments[j-1])){if(f=arguments[j],b=arguments[j-=1],0===j)throw new TypeError(w("00h05"))}else b=arguments[j];else{if(!(j>=2))throw new TypeError(w("00h05"));if(f=arguments[j],!h(b=arguments[j-=1]))throw new TypeError(w("00h2b",b))}if((j-=1)>=0&&r(arguments[j])?(c=arguments[j],j-=1):c=g,null===(y=d(c)))throw new TypeError(w("00h2Y",c));if("generic"===c){if(E=arguments[0],0===j){if(e(E)?u=E:i(E)&&(u=E.length),void 0!==u)return m(u,b,f);if(n(E))throw new Error(w("00h04"));if(o(E)){if(!1===v)throw new TypeError(w("00h2Z",E));if(!h(E[p]))throw new TypeError(w("00h2a",E));if(E=E[p](),!h(E.next))throw new TypeError(w("00h2a",E));return function(r,e,t){var s,i;for(s=[],i=-1;!r.next().done;)i+=1,s.push(e.call(t,i));return s}(E,b,f)}throw new TypeError(w("00h2a",E))}if(n(E))throw new Error(w("00h04"));throw new TypeError(w("00h2a",E))}if(0===j)if(i(E=arguments[0]))x=new y(E.length);else if(n(E))x=new y(E);else if(e(E))x=new y(E);else{if(!o(E))throw new TypeError(w("00h2a",E));if(!1===v)throw new TypeError(w("00h2Z",E));if(!h(E[p]))throw new TypeError(w("00h2a",E));if(E=E[p](),!h(E.next))throw new TypeError(w("00h2a",E));x=new y(a(E))}else x=1===j?new y(arguments[0],arguments[1]):new y(arguments[0],arguments[1],arguments[2]);return x.length>0&&(t(c)||s(c)?function(r,e,t){var s;for(s=0;s\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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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( format('00h05') );\n\t\t}\n\t\tctor = ctors( dtype );\n\t\tif ( ctor === null ) {\n\t\t\tthrow new TypeError( format( '00h2Y', 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( format('00h05') );\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( format('00h05') );\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( '00h2b', 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( format('00h05') );\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( '00h2Y', 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( format('00h04') );\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( '00h2Z', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00h2a', 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( '00h2a', 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( '00h2a', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format('00h04') );\n\t\t}\n\t\tthrow new TypeError( format( '00h2a', 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( '00h2Z', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00h2a', 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( '00h2a', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00h2a', 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\nexport default filledarrayBy;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","DEFAULT_DTYPE","defaults","get","filledarrayBy","thisArg","nargs","dtype","clbk","ctor","arr","len","arg","arguments","length","ctors","isString","TypeError","format","isFunction","isNonNegativeInteger","isCollection","filledArray","isArrayBuffer","Error","isObject","ITERATOR_SYMBOL","next","it","i","done","push","call","filledArrayIterator","iterLength","isComplexDataType","isBooleanDataType","set","filledAccessors","gfillBy","value","aidx"],"mappings":";;sjDA0CA,IAAIA,EAAsBC,IACtBC,EAAgBC,EAASC,IAAK,kBA2MlC,SAASC,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAKJ,GAAe,KAHfN,EAAQO,UAAUC,QAKjB,OAAO,IADPL,EAAOM,EAAOd,IACG,GAIlB,GAAKe,EADLT,EAAQM,UAAW,IACM,CAExB,GAAKP,EAAQ,EACZ,MAAM,IAAIW,UAAWC,EAAO,UAG7B,GAAc,QADdT,EAAOM,EAAOR,IAEb,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,OAAO,IAAIE,EAAM,EACjB,CAED,GAAKH,EAAQ,EACZ,MAAM,IAAIW,UAAWC,EAAO,UAM7B,GAAKC,EAAYN,UAHjBP,GAAS,IAKR,GAAKa,EAAYN,UAAWP,EAAM,KAMjC,GALAD,EAAUQ,UAAWP,GAErBE,EAAOK,UADPP,GAAS,GAIM,IAAVA,EACJ,MAAM,IAAIW,UAAWC,EAAO,eAI7BV,EAAOK,UAAWP,OAIf,MAAKA,GAAS,GAUlB,MAAM,IAAIW,UAAWC,EAAO,UAN5B,GAHAb,EAAUQ,UAAWP,IAGfa,EADNX,EAAOK,UADPP,GAAS,IAGR,MAAM,IAAIW,UAAWC,EAAQ,QAASV,GAMvC,CAUD,IARAF,GAAS,IACK,GAAKU,EAAUH,UAAWP,KACvCC,EAAQM,UAAWP,GACnBA,GAAS,GAETC,EAAQN,EAGK,QADdQ,EAAOM,EAAOR,IAEb,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,GAAe,YAAVA,EAAsB,CAE1B,GADAK,EAAMC,UAAW,GACF,IAAVP,EAAc,CAMlB,GALKc,EAAsBR,GAC1BD,EAAMC,EACKS,EAAcT,KACzBD,EAAMC,EAAIE,aAEE,IAARH,EACJ,OAAOW,EAAaX,EAAKH,EAAMH,GAEhC,GAAKkB,EAAeX,GACnB,MAAM,IAAIY,MAAON,EAAO,UAEzB,GAAKO,EAAUb,GAAQ,CACtB,IAA6B,IAAxBb,EACJ,MAAM,IAAIkB,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAYP,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLP,EAAYP,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvC,OAvSJ,SAA8BgB,EAAIpB,EAAMH,GACvC,IAAIK,EACAmB,EAKJ,IAFAnB,EAAM,GACNmB,GAAK,GAEAD,EAAGD,OACAG,MAGPD,GAAK,EACLnB,EAAIqB,KAAMvB,EAAKwB,KAAM3B,EAASwB,IAE/B,OAAOnB,CACR,CAuRWuB,CAAqBrB,EAAKJ,EAAMH,EACvC,CACD,MAAM,IAAIY,UAAWC,EAAQ,QAASN,GACzC,CAAS,GAAKW,EAAeX,GAC1B,MAAM,IAAIY,MAAON,EAAO,UAEzB,MAAM,IAAID,UAAWC,EAAQ,QAASN,GACtC,CACD,GAAe,IAAVN,EAEJ,GAAKe,EADLT,EAAMC,UAAW,IAEhBH,EAAM,IAAID,EAAMG,EAAIE,aACd,GAAKS,EAAeX,GAC1BF,EAAM,IAAID,EAAMG,QACV,GAAKQ,EAAsBR,GACjCF,EAAM,IAAID,EAAMG,OACV,KAAKa,EAAUb,GAarB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAZtC,IAA6B,IAAxBb,EACJ,MAAM,IAAIkB,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAYP,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLP,EAAYP,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvCF,EAAM,IAAID,EAAMyB,EAAYtB,GAG5B,MAEDF,EADqB,IAAVJ,EACL,IAAIG,EAAMI,UAAU,GAAIA,UAAU,IAElC,IAAIJ,EAAMI,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKH,EAAII,OAAS,IACZqB,EAAmB5B,IAAW6B,EAAmB7B,GAjTxD,SAA0BG,EAAKF,EAAMH,GACpC,IAAIwB,EACJ,IAAMA,EAAI,EAAGA,EAAInB,EAAII,OAAQe,IAC5BnB,EAAI2B,IAAK7B,EAAKwB,KAAM3B,EAASwB,GAAKA,EAGpC,CA4SGS,CAAiB5B,EAAKF,EAAMH,GAE5BkC,EAAS7B,EAAII,OAAQJ,EAAK,GAe5B,SAAmB8B,EAAOC,GACzB,OAAOjC,EAAKwB,KAAM3B,EAASoC,EAC3B,KAdM/B,CAeR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d115cf0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,192 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -/** -* Create a filled array according to a provided callback function. -* -* @module @stdlib/array-filled-by -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* var arr = filledarrayBy(); -* // returns -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'generic', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( [ 0.5, 0.5 ], clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1; -* } -* -* var arr = filledarrayBy( [ 5, -3 ], 'int32', clbk ); -* // returns [ 1, 1 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk1() { -* return 10; -* } -* -* function clbk2() { -* return 1.0; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, clbk2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk1() { -* return 1.0; -* } -* -* function clbk2() { -* return 2; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, 'uint32', clbk2 ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 'float32', clbk ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, clbk ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, 'int32', clbk ); -* // returns [ 1, 1 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index ed1aa9a..0000000 --- a/lib/main.js +++ /dev/null @@ -1,416 +0,0 @@ -/** -* @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 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' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var ctors = require( '@stdlib/array-ctors' ); -var gfillBy = require( '@stdlib/blas-ext-base-gfill-by' ); -var filledArray = require( '@stdlib/array-base-filled-by' ); -var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var iterLength = require( '@stdlib/iter-length' ); -var defaults = require( '@stdlib/array-defaults' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport(); -var DEFAULT_DTYPE = defaults.get( 'dtypes.default' ); - - -// FUNCTIONS // - -/** -* Creates a filled "generic" array from an iterator. -* -* @private -* @param {Iterable} it - iterator -* @param {Callback} clbk - callback function -* @param {*} thisArg - callback function execution context -* @returns {Array} filled array -*/ -function filledArrayIterator( it, clbk, thisArg ) { - var arr; - var i; - var v; - - arr = []; - i = -1; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - i += 1; - arr.push( clbk.call( thisArg, i ) ); - } - return arr; -} - -/** -* Fills an array exposing accessors for getting and setting array elements. -* -* @private -* @param {Collection} arr - input array -* @param {Callback} clbk - callback function -* @param {*} thisArg - callback function execution context -* @returns {Collection} input array -*/ -function filledAccessors( arr, clbk, thisArg ) { - var i; - for ( i = 0; i < arr.length; i++ ) { - arr.set( clbk.call( thisArg, i ), i ); - } - return arr; -} - - -// MAIN // - -/** -* Creates a filled array according to a provided callback function. -* -* @param {(NonNegativeInteger|TypedArray|ArrayLikeObject|ArrayBuffer|Iterable)} [arg] - a length, typed array, array-like object, buffer, or iterable -* @param {NonNegativeInteger} [byteOffset=0] - byte offset -* @param {NonNegativeInteger} [length] - view length -* @param {string} [dtype="float64"] - data type -* @param {Callback} [clbk] - callback to invoke -* @param {*} [thisArg] - callback execution context -* @throws {TypeError} must provide a recognized data type -* @throws {TypeError} must provide a length, typed array, array-like object, buffer, or iterable -* @throws {TypeError} callback argument must be a function. -* @throws {Error} creating a generic array from an `ArrayBuffer` is not supported -* @returns {(TypedArray|Array)} array or typed array -* -* @example -* var arr = filledarrayBy(); -* // returns -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'generic', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( [ 0.5, 0.5 ], clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1; -* } -* -* var arr = filledarrayBy( [ 5, -3 ], 'int32', clbk ); -* // returns [ 1, 1 ] -* -* @example -* function clbk1() { -* return 10; -* } -* -* function clbk2() { -* return 1.0; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, clbk2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk1() { -* return 1.0; -* } -* -* function clbk2() { -* return 2; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, 'uint32', clbk2 ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 'float32', clbk ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, clbk ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, 'int32', clbk ); -* // returns [ 1, 1 ] -*/ -function filledarrayBy() { - var thisArg; - var nargs; - var dtype; - var clbk; - var ctor; - var arr; - var len; - var arg; - - nargs = arguments.length; - - // If we weren't provided any arguments, return an empty array... - if ( nargs === 0 ) { - ctor = ctors( DEFAULT_DTYPE ); - return new ctor( 0 ); - } - // Check if we were provided a dtype as the first argument... - dtype = arguments[ 0 ]; - if ( isString( dtype ) ) { - // Invoking this function with arguments `f( dtype, clbk[, thisArg] )` is not allowed (otherwise, we'd need to also allow `f( clbk[, thisArg] )`)... - if ( nargs > 1 ) { - throw new TypeError( format('00h05') ); - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '00h2Y', dtype ) ); - } - // Return an empty array having the specified dtype: - return new ctor( 0 ); - } - // For all other supported invocations, we need at least two arguments... - if ( nargs < 2 ) { - throw new TypeError( format('00h05') ); - } - // At this point, we need to do some argument juggling... - nargs -= 1; // henceforth, the number of available arguments is `nargs+1` - - // Determine whether the last argument is a callback or "this" context... - if ( isFunction( arguments[ nargs ] ) ) { - // 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... - if ( isFunction( arguments[ nargs-1 ] ) ) { - thisArg = arguments[ nargs ]; - nargs -= 1; - clbk = arguments[ nargs ]; - - // Check if we were provided only a callback and a "this" context.. - if ( nargs === 0 ) { - throw new TypeError( format('00h05') ); - } - } else { - // "this" context is left undefined... - clbk = arguments[ nargs ]; - } - } - // 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... - else if ( nargs >= 2 ) { - thisArg = arguments[ nargs ]; - nargs -= 1; - clbk = arguments[ nargs ]; - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '00h2b', clbk ) ); - } - } - // If were were only provided 2 arguments and the last argument was not a function, we've been provided an insufficient number of arguments... - else { - throw new TypeError( format('00h05') ); - } - // Now that we've processed the callback arguments, let's continue working backward to see if we've been provided a `dtype` argument... - nargs -= 1; - if ( nargs >= 0 && isString( arguments[ nargs ] ) ) { - dtype = arguments[ nargs ]; - nargs -= 1; - } else { - dtype = DEFAULT_DTYPE; - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '00h2Y', dtype ) ); - } - // At this point, we've resolved the output array data type, and now we can actually create the output array... - if ( dtype === 'generic' ) { - arg = arguments[ 0 ]; - if ( nargs === 0 ) { - if ( isNonNegativeInteger( arg ) ) { - len = arg; - } else if ( isCollection( arg ) ) { - len = arg.length; - } - if ( len !== void 0 ) { - return filledArray( len, clbk, thisArg ); - } - if ( isArrayBuffer( arg ) ) { - throw new Error( format('00h04') ); - } - if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( '00h2Z', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00h2a', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00h2a', arg ) ); - } - return filledArrayIterator( arg, clbk, thisArg ); - } - throw new TypeError( format( '00h2a', arg ) ); - } else if ( isArrayBuffer( arg ) ) { - throw new Error( format('00h04') ); - } - throw new TypeError( format( '00h2a', arg ) ); - } - if ( nargs === 0 ) { // length || array-like || ArrayBuffer || iterable - arg = arguments[ 0 ]; - if ( isCollection( arg ) ) { - arr = new ctor( arg.length ); - } else if ( isArrayBuffer( arg ) ) { - arr = new ctor( arg ); - } else if ( isNonNegativeInteger( arg ) ) { - arr = new ctor( arg ); - } else if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( '00h2Z', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00h2a', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00h2a', arg ) ); - } - arr = new ctor( iterLength( arg ) ); - } else { - throw new TypeError( format( '00h2a', arg ) ); - } - } else if ( nargs === 1 ) { - arr = new ctor( arguments[0], arguments[1] ); // (ArrayBuffer, byteOffset) - } else { - arr = new ctor( arguments[0], arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset, length) - } - if ( arr.length > 0 ) { - if ( isComplexDataType( dtype ) || isBooleanDataType( dtype ) ) { - filledAccessors( arr, clbk, thisArg ); - } else { - gfillBy( arr.length, arr, 1, callback ); - } - } - return arr; - - /** - * Callback which wraps a provided callback and is invoked for each array element. - * - * @private - * @param {*} value - element value - * @param {NonNegativeInteger} aidx - array index - * @param {NonNegativeInteger} sidx - strided index - * @param {Collection} array - input array/collection - * @returns {*} callback return value - */ - function callback( value, aidx ) { - return clbk.call( thisArg, aidx ); - } -} - - -// EXPORTS // - -module.exports = filledarrayBy; diff --git a/package.json b/package.json index b5ac3ab..b16be36 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Create a filled array according to a provided callback function.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,75 +13,6 @@ "bugs": { "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.2", - "@stdlib/array-ctors": "^0.3.0", - "@stdlib/array-defaults": "^0.3.0", - "@stdlib/assert-has-iterator-symbol-support": "^0.2.2", - "@stdlib/assert-is-arraybuffer": "^0.2.2", - "@stdlib/assert-is-collection": "^0.2.2", - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer": "^0.2.2", - "@stdlib/assert-is-object": "^0.2.2", - "@stdlib/assert-is-string": "^0.2.2", - "@stdlib/blas-ext-base-gfill-by": "^0.2.1", - "@stdlib/iter-length": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/symbol-iterator": "^0.2.2", - "@stdlib/types": "^0.4.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-bool": "^0.1.0", - "@stdlib/array-buffer": "^0.2.2", - "@stdlib/array-complex128": "^0.3.0", - "@stdlib/array-complex64": "^0.3.0", - "@stdlib/array-float32": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/array-int16": "^0.2.2", - "@stdlib/array-int32": "^0.2.2", - "@stdlib/array-int8": "^0.2.2", - "@stdlib/array-typed-real-dtypes": "^0.2.2", - "@stdlib/array-uint16": "^0.2.2", - "@stdlib/array-uint32": "^0.2.2", - "@stdlib/array-uint8": "^0.2.2", - "@stdlib/array-uint8c": "^0.2.2", - "@stdlib/assert-instance-of": "^0.2.2", - "@stdlib/assert-is-array": "^0.2.2", - "@stdlib/assert-is-typed-array": "^0.2.2", - "@stdlib/assert-is-typed-array-like": "^0.2.2", - "@stdlib/complex-float32-ctor": "^0.0.2", - "@stdlib/complex-float64-ctor": "^0.0.3", - "@stdlib/iter-constant": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/random-base-discrete-uniform": "^0.2.1", - "@stdlib/strided-base-reinterpret-boolean": "^0.0.2", - "@stdlib/strided-base-reinterpret-complex128": "^0.2.2", - "@stdlib/strided-base-reinterpret-complex64": "^0.2.1", - "@stdlib/utils-constant-function": "^0.2.2", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..e4cee9c --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index ca0cf25..0000000 --- a/test/test.js +++ /dev/null @@ -1,4397 +0,0 @@ -/** -* @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. -*/ - -/* eslint-disable max-len */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -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' ); -var iterConstant = require( '@stdlib/iter-constant' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var filledarrayBy = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': !hasIteratorSymbolSupport() -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof filledarrayBy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if only provided callback arguments', function test( t ) { - t.throws( clbk1, TypeError, 'throws an error' ); - t.throws( clbk2, TypeError, 'throws an error' ); - t.throws( clbk3, TypeError, 'throws an error' ); - t.end(); - - function clbk1() { - filledarrayBy( constantFunction( 1.0 ) ); - } - - function clbk2() { - filledarrayBy( constantFunction( 1.0 ), {} ); - } - - function clbk3() { - filledarrayBy( constantFunction( 1.0 ), constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (only argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (typed array; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (array-like object)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (array-like object; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 8 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 8 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, 1, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (iterator)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( iterConstant( 1.0 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (iterator; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( iterConstant( 1.0 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if only provided data type and callback arguments', function test( t ) { - t.throws( clbk1, TypeError, 'throws an error' ); - t.throws( clbk2, TypeError, 'throws an error' ); - t.throws( clbk3, TypeError, 'throws an error' ); - t.end(); - - function clbk1() { - filledarrayBy( 'float64', constantFunction( 1.0 ) ); - } - - function clbk2() { - filledarrayBy( 'float64', constantFunction( 1.0 ), {} ); - } - - function clbk3() { - filledarrayBy( 'float64', constantFunction( 1.0 ), constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (array-like object)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (array-like object; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, 1, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, 1, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (no iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (no iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (non-function iterator symbol property)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (non-function iterator symbol property; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (`next` property is not a function)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ) ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (`next` property is not a function; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ), {} ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (no iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (no iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (non-function iterator symbol property)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (non-function iterator symbol property; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (`next` property is not a function)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ) ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (`next` property is not a function; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ), {} ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 1, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 1, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function returns a filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - arr = filledarrayBy(); - - t.strictEqual( instanceOf( arr, Float64Array ), 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=float64)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - arr = filledarrayBy( 'float64' ); - - t.strictEqual( instanceOf( arr, Float64Array ), 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=float32)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( 0 ); - arr = filledarrayBy( 'float32' ); - - t.strictEqual( instanceOf( arr, Float32Array ), 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=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; - - expected = new Complex128Array( 0 ); - arr = filledarrayBy( 'complex128' ); - - t.strictEqual( instanceOf( arr, Complex128Array ), 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=complex64)', function test( t ) { - var expected; - var arr; - - expected = new Complex64Array( 0 ); - arr = filledarrayBy( 'complex64' ); - - t.strictEqual( instanceOf( arr, Complex64Array ), 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=int32)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( 0 ); - arr = filledarrayBy( 'int32' ); - - t.strictEqual( instanceOf( arr, Int32Array ), 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=uint32)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( 0 ); - arr = filledarrayBy( 'uint32' ); - - t.strictEqual( instanceOf( arr, Uint32Array ), 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=int16)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( 0 ); - arr = filledarrayBy( 'int16' ); - - t.strictEqual( instanceOf( arr, Int16Array ), 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=uint16)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( 0 ); - arr = filledarrayBy( 'uint16' ); - - t.strictEqual( instanceOf( arr, Uint16Array ), 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=int8)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( 0 ); - arr = filledarrayBy( 'int8' ); - - t.strictEqual( instanceOf( arr, Int8Array ), 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=uint8)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( 0 ); - arr = filledarrayBy( 'uint8' ); - - t.strictEqual( instanceOf( arr, Uint8Array ), 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=uint8c)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( 0 ); - arr = filledarrayBy( 'uint8c' ); - - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), 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=generic)', function test( t ) { - var expected; - var arr; - - expected = []; - arr = filledarrayBy( 'generic' ); - - t.strictEqual( instanceOf( arr, Array ), 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 (default, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, length=0)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array(); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 0, clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, clbk, ctx ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (default, length; thisArg=function)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, clbk, context ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this(); // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } - - function context() { - ctx.count += 1; - } -}); - -tape( 'the function returns a filled array (dtype=float64, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, 'float64', clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, length; thisArg=function)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, 'float64', clbk, context ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this(); // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } - - function context() { - ctx.count += 1; - } -}); - -tape( 'the function returns a filled array (dtype=float32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, 'float32', clbk ); - - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - 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; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = filledarrayBy( 5, 'complex128', clbk ); - - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = filledarrayBy( 5, 'complex64', clbk ); - - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int32Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int32', clbk ); - - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint32Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint32', clbk ); - - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int16Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int16', clbk ); - - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint16', clbk ); - - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int8Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int8', clbk ); - - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint8', clbk ); - - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint8c', clbk ); - - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = [ 1, 1, 1, 1, 1 ]; - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'generic', clbk ); - - t.strictEqual( instanceOf( arr, Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - 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; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = [ 1.0, 2.0 ]; - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = [ 1.0, 2.0 ]; - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int32', clbk ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, typed array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, typed array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - 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; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = new Float64Array( [ 1.0, 2.0 ] ); - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = new Float64Array( [ 1.0, 2.0 ] ); - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (default, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - 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; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer, byteoffset; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer, byteoffset; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - 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; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 48 ); - out = filledarrayBy( buf, 16, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 24 ); - out = filledarrayBy( buf, 8, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int32', clbk ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint8c', clbk ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - 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; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 64 ); - out = filledarrayBy( buf, 16, 2, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset, length)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 1, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 1, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled array (default, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, iterator; thisArg)', opts, function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - ctx = { - 'count': 0 - }; - indices = []; - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, iterator; thisArg)', opts, function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - ctx = { - 'count': 0 - }; - indices = []; - out = filledarrayBy( arr, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - 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; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = iterConstant( new Complex128( 3.0, 3.0 ), { - 'iter': 2 - }); - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = iterConstant( new Complex64( 3.0, 3.0 ), { - 'iter': 2 - }); - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); From 740ee74d2882132ea2ad7804e3e96f0b812a1020 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 19 May 2025 01:27:38 +0000 Subject: [PATCH 081/117] Transform error messages --- lib/main.js | 38 +++++++++++++++++++------------------- package.json | 2 +- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/lib/main.js b/lib/main.js index b322cfe..ed1aa9a 100644 --- a/lib/main.js +++ b/lib/main.js @@ -35,7 +35,7 @@ var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-supp var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); var iterLength = require( '@stdlib/iter-length' ); var defaults = require( '@stdlib/array-defaults' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -266,18 +266,18 @@ function filledarrayBy() { if ( isString( dtype ) ) { // Invoking this function with arguments `f( dtype, clbk[, thisArg] )` is not allowed (otherwise, we'd need to also allow `f( clbk[, thisArg] )`)... if ( nargs > 1 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format('00h05') ); } ctor = ctors( dtype ); if ( ctor === null ) { - throw new TypeError( format( 'invalid argument. Must provide a recognized data type. Value: `%s`.', dtype ) ); + throw new TypeError( format( '00h2Y', dtype ) ); } // Return an empty array having the specified dtype: return new ctor( 0 ); } // For all other supported invocations, we need at least two arguments... if ( nargs < 2 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format('00h05') ); } // At this point, we need to do some argument juggling... nargs -= 1; // henceforth, the number of available arguments is `nargs+1` @@ -292,7 +292,7 @@ function filledarrayBy() { // Check if we were provided only a callback and a "this" context.. if ( nargs === 0 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format('00h05') ); } } else { // "this" context is left undefined... @@ -305,12 +305,12 @@ function filledarrayBy() { nargs -= 1; clbk = arguments[ nargs ]; if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '00h2b', clbk ) ); } } // If were were only provided 2 arguments and the last argument was not a function, we've been provided an insufficient number of arguments... else { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format('00h05') ); } // Now that we've processed the callback arguments, let's continue working backward to see if we've been provided a `dtype` argument... nargs -= 1; @@ -322,7 +322,7 @@ function filledarrayBy() { } ctor = ctors( dtype ); if ( ctor === null ) { - throw new TypeError( format( 'invalid argument. Must provide a recognized data type. Value: `%s`.', dtype ) ); + throw new TypeError( format( '00h2Y', dtype ) ); } // At this point, we've resolved the output array data type, and now we can actually create the output array... if ( dtype === 'generic' ) { @@ -337,26 +337,26 @@ function filledarrayBy() { return filledArray( len, clbk, thisArg ); } if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format('00h04') ); } if ( isObject( arg ) ) { if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2Z', arg ) ); } if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } arg = arg[ ITERATOR_SYMBOL ](); if ( !isFunction( arg.next ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } return filledArrayIterator( arg, clbk, thisArg ); } - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } else if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format('00h04') ); } - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } if ( nargs === 0 ) { // length || array-like || ArrayBuffer || iterable arg = arguments[ 0 ]; @@ -368,18 +368,18 @@ function filledarrayBy() { arr = new ctor( arg ); } else if ( isObject( arg ) ) { if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2Z', arg ) ); } if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } arg = arg[ ITERATOR_SYMBOL ](); if ( !isFunction( arg.next ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } arr = new ctor( iterLength( arg ) ); } else { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } } else if ( nargs === 1 ) { arr = new ctor( arguments[0], arguments[1] ); // (ArrayBuffer, byteOffset) diff --git a/package.json b/package.json index 42e92b1..b5ac3ab 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "@stdlib/assert-is-string": "^0.2.2", "@stdlib/blas-ext-base-gfill-by": "^0.2.1", "@stdlib/iter-length": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/symbol-iterator": "^0.2.2", "@stdlib/types": "^0.4.3", "@stdlib/error-tools-fmtprodmsg": "^0.2.2" From 3c4e3271f89e598a31901e841b066d8a6e32ab5f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 19 May 2025 02:43:19 +0000 Subject: [PATCH 082/117] Remove files --- index.d.ts | 322 ---- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5169 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index cb63cd1..0000000 --- a/index.d.ts +++ /dev/null @@ -1,322 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, RealOrComplexTypedArray, BooleanArray, DataType } from '@stdlib/types/array'; -import { IterableIterator } from '@stdlib/types/iter'; - -/** -* Array or typed array. -*/ -type ArrayOrTypedArray = Array | RealOrComplexTypedArray | BooleanArray; - -/** -* Nullary callback function. -* -* @returns fill value -*/ -type Nullary = () => any; - -/** -* Unary callback function. -* -* @param i - current array index -* @returns fill value -*/ -type Unary = ( i: number ) => any; - -/** -* Callback function. -* -* @param i - current array index -* @returns fill value -*/ -type Callback = Nullary | Unary; - -/** -* Creates a filled array according to a provided callback function and having a specified data type. -* -* @param dtype - data type -* @returns filled array -* -* @example -* var arr = filledarrayBy(); -* // returns -* -* @example -* var arr = filledarrayBy( 'float32' ); -* // returns -*/ -declare function filledarrayBy( dtype?: DataType ): ArrayOrTypedArray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Creates a filled array according to a provided callback function and having a specified `length`. -* -* @param length - array length -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* -* var arr = filledarrayBy( 5, constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( length: number, clbk: Callback, thisArg?: any ): ArrayOrTypedArray; - -/** -* Creates a filled array according to a provided callback function and having a specified `length`. -* -* @param length - array length -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* -* var arr = filledarrayBy( 5, 'float64', constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( length: number, dtype: DataType, clbk: Callback, thisArg?: any ): ArrayOrTypedArray; - -/** -* Creates a filled array from another `array` according to a provided callback function. -* -* @param array - typed array or array-like object -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* -* 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; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Creates a filled array from another `array` according to a provided callback function. -* -* @param array - typed array or array-like object -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* -* 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; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Creates a filled array from an iterable according to a callback function. -* -* @param iterable - iterable -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var iterConstant = require( '@stdlib/iter-constant' ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarrayBy( it, constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( iterable: IterableIterator, clbk: Callback, thisArg?: any ): ArrayOrTypedArray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Creates a filled array from an iterable according to a callback function. -* -* @param iterable - iterable -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var iterConstant = require( '@stdlib/iter-constant' ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarrayBy( it, 'float64', constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( iterable: IterableIterator, dtype: DataType, clbk: 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. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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 | BooleanArray; - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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 | BooleanArray; - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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 | BooleanArray; - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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 | BooleanArray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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 | BooleanArray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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 | BooleanArray; // eslint-disable-line @typescript-eslint/unified-signatures - - -// EXPORTS // - -export = filledarrayBy; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 668c2f7..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@v0.0.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-ctors@v0.3.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill-by@v0.2.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled-by@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@v0.2.2-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.3.0-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";var v=f(),g=j.get("dtypes.default");function c(){var f,j,c,b,y,x,u,E;if(0===(j=arguments.length))return new(y=d(g))(0);if(r(c=arguments[0])){if(j>1)throw new TypeError(w("00h05"));if(null===(y=d(c)))throw new TypeError(w("00h2Y",c));return new y(0)}if(j<2)throw new TypeError(w("00h05"));if(h(arguments[j-=1]))if(h(arguments[j-1])){if(f=arguments[j],b=arguments[j-=1],0===j)throw new TypeError(w("00h05"))}else b=arguments[j];else{if(!(j>=2))throw new TypeError(w("00h05"));if(f=arguments[j],!h(b=arguments[j-=1]))throw new TypeError(w("00h2b",b))}if((j-=1)>=0&&r(arguments[j])?(c=arguments[j],j-=1):c=g,null===(y=d(c)))throw new TypeError(w("00h2Y",c));if("generic"===c){if(E=arguments[0],0===j){if(e(E)?u=E:i(E)&&(u=E.length),void 0!==u)return m(u,b,f);if(n(E))throw new Error(w("00h04"));if(o(E)){if(!1===v)throw new TypeError(w("00h2Z",E));if(!h(E[p]))throw new TypeError(w("00h2a",E));if(E=E[p](),!h(E.next))throw new TypeError(w("00h2a",E));return function(r,e,t){var s,i;for(s=[],i=-1;!r.next().done;)i+=1,s.push(e.call(t,i));return s}(E,b,f)}throw new TypeError(w("00h2a",E))}if(n(E))throw new Error(w("00h04"));throw new TypeError(w("00h2a",E))}if(0===j)if(i(E=arguments[0]))x=new y(E.length);else if(n(E))x=new y(E);else if(e(E))x=new y(E);else{if(!o(E))throw new TypeError(w("00h2a",E));if(!1===v)throw new TypeError(w("00h2Z",E));if(!h(E[p]))throw new TypeError(w("00h2a",E));if(E=E[p](),!h(E.next))throw new TypeError(w("00h2a",E));x=new y(a(E))}else x=1===j?new y(arguments[0],arguments[1]):new y(arguments[0],arguments[1],arguments[2]);return x.length>0&&(t(c)||s(c)?function(r,e,t){var s;for(s=0;s\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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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( format('00h05') );\n\t\t}\n\t\tctor = ctors( dtype );\n\t\tif ( ctor === null ) {\n\t\t\tthrow new TypeError( format( '00h2Y', 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( format('00h05') );\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( format('00h05') );\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( '00h2b', 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( format('00h05') );\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( '00h2Y', 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( format('00h04') );\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( '00h2Z', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00h2a', 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( '00h2a', 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( '00h2a', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format('00h04') );\n\t\t}\n\t\tthrow new TypeError( format( '00h2a', 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( '00h2Z', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00h2a', 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( '00h2a', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00h2a', 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\nexport default filledarrayBy;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","DEFAULT_DTYPE","defaults","get","filledarrayBy","thisArg","nargs","dtype","clbk","ctor","arr","len","arg","arguments","length","ctors","isString","TypeError","format","isFunction","isNonNegativeInteger","isCollection","filledArray","isArrayBuffer","Error","isObject","ITERATOR_SYMBOL","next","it","i","done","push","call","filledArrayIterator","iterLength","isComplexDataType","isBooleanDataType","set","filledAccessors","gfillBy","value","aidx"],"mappings":";;sjDA0CA,IAAIA,EAAsBC,IACtBC,EAAgBC,EAASC,IAAK,kBA2MlC,SAASC,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAKJ,GAAe,KAHfN,EAAQO,UAAUC,QAKjB,OAAO,IADPL,EAAOM,EAAOd,IACG,GAIlB,GAAKe,EADLT,EAAQM,UAAW,IACM,CAExB,GAAKP,EAAQ,EACZ,MAAM,IAAIW,UAAWC,EAAO,UAG7B,GAAc,QADdT,EAAOM,EAAOR,IAEb,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,OAAO,IAAIE,EAAM,EACjB,CAED,GAAKH,EAAQ,EACZ,MAAM,IAAIW,UAAWC,EAAO,UAM7B,GAAKC,EAAYN,UAHjBP,GAAS,IAKR,GAAKa,EAAYN,UAAWP,EAAM,KAMjC,GALAD,EAAUQ,UAAWP,GAErBE,EAAOK,UADPP,GAAS,GAIM,IAAVA,EACJ,MAAM,IAAIW,UAAWC,EAAO,eAI7BV,EAAOK,UAAWP,OAIf,MAAKA,GAAS,GAUlB,MAAM,IAAIW,UAAWC,EAAO,UAN5B,GAHAb,EAAUQ,UAAWP,IAGfa,EADNX,EAAOK,UADPP,GAAS,IAGR,MAAM,IAAIW,UAAWC,EAAQ,QAASV,GAMvC,CAUD,IARAF,GAAS,IACK,GAAKU,EAAUH,UAAWP,KACvCC,EAAQM,UAAWP,GACnBA,GAAS,GAETC,EAAQN,EAGK,QADdQ,EAAOM,EAAOR,IAEb,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,GAAe,YAAVA,EAAsB,CAE1B,GADAK,EAAMC,UAAW,GACF,IAAVP,EAAc,CAMlB,GALKc,EAAsBR,GAC1BD,EAAMC,EACKS,EAAcT,KACzBD,EAAMC,EAAIE,aAEE,IAARH,EACJ,OAAOW,EAAaX,EAAKH,EAAMH,GAEhC,GAAKkB,EAAeX,GACnB,MAAM,IAAIY,MAAON,EAAO,UAEzB,GAAKO,EAAUb,GAAQ,CACtB,IAA6B,IAAxBb,EACJ,MAAM,IAAIkB,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAYP,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLP,EAAYP,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvC,OAvSJ,SAA8BgB,EAAIpB,EAAMH,GACvC,IAAIK,EACAmB,EAKJ,IAFAnB,EAAM,GACNmB,GAAK,GAEAD,EAAGD,OACAG,MAGPD,GAAK,EACLnB,EAAIqB,KAAMvB,EAAKwB,KAAM3B,EAASwB,IAE/B,OAAOnB,CACR,CAuRWuB,CAAqBrB,EAAKJ,EAAMH,EACvC,CACD,MAAM,IAAIY,UAAWC,EAAQ,QAASN,GACzC,CAAS,GAAKW,EAAeX,GAC1B,MAAM,IAAIY,MAAON,EAAO,UAEzB,MAAM,IAAID,UAAWC,EAAQ,QAASN,GACtC,CACD,GAAe,IAAVN,EAEJ,GAAKe,EADLT,EAAMC,UAAW,IAEhBH,EAAM,IAAID,EAAMG,EAAIE,aACd,GAAKS,EAAeX,GAC1BF,EAAM,IAAID,EAAMG,QACV,GAAKQ,EAAsBR,GACjCF,EAAM,IAAID,EAAMG,OACV,KAAKa,EAAUb,GAarB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAZtC,IAA6B,IAAxBb,EACJ,MAAM,IAAIkB,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAYP,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLP,EAAYP,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvCF,EAAM,IAAID,EAAMyB,EAAYtB,GAG5B,MAEDF,EADqB,IAAVJ,EACL,IAAIG,EAAMI,UAAU,GAAIA,UAAU,IAElC,IAAIJ,EAAMI,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKH,EAAII,OAAS,IACZqB,EAAmB5B,IAAW6B,EAAmB7B,GAjTxD,SAA0BG,EAAKF,EAAMH,GACpC,IAAIwB,EACJ,IAAMA,EAAI,EAAGA,EAAInB,EAAII,OAAQe,IAC5BnB,EAAI2B,IAAK7B,EAAKwB,KAAM3B,EAASwB,GAAKA,EAGpC,CA4SGS,CAAiB5B,EAAKF,EAAMH,GAE5BkC,EAAS7B,EAAII,OAAQJ,EAAK,GAe5B,SAAmB8B,EAAOC,GACzB,OAAOjC,EAAKwB,KAAM3B,EAASoC,EAC3B,KAdM/B,CAeR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index e4cee9c..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 59f821d3bd886d4995f203dcf24a09c521ec8f9d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 19 May 2025 02:43:40 +0000 Subject: [PATCH 083/117] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 194 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 191 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 49 +- SECURITY.md | 5 - benchmark/benchmark.js | 341 -- benchmark/benchmark.length.bool.js | 97 - benchmark/benchmark.length.complex128.js | 98 - benchmark/benchmark.length.complex64.js | 98 - benchmark/benchmark.length.float32.js | 97 - benchmark/benchmark.length.float64.js | 97 - benchmark/benchmark.length.generic.js | 97 - benchmark/benchmark.length.int16.js | 97 - benchmark/benchmark.length.int32.js | 97 - benchmark/benchmark.length.int8.js | 97 - benchmark/benchmark.length.uint16.js | 97 - benchmark/benchmark.length.uint32.js | 97 - benchmark/benchmark.length.uint8.js | 97 - benchmark/benchmark.length.uint8c.js | 97 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 36 - dist/index.js.map | 7 - docs/repl.txt | 157 - docs/types/test.ts | 606 --- examples/index.js | 37 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 192 - lib/main.js | 416 -- package.json | 96 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 4397 ---------------- 57 files changed, 4870 insertions(+), 11148 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.length.bool.js delete mode 100644 benchmark/benchmark.length.complex128.js delete mode 100644 benchmark/benchmark.length.complex64.js delete mode 100644 benchmark/benchmark.length.float32.js delete mode 100644 benchmark/benchmark.length.float64.js delete mode 100644 benchmark/benchmark.length.generic.js delete mode 100644 benchmark/benchmark.length.int16.js delete mode 100644 benchmark/benchmark.length.int32.js delete mode 100644 benchmark/benchmark.length.int8.js delete mode 100644 benchmark/benchmark.length.uint16.js delete mode 100644 benchmark/benchmark.length.uint32.js delete mode 100644 benchmark/benchmark.length.uint8.js delete mode 100644 benchmark/benchmark.length.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 8d6145e..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-05-19T01:27:10.067Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 2d6aaee..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/contributing/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index f988046..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index b2c1f9c..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '42 6 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -278,7 +269,7 @@ for ( i = 0; i < dt.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -347,13 +338,13 @@ Copyright © 2016-2025. 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/dtypes]: https://github.com/stdlib-js/array-dtypes/tree/esm -[@stdlib/array/filled]: https://github.com/stdlib-js/array-filled +[@stdlib/array/filled]: https://github.com/stdlib-js/array-filled/tree/esm -[@stdlib/array/typed]: https://github.com/stdlib-js/array-typed +[@stdlib/array/typed]: https://github.com/stdlib-js/array-typed/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 17cfb5a..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,341 +0,0 @@ -/** -* @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 isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); -var isArray = require( '@stdlib/assert-is-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var Complex64 = require( '@stdlib/complex-float32-ctor' ); -var Complex128 = require( '@stdlib/complex-float64-ctor' ); -var pkg = require( './../package.json' ).name; -var filledarrayBy = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 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=float64', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'float64', 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=float32', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'float32', 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=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; - var i; - - clbk = constantFunction( new Complex128( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'complex128', 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=complex64', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( new Complex64( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'complex64', 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=int32', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int32', 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=uint32', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint32', 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=int16', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int16', 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=uint16', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint16', 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=int8', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int8', 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=uint8', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint8', 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=uint8c', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint8c', 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=generic', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'generic', clbk ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.length.bool.js b/benchmark/benchmark.length.bool.js deleted file mode 100644 index 3cdd152..0000000 --- a/benchmark/benchmark.length.bool.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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/benchmark/benchmark.length.complex128.js b/benchmark/benchmark.length.complex128.js deleted file mode 100644 index 122bc7c..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 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 Complex128 = require( '@stdlib/complex-float64-ctor' ); -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( new Complex128( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'complex128', 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=complex128,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.complex64.js b/benchmark/benchmark.length.complex64.js deleted file mode 100644 index e7a2d74..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 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 Complex64 = require( '@stdlib/complex-float32-ctor' ); -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( new Complex64( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'complex64', 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=complex64,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.float32.js b/benchmark/benchmark.length.float32.js deleted file mode 100644 index d2b2ba7..0000000 --- a/benchmark/benchmark.length.float32.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'float32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=float32,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.float64.js b/benchmark/benchmark.length.float64.js deleted file mode 100644 index 65064e3..0000000 --- a/benchmark/benchmark.length.float64.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'float64', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=float64,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.generic.js b/benchmark/benchmark.length.generic.js deleted file mode 100644 index eb87dfa..0000000 --- a/benchmark/benchmark.length.generic.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isArray = require( '@stdlib/assert-is-array' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'generic', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isArray( 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=generic,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int16.js b/benchmark/benchmark.length.int16.js deleted file mode 100644 index 914ff7c..0000000 --- a/benchmark/benchmark.length.int16.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int16', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=int16,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int32.js b/benchmark/benchmark.length.int32.js deleted file mode 100644 index cc0f678..0000000 --- a/benchmark/benchmark.length.int32.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=int32,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int8.js b/benchmark/benchmark.length.int8.js deleted file mode 100644 index 77553b0..0000000 --- a/benchmark/benchmark.length.int8.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int8', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=int8,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint16.js b/benchmark/benchmark.length.uint16.js deleted file mode 100644 index c68efdd..0000000 --- a/benchmark/benchmark.length.uint16.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint16', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint16,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint32.js b/benchmark/benchmark.length.uint32.js deleted file mode 100644 index 27c1742..0000000 --- a/benchmark/benchmark.length.uint32.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint32,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint8.js b/benchmark/benchmark.length.uint8.js deleted file mode 100644 index 2a26be4..0000000 --- a/benchmark/benchmark.length.uint8.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint8', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint8,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint8c.js b/benchmark/benchmark.length.uint8c.js deleted file mode 100644 index dd6e8c2..0000000 --- a/benchmark/benchmark.length.uint8c.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint8c', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint8c,len='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index c138144..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by" -%% click B href "https://github.com/stdlib-js/array-filled-by/tree/main" -%% click C href "https://github.com/stdlib-js/array-filled-by/tree/production" -%% click D href "https://github.com/stdlib-js/array-filled-by/tree/esm" -%% click E href "https://github.com/stdlib-js/array-filled-by/tree/deno" -%% click F href "https://github.com/stdlib-js/array-filled-by/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by -[production-url]: https://github.com/stdlib-js/array-filled-by/tree/production -[deno-url]: https://github.com/stdlib-js/array-filled-by/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-filled-by/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-filled-by/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-filled-by/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-filled-by/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-filled-by/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 188fc9b..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import filledarrayBy from '../docs/types/index'; -export = filledarrayBy; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 65ae3db..0000000 --- a/dist/index.js +++ /dev/null @@ -1,36 +0,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 deleted file mode 100644 index e88f9aa..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "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,YACjDC,EAAuB,QAAS,uCAAwC,EAAE,YAC1EC,EAAoB,QAAS,+DAAgE,EAC7FC,EAAoB,QAAS,gDAAiD,EAC9EC,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,EAAQ,UAAU,OAGbA,IAAU,EACd,OAAAE,EAAOrB,EAAOS,CAAc,EACrB,IAAIY,EAAM,CAAE,EAIpB,GADAD,EAAQ,UAAW,CAAE,EAChB5B,EAAU4B,CAAM,EAAI,CAExB,GAAKD,EAAQ,EACZ,MAAM,IAAI,UAAW,2FAA4F,EAGlH,GADAE,EAAOrB,EAAOoB,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWd,EAAQ,sEAAuEa,CAAM,CAAE,EAG7G,OAAO,IAAIC,EAAM,CAAE,CACpB,CAEA,GAAKF,EAAQ,EACZ,MAAM,IAAI,UAAW,2FAA4F,EAMlH,GAHAA,GAAS,EAGJpB,EAAY,UAAWoB,CAAM,CAAE,EAEnC,GAAKpB,EAAY,UAAWoB,EAAM,CAAE,CAAE,GAMrC,GALAN,EAAU,UAAWM,CAAM,EAC3BA,GAAS,EACTP,EAAO,UAAWO,CAAM,EAGnBA,IAAU,EACd,MAAM,IAAI,UAAW,2FAA4F,OAIlHP,EAAO,UAAWO,CAAM,UAIhBA,GAAS,GAIlB,GAHAN,EAAU,UAAWM,CAAM,EAC3BA,GAAS,EACTP,EAAO,UAAWO,CAAM,EACnB,CAACpB,EAAYa,CAAK,EACtB,MAAM,IAAI,UAAWL,EAAQ,uEAAwEK,CAAK,CAAE,MAK7G,OAAM,IAAI,UAAW,2FAA4F,EAWlH,GARAO,GAAS,EACJA,GAAS,GAAK3B,EAAU,UAAW2B,CAAM,CAAE,GAC/CC,EAAQ,UAAWD,CAAM,EACzBA,GAAS,GAETC,EAAQX,EAETY,EAAOrB,EAAOoB,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWd,EAAQ,sEAAuEa,CAAM,CAAE,EAG7G,GAAKA,IAAU,UAAY,CAE1B,GADAG,EAAM,UAAW,CAAE,EACdJ,IAAU,EAAI,CAMlB,GALK1B,EAAsB8B,CAAI,EAC9BD,EAAMC,EACK3B,EAAc2B,CAAI,IAC7BD,EAAMC,EAAI,QAEND,IAAQ,OACZ,OAAOpB,EAAaoB,EAAKV,EAAMC,CAAQ,EAExC,GAAKhB,EAAe0B,CAAI,EACvB,MAAM,IAAI,MAAO,mFAAoF,EAEtG,GAAKzB,EAAUyB,CAAI,EAAI,CACtB,GAAKf,IAAwB,GAC5B,MAAM,IAAI,UAAWD,EAAQ,sIAAuIgB,CAAI,CAAE,EAE3K,GAAK,CAACxB,EAAYwB,EAAKnB,CAAgB,CAAE,EACxC,MAAM,IAAI,UAAWG,EAAQ,wGAAyGgB,CAAI,CAAE,EAG7I,GADAA,EAAMA,EAAKnB,CAAgB,EAAE,EACxB,CAACL,EAAYwB,EAAI,IAAK,EAC1B,MAAM,IAAI,UAAWhB,EAAQ,wGAAyGgB,CAAI,CAAE,EAE7I,OAAOb,EAAqBa,EAAKX,EAAMC,CAAQ,CAChD,CACA,MAAM,IAAI,UAAWN,EAAQ,wGAAyGgB,CAAI,CAAE,CAC7I,SAAY1B,EAAe0B,CAAI,EAC9B,MAAM,IAAI,MAAO,mFAAoF,EAEtG,MAAM,IAAI,UAAWhB,EAAQ,wGAAyGgB,CAAI,CAAE,CAC7I,CACA,GAAKJ,IAAU,EAEd,GADAI,EAAM,UAAW,CAAE,EACd3B,EAAc2B,CAAI,EACtBT,EAAM,IAAIO,EAAME,EAAI,MAAO,UAChB1B,EAAe0B,CAAI,EAC9BT,EAAM,IAAIO,EAAME,CAAI,UACT9B,EAAsB8B,CAAI,EACrCT,EAAM,IAAIO,EAAME,CAAI,UACTzB,EAAUyB,CAAI,EAAI,CAC7B,GAAKf,IAAwB,GAC5B,MAAM,IAAI,UAAWD,EAAQ,sIAAuIgB,CAAI,CAAE,EAE3K,GAAK,CAACxB,EAAYwB,EAAKnB,CAAgB,CAAE,EACxC,MAAM,IAAI,UAAWG,EAAQ,wGAAyGgB,CAAI,CAAE,EAG7I,GADAA,EAAMA,EAAKnB,CAAgB,EAAE,EACxB,CAACL,EAAYwB,EAAI,IAAK,EAC1B,MAAM,IAAI,UAAWhB,EAAQ,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,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 deleted file mode 100644 index 06f3146..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,157 +0,0 @@ - -{{alias}}( [dtype] ) - Creates a filled array. - - Parameters - ---------- - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr = {{alias}}() - - > arr = {{alias}}( 'float32' ) - - - -{{alias}}( length[, dtype], clbk[, thisArg] ) - Returns a filled array according to a provided callback function and having - a specified length. - - Parameters - ---------- - length: integer - Array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > function clbk() { return 1.0; }; - > var arr = {{alias}}( 5, clbk ) - [ 1.0, 1.0, 1.0, 1.0, 1.0 ] - > arr = {{alias}}( 5, 'int32', clbk ) - [ 1, 1, 1, 1, 1 ] - - -{{alias}}( array[, dtype], clbk[, thisArg] ) - Creates a filled array from another array (or array-like object) according - to a provided callback function. - - Parameters - ---------- - array: ArrayLikeObject - Array from which to generate another array. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias}}( [ 0.5, 0.5, 0.5 ], {{alias:@stdlib/utils/constant-function}}( 2.0 ) ) - [ 2.0, 2.0, 2.0 ] - > var arr2 = {{alias}}( arr1, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( iterable[, dtype], clbk[, thisArg] ) - Creates a filled array from an iterable according to a provided callback - function. - - Parameters - ---------- - iterable: Iterable - Iterable from which to generate an array. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias:@stdlib/iter/constant}}( 3.0, {'iter': 3} ); - > var arr2 = {{alias}}( arr1, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( buffer[, byteOffset[, length]][, dtype], clbk[, thisArg] ) - Returns a filled typed array view of an ArrayBuffer according to a provided - callback function. - - The 'generic' array data type is *not* supported. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( buf, 0, 4, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0, 1.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index bb876ed..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,606 +0,0 @@ -/* -* @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. -*/ - -/// - -import { IterableIterator } from '@stdlib/types/iter'; -import filledarrayBy = require( './index' ); - - -/** -* Returns an iterator protocol-compliant object. -* -* @returns iterator protocol-compliant object -*/ -function iterator(): IterableIterator { - const obj: IterableIterator = { - [Symbol.iterator]: iterator, - 'next': next - }; - return obj; -} - -/** -* Implements the iterator protocol `next` method. -* -* @returns iterator protocol-compliant object -*/ -function next(): any { - return { - 'value': 1.0, - 'done': false - }; -} - -/** -* Callback function. -* -* @param i - current array index -* @returns return value -*/ -function clbk( i: number ): number { - return i; -} - - -// TESTS // - -// The function returns an array or typed array... -{ - filledarrayBy(); // $ExpectType ArrayOrTypedArray - filledarrayBy( 'float32' ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( 10, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( 10, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( 10, 'int32', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( 10, 'int32', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const x = new Float64Array( 10 ); - filledarrayBy( x, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( x, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( x, 'uint8', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( x, 'uint8', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const y = [ 2.0, 2.0, 2.0 ]; - filledarrayBy( y, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( y, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( y, 'float64', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( y, 'float64', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const it = iterator(); - filledarrayBy( it, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( it, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( it, 'uint8c', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( it, 'uint8c', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const buf = new ArrayBuffer( 32 ); - filledarrayBy( buf, clbk ); // $ExpectType RealOrComplexTypedArray | BooleanArray - filledarrayBy( buf, clbk, {} ); // $ExpectType RealOrComplexTypedArray | BooleanArray - - filledarrayBy( buf, 'uint32', clbk ); // $ExpectType RealOrComplexTypedArray | BooleanArray - filledarrayBy( buf, 'uint32', clbk, {} ); // $ExpectType RealOrComplexTypedArray | BooleanArray - - filledarrayBy( buf, 8, clbk ); // $ExpectType RealOrComplexTypedArray | BooleanArray - filledarrayBy( buf, 8, clbk, {} ); // $ExpectType RealOrComplexTypedArray | BooleanArray - - filledarrayBy( buf, 8, 'uint16', clbk ); // $ExpectType RealOrComplexTypedArray | BooleanArray - filledarrayBy( buf, 8, 'uint16', clbk, {} ); // $ExpectType RealOrComplexTypedArray | BooleanArray - - filledarrayBy( buf, 8, 2, clbk ); // $ExpectType RealOrComplexTypedArray | BooleanArray - filledarrayBy( buf, 8, 2, clbk, {} ); // $ExpectType RealOrComplexTypedArray | BooleanArray - - filledarrayBy( buf, 8, 2, 'int16', clbk ); // $ExpectType RealOrComplexTypedArray | BooleanArray - filledarrayBy( buf, 8, 2, 'int16', clbk, {} ); // $ExpectType RealOrComplexTypedArray | BooleanArray -} - -// The compiler throws an error if a callback function argument is not a function... -{ - filledarrayBy( 'float64', '5' ); // $ExpectError - filledarrayBy( 'float64', 1.0 ); // $ExpectError - filledarrayBy( 'float64', false ); // $ExpectError - filledarrayBy( 'float64', true ); // $ExpectError - filledarrayBy( 'float64', null ); // $ExpectError - filledarrayBy( 'float64', undefined ); // $ExpectError - filledarrayBy( 'float64', [] ); // $ExpectError - filledarrayBy( 'float64', {} ); // $ExpectError - - filledarrayBy( 'float64', '5', {} ); // $ExpectError - filledarrayBy( 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( 'float64', false, {} ); // $ExpectError - filledarrayBy( 'float64', true, {} ); // $ExpectError - filledarrayBy( 'float64', null, {} ); // $ExpectError - filledarrayBy( 'float64', undefined, {} ); // $ExpectError - filledarrayBy( 'float64', [], {} ); // $ExpectError - filledarrayBy( 'float64', {}, {} ); // $ExpectError - - filledarrayBy( 10, '5' ); // $ExpectError - filledarrayBy( 10, 1.0 ); // $ExpectError - filledarrayBy( 10, false ); // $ExpectError - filledarrayBy( 10, true ); // $ExpectError - filledarrayBy( 10, null ); // $ExpectError - filledarrayBy( 10, undefined ); // $ExpectError - filledarrayBy( 10, [] ); // $ExpectError - filledarrayBy( 10, {} ); // $ExpectError - - filledarrayBy( 10, '5', {} ); // $ExpectError - filledarrayBy( 10, 1.0, {} ); // $ExpectError - filledarrayBy( 10, false, {} ); // $ExpectError - filledarrayBy( 10, true, {} ); // $ExpectError - filledarrayBy( 10, null, {} ); // $ExpectError - filledarrayBy( 10, undefined, {} ); // $ExpectError - filledarrayBy( 10, [], {} ); // $ExpectError - filledarrayBy( 10, {}, {} ); // $ExpectError - - filledarrayBy( 10, 'float64', '5' ); // $ExpectError - filledarrayBy( 10, 'float64', 1.0 ); // $ExpectError - filledarrayBy( 10, 'float64', false ); // $ExpectError - filledarrayBy( 10, 'float64', true ); // $ExpectError - filledarrayBy( 10, 'float64', null ); // $ExpectError - filledarrayBy( 10, 'float64', undefined ); // $ExpectError - filledarrayBy( 10, 'float64', [] ); // $ExpectError - filledarrayBy( 10, 'float64', {} ); // $ExpectError - - filledarrayBy( 10, 'float64', '5', {} ); // $ExpectError - filledarrayBy( 10, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( 10, 'float64', false, {} ); // $ExpectError - filledarrayBy( 10, 'float64', true, {} ); // $ExpectError - filledarrayBy( 10, 'float64', null, {} ); // $ExpectError - filledarrayBy( 10, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( 10, 'float64', [], {} ); // $ExpectError - filledarrayBy( 10, 'float64', {}, {} ); // $ExpectError - - const x = new Float64Array( 10 ); - filledarrayBy( x, '5' ); // $ExpectError - filledarrayBy( x, 1.0 ); // $ExpectError - filledarrayBy( x, false ); // $ExpectError - filledarrayBy( x, true ); // $ExpectError - filledarrayBy( x, null ); // $ExpectError - filledarrayBy( x, undefined ); // $ExpectError - filledarrayBy( x, [] ); // $ExpectError - filledarrayBy( x, {} ); // $ExpectError - - filledarrayBy( x, '5', {} ); // $ExpectError - filledarrayBy( x, 1.0, {} ); // $ExpectError - filledarrayBy( x, false, {} ); // $ExpectError - filledarrayBy( x, true, {} ); // $ExpectError - filledarrayBy( x, null, {} ); // $ExpectError - filledarrayBy( x, undefined, {} ); // $ExpectError - filledarrayBy( x, [], {} ); // $ExpectError - filledarrayBy( x, {}, {} ); // $ExpectError - - filledarrayBy( x, 'float64', '5' ); // $ExpectError - filledarrayBy( x, 'float64', 1.0 ); // $ExpectError - filledarrayBy( x, 'float64', false ); // $ExpectError - filledarrayBy( x, 'float64', true ); // $ExpectError - filledarrayBy( x, 'float64', null ); // $ExpectError - filledarrayBy( x, 'float64', undefined ); // $ExpectError - filledarrayBy( x, 'float64', [] ); // $ExpectError - filledarrayBy( x, 'float64', {} ); // $ExpectError - - filledarrayBy( x, 'float64', '5', {} ); // $ExpectError - filledarrayBy( x, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( x, 'float64', false, {} ); // $ExpectError - filledarrayBy( x, 'float64', true, {} ); // $ExpectError - filledarrayBy( x, 'float64', null, {} ); // $ExpectError - filledarrayBy( x, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( x, 'float64', [], {} ); // $ExpectError - filledarrayBy( x, 'float64', {}, {} ); // $ExpectError - - const y = [ 2.0, 2.0, 2.0 ]; - filledarrayBy( y, '5' ); // $ExpectError - filledarrayBy( y, 1.0 ); // $ExpectError - filledarrayBy( y, false ); // $ExpectError - filledarrayBy( y, true ); // $ExpectError - filledarrayBy( y, null ); // $ExpectError - filledarrayBy( y, undefined ); // $ExpectError - filledarrayBy( y, [] ); // $ExpectError - filledarrayBy( y, {} ); // $ExpectError - - filledarrayBy( y, '5', {} ); // $ExpectError - filledarrayBy( y, 1.0, {} ); // $ExpectError - filledarrayBy( y, false, {} ); // $ExpectError - filledarrayBy( y, true, {} ); // $ExpectError - filledarrayBy( y, null, {} ); // $ExpectError - filledarrayBy( y, undefined, {} ); // $ExpectError - filledarrayBy( y, [], {} ); // $ExpectError - filledarrayBy( y, {}, {} ); // $ExpectError - - filledarrayBy( y, 'float64', '5' ); // $ExpectError - filledarrayBy( y, 'float64', 1.0 ); // $ExpectError - filledarrayBy( y, 'float64', false ); // $ExpectError - filledarrayBy( y, 'float64', true ); // $ExpectError - filledarrayBy( y, 'float64', null ); // $ExpectError - filledarrayBy( y, 'float64', undefined ); // $ExpectError - filledarrayBy( y, 'float64', [] ); // $ExpectError - filledarrayBy( y, 'float64', {} ); // $ExpectError - - filledarrayBy( y, 'float64', '5', {} ); // $ExpectError - filledarrayBy( y, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( y, 'float64', false, {} ); // $ExpectError - filledarrayBy( y, 'float64', true, {} ); // $ExpectError - filledarrayBy( y, 'float64', null, {} ); // $ExpectError - filledarrayBy( y, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( y, 'float64', [], {} ); // $ExpectError - filledarrayBy( y, 'float64', {}, {} ); // $ExpectError - - const it = iterator(); - filledarrayBy( it, '5' ); // $ExpectError - filledarrayBy( it, 1.0 ); // $ExpectError - filledarrayBy( it, false ); // $ExpectError - filledarrayBy( it, true ); // $ExpectError - filledarrayBy( it, null ); // $ExpectError - filledarrayBy( it, undefined ); // $ExpectError - filledarrayBy( it, [] ); // $ExpectError - filledarrayBy( it, {} ); // $ExpectError - - filledarrayBy( it, '5', {} ); // $ExpectError - filledarrayBy( it, 1.0, {} ); // $ExpectError - filledarrayBy( it, false, {} ); // $ExpectError - filledarrayBy( it, true, {} ); // $ExpectError - filledarrayBy( it, null, {} ); // $ExpectError - filledarrayBy( it, undefined, {} ); // $ExpectError - filledarrayBy( it, [], {} ); // $ExpectError - filledarrayBy( it, {}, {} ); // $ExpectError - - filledarrayBy( it, 'float64', '5' ); // $ExpectError - filledarrayBy( it, 'float64', 1.0 ); // $ExpectError - filledarrayBy( it, 'float64', false ); // $ExpectError - filledarrayBy( it, 'float64', true ); // $ExpectError - filledarrayBy( it, 'float64', null ); // $ExpectError - filledarrayBy( it, 'float64', undefined ); // $ExpectError - filledarrayBy( it, 'float64', [] ); // $ExpectError - filledarrayBy( it, 'float64', {} ); // $ExpectError - - filledarrayBy( it, 'float64', '5', {} ); // $ExpectError - filledarrayBy( it, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( it, 'float64', false, {} ); // $ExpectError - filledarrayBy( it, 'float64', true, {} ); // $ExpectError - filledarrayBy( it, 'float64', null, {} ); // $ExpectError - filledarrayBy( it, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( it, 'float64', [], {} ); // $ExpectError - filledarrayBy( it, 'float64', {}, {} ); // $ExpectError - - const buf = new ArrayBuffer( 32 ); - filledarrayBy( buf, '5' ); // $ExpectError - filledarrayBy( buf, 1.0 ); // $ExpectError - filledarrayBy( buf, false ); // $ExpectError - filledarrayBy( buf, true ); // $ExpectError - filledarrayBy( buf, null ); // $ExpectError - filledarrayBy( buf, undefined ); // $ExpectError - filledarrayBy( buf, [] ); // $ExpectError - filledarrayBy( buf, {} ); // $ExpectError - - filledarrayBy( buf, '5', {} ); // $ExpectError - filledarrayBy( buf, 1.0, {} ); // $ExpectError - filledarrayBy( buf, false, {} ); // $ExpectError - filledarrayBy( buf, true, {} ); // $ExpectError - filledarrayBy( buf, null, {} ); // $ExpectError - filledarrayBy( buf, undefined, {} ); // $ExpectError - filledarrayBy( buf, [], {} ); // $ExpectError - filledarrayBy( buf, {}, {} ); // $ExpectError - - filledarrayBy( buf, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 'float64', false ); // $ExpectError - filledarrayBy( buf, 'float64', true ); // $ExpectError - filledarrayBy( buf, 'float64', null ); // $ExpectError - filledarrayBy( buf, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 'float64', {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5' ); // $ExpectError - filledarrayBy( buf, 8, 1.0 ); // $ExpectError - filledarrayBy( buf, 8, false ); // $ExpectError - filledarrayBy( buf, 8, true ); // $ExpectError - filledarrayBy( buf, 8, null ); // $ExpectError - filledarrayBy( buf, 8, undefined ); // $ExpectError - filledarrayBy( buf, 8, [] ); // $ExpectError - filledarrayBy( buf, 8, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, false, {} ); // $ExpectError - filledarrayBy( buf, 8, true, {} ); // $ExpectError - filledarrayBy( buf, 8, null, {} ); // $ExpectError - filledarrayBy( buf, 8, undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, [], {} ); // $ExpectError - filledarrayBy( buf, 8, {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 8, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 'float64', false ); // $ExpectError - filledarrayBy( buf, 8, 'float64', true ); // $ExpectError - filledarrayBy( buf, 8, 'float64', null ); // $ExpectError - filledarrayBy( buf, 8, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 8, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 8, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 8, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, '5' ); // $ExpectError - filledarrayBy( buf, 8, 2, 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 2, false ); // $ExpectError - filledarrayBy( buf, 8, 2, true ); // $ExpectError - filledarrayBy( buf, 8, 2, null ); // $ExpectError - filledarrayBy( buf, 8, 2, undefined ); // $ExpectError - filledarrayBy( buf, 8, 2, [] ); // $ExpectError - filledarrayBy( buf, 8, 2, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, false, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, true, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, null, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, [], {} ); // $ExpectError - filledarrayBy( buf, 8, 2, {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', false ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', true ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', null ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', {}, {} ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid length, typed array, array-like object, `ArrayBuffer`, or iterable argument... -{ - filledarrayBy( false, clbk ); // $ExpectError - filledarrayBy( true, clbk ); // $ExpectError - filledarrayBy( null, clbk ); // $ExpectError - filledarrayBy( {}, clbk ); // $ExpectError - - filledarrayBy( false, clbk, {} ); // $ExpectError - filledarrayBy( true, clbk, {} ); // $ExpectError - filledarrayBy( null, clbk, {} ); // $ExpectError - filledarrayBy( {}, clbk, {} ); // $ExpectError - - filledarrayBy( false, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 'float64', clbk ); // $ExpectError - - filledarrayBy( false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, clbk ); // $ExpectError - filledarrayBy( 1.0, 8, clbk ); // $ExpectError - filledarrayBy( false, 8, clbk ); // $ExpectError - filledarrayBy( true, 8, clbk ); // $ExpectError - filledarrayBy( null, 8, clbk ); // $ExpectError - filledarrayBy( undefined, 8, clbk ); // $ExpectError - filledarrayBy( [], 8, clbk ); // $ExpectError - filledarrayBy( {}, 8, clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, clbk ); // $ExpectError - - filledarrayBy( '5', 8, clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, clbk, {} ); // $ExpectError - filledarrayBy( false, 8, clbk, {} ); // $ExpectError - filledarrayBy( true, 8, clbk, {} ); // $ExpectError - filledarrayBy( null, 8, clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, clbk, {} ); // $ExpectError - filledarrayBy( [], 8, clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 'float64', clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( false, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( [], 8, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 'float64', clbk ); // $ExpectError - - filledarrayBy( '5', 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 2, clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 2, clbk ); // $ExpectError - filledarrayBy( false, 8, 2, clbk ); // $ExpectError - filledarrayBy( true, 8, 2, clbk ); // $ExpectError - filledarrayBy( null, 8, 2, clbk ); // $ExpectError - filledarrayBy( undefined, 8, 2, clbk ); // $ExpectError - filledarrayBy( [], 8, 2, clbk ); // $ExpectError - filledarrayBy( {}, 8, 2, clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, clbk ); // $ExpectError - - filledarrayBy( '5', 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( false, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( [], 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, 'float64', clbk ); // $ExpectError - - filledarrayBy( '5', 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a byte offset argument which is not a number... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, false, clbk ); // $ExpectError - filledarrayBy( buf, true, clbk ); // $ExpectError - filledarrayBy( buf, null, clbk ); // $ExpectError - filledarrayBy( buf, [], clbk ); // $ExpectError - filledarrayBy( buf, {}, clbk ); // $ExpectError - - filledarrayBy( buf, false, clbk, {} ); // $ExpectError - filledarrayBy( buf, true, clbk, {} ); // $ExpectError - filledarrayBy( buf, null, clbk, {} ); // $ExpectError - filledarrayBy( buf, [], clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, clbk, {} ); // $ExpectError - - filledarrayBy( buf, '5', 'float64', clbk ); // $ExpectError - filledarrayBy( buf, false, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, true, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, null, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, [], 'float64', clbk ); // $ExpectError - filledarrayBy( buf, {}, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, '5', 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( buf, false, 2, clbk ); // $ExpectError - filledarrayBy( buf, true, 2, clbk ); // $ExpectError - filledarrayBy( buf, null, 2, clbk ); // $ExpectError - filledarrayBy( buf, [], 2, clbk ); // $ExpectError - filledarrayBy( buf, {}, 2, clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, clbk ); // $ExpectError - - filledarrayBy( buf, false, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, clbk, {} ); // $ExpectError - - filledarrayBy( buf, '5', 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, false, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, true, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, null, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, undefined, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, [], 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, {}, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, '5', 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, false, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, undefined, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a view length argument which is not a number... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, 8, false, clbk ); // $ExpectError - filledarrayBy( buf, 8, true, clbk ); // $ExpectError - filledarrayBy( buf, 8, null, clbk ); // $ExpectError - filledarrayBy( buf, 8, [], clbk ); // $ExpectError - filledarrayBy( buf, 8, {}, clbk ); // $ExpectError - - filledarrayBy( buf, 8, false, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, true, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, null, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, [], clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, {}, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, clbk, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5', 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, false, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, true, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, null, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, [], 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, {}, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, 8, '5', 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, [], 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, {}, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided too many arguments... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, 8, 2, 'float64', 1, clbk, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 997a381..0000000 --- a/examples/index.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ).factory; -var dtypes = require( '@stdlib/array-typed-real-dtypes' ); -var filledarrayBy = require( './../lib' ); - -// Create a pseudorandom number generator: -var rand = discreteUniform( 0, 100 ); - -// Get a list of array data types: -var dt = dtypes(); - -// Generate filled arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = filledarrayBy( 10, dt[ i ], rand ); - console.log( arr ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 764e40e..cb63cd1 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, RealOrComplexTypedArray, BooleanArray, DataType } from '@stdlib/types/array'; import { IterableIterator } from '@stdlib/types/iter'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..668c2f7 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@v0.0.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-ctors@v0.3.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill-by@v0.2.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled-by@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@v0.2.2-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.3.0-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";var v=f(),g=j.get("dtypes.default");function c(){var f,j,c,b,y,x,u,E;if(0===(j=arguments.length))return new(y=d(g))(0);if(r(c=arguments[0])){if(j>1)throw new TypeError(w("00h05"));if(null===(y=d(c)))throw new TypeError(w("00h2Y",c));return new y(0)}if(j<2)throw new TypeError(w("00h05"));if(h(arguments[j-=1]))if(h(arguments[j-1])){if(f=arguments[j],b=arguments[j-=1],0===j)throw new TypeError(w("00h05"))}else b=arguments[j];else{if(!(j>=2))throw new TypeError(w("00h05"));if(f=arguments[j],!h(b=arguments[j-=1]))throw new TypeError(w("00h2b",b))}if((j-=1)>=0&&r(arguments[j])?(c=arguments[j],j-=1):c=g,null===(y=d(c)))throw new TypeError(w("00h2Y",c));if("generic"===c){if(E=arguments[0],0===j){if(e(E)?u=E:i(E)&&(u=E.length),void 0!==u)return m(u,b,f);if(n(E))throw new Error(w("00h04"));if(o(E)){if(!1===v)throw new TypeError(w("00h2Z",E));if(!h(E[p]))throw new TypeError(w("00h2a",E));if(E=E[p](),!h(E.next))throw new TypeError(w("00h2a",E));return function(r,e,t){var s,i;for(s=[],i=-1;!r.next().done;)i+=1,s.push(e.call(t,i));return s}(E,b,f)}throw new TypeError(w("00h2a",E))}if(n(E))throw new Error(w("00h04"));throw new TypeError(w("00h2a",E))}if(0===j)if(i(E=arguments[0]))x=new y(E.length);else if(n(E))x=new y(E);else if(e(E))x=new y(E);else{if(!o(E))throw new TypeError(w("00h2a",E));if(!1===v)throw new TypeError(w("00h2Z",E));if(!h(E[p]))throw new TypeError(w("00h2a",E));if(E=E[p](),!h(E.next))throw new TypeError(w("00h2a",E));x=new y(a(E))}else x=1===j?new y(arguments[0],arguments[1]):new y(arguments[0],arguments[1],arguments[2]);return x.length>0&&(t(c)||s(c)?function(r,e,t){var s;for(s=0;s\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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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( format('00h05') );\n\t\t}\n\t\tctor = ctors( dtype );\n\t\tif ( ctor === null ) {\n\t\t\tthrow new TypeError( format( '00h2Y', 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( format('00h05') );\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( format('00h05') );\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( '00h2b', 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( format('00h05') );\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( '00h2Y', 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( format('00h04') );\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( '00h2Z', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00h2a', 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( '00h2a', 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( '00h2a', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format('00h04') );\n\t\t}\n\t\tthrow new TypeError( format( '00h2a', 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( '00h2Z', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00h2a', 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( '00h2a', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00h2a', 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\nexport default filledarrayBy;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","DEFAULT_DTYPE","defaults","get","filledarrayBy","thisArg","nargs","dtype","clbk","ctor","arr","len","arg","arguments","length","ctors","isString","TypeError","format","isFunction","isNonNegativeInteger","isCollection","filledArray","isArrayBuffer","Error","isObject","ITERATOR_SYMBOL","next","it","i","done","push","call","filledArrayIterator","iterLength","isComplexDataType","isBooleanDataType","set","filledAccessors","gfillBy","value","aidx"],"mappings":";;sjDA0CA,IAAIA,EAAsBC,IACtBC,EAAgBC,EAASC,IAAK,kBA2MlC,SAASC,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAKJ,GAAe,KAHfN,EAAQO,UAAUC,QAKjB,OAAO,IADPL,EAAOM,EAAOd,IACG,GAIlB,GAAKe,EADLT,EAAQM,UAAW,IACM,CAExB,GAAKP,EAAQ,EACZ,MAAM,IAAIW,UAAWC,EAAO,UAG7B,GAAc,QADdT,EAAOM,EAAOR,IAEb,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,OAAO,IAAIE,EAAM,EACjB,CAED,GAAKH,EAAQ,EACZ,MAAM,IAAIW,UAAWC,EAAO,UAM7B,GAAKC,EAAYN,UAHjBP,GAAS,IAKR,GAAKa,EAAYN,UAAWP,EAAM,KAMjC,GALAD,EAAUQ,UAAWP,GAErBE,EAAOK,UADPP,GAAS,GAIM,IAAVA,EACJ,MAAM,IAAIW,UAAWC,EAAO,eAI7BV,EAAOK,UAAWP,OAIf,MAAKA,GAAS,GAUlB,MAAM,IAAIW,UAAWC,EAAO,UAN5B,GAHAb,EAAUQ,UAAWP,IAGfa,EADNX,EAAOK,UADPP,GAAS,IAGR,MAAM,IAAIW,UAAWC,EAAQ,QAASV,GAMvC,CAUD,IARAF,GAAS,IACK,GAAKU,EAAUH,UAAWP,KACvCC,EAAQM,UAAWP,GACnBA,GAAS,GAETC,EAAQN,EAGK,QADdQ,EAAOM,EAAOR,IAEb,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,GAAe,YAAVA,EAAsB,CAE1B,GADAK,EAAMC,UAAW,GACF,IAAVP,EAAc,CAMlB,GALKc,EAAsBR,GAC1BD,EAAMC,EACKS,EAAcT,KACzBD,EAAMC,EAAIE,aAEE,IAARH,EACJ,OAAOW,EAAaX,EAAKH,EAAMH,GAEhC,GAAKkB,EAAeX,GACnB,MAAM,IAAIY,MAAON,EAAO,UAEzB,GAAKO,EAAUb,GAAQ,CACtB,IAA6B,IAAxBb,EACJ,MAAM,IAAIkB,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAYP,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLP,EAAYP,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvC,OAvSJ,SAA8BgB,EAAIpB,EAAMH,GACvC,IAAIK,EACAmB,EAKJ,IAFAnB,EAAM,GACNmB,GAAK,GAEAD,EAAGD,OACAG,MAGPD,GAAK,EACLnB,EAAIqB,KAAMvB,EAAKwB,KAAM3B,EAASwB,IAE/B,OAAOnB,CACR,CAuRWuB,CAAqBrB,EAAKJ,EAAMH,EACvC,CACD,MAAM,IAAIY,UAAWC,EAAQ,QAASN,GACzC,CAAS,GAAKW,EAAeX,GAC1B,MAAM,IAAIY,MAAON,EAAO,UAEzB,MAAM,IAAID,UAAWC,EAAQ,QAASN,GACtC,CACD,GAAe,IAAVN,EAEJ,GAAKe,EADLT,EAAMC,UAAW,IAEhBH,EAAM,IAAID,EAAMG,EAAIE,aACd,GAAKS,EAAeX,GAC1BF,EAAM,IAAID,EAAMG,QACV,GAAKQ,EAAsBR,GACjCF,EAAM,IAAID,EAAMG,OACV,KAAKa,EAAUb,GAarB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAZtC,IAA6B,IAAxBb,EACJ,MAAM,IAAIkB,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAYP,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLP,EAAYP,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvCF,EAAM,IAAID,EAAMyB,EAAYtB,GAG5B,MAEDF,EADqB,IAAVJ,EACL,IAAIG,EAAMI,UAAU,GAAIA,UAAU,IAElC,IAAIJ,EAAMI,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKH,EAAII,OAAS,IACZqB,EAAmB5B,IAAW6B,EAAmB7B,GAjTxD,SAA0BG,EAAKF,EAAMH,GACpC,IAAIwB,EACJ,IAAMA,EAAI,EAAGA,EAAInB,EAAII,OAAQe,IAC5BnB,EAAI2B,IAAK7B,EAAKwB,KAAM3B,EAASwB,GAAKA,EAGpC,CA4SGS,CAAiB5B,EAAKF,EAAMH,GAE5BkC,EAAS7B,EAAII,OAAQJ,EAAK,GAe5B,SAAmB8B,EAAOC,GACzB,OAAOjC,EAAKwB,KAAM3B,EAASoC,EAC3B,KAdM/B,CAeR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d115cf0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,192 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -/** -* Create a filled array according to a provided callback function. -* -* @module @stdlib/array-filled-by -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* var arr = filledarrayBy(); -* // returns -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'generic', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( [ 0.5, 0.5 ], clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1; -* } -* -* var arr = filledarrayBy( [ 5, -3 ], 'int32', clbk ); -* // returns [ 1, 1 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk1() { -* return 10; -* } -* -* function clbk2() { -* return 1.0; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, clbk2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk1() { -* return 1.0; -* } -* -* function clbk2() { -* return 2; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, 'uint32', clbk2 ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 'float32', clbk ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, clbk ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, 'int32', clbk ); -* // returns [ 1, 1 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index ed1aa9a..0000000 --- a/lib/main.js +++ /dev/null @@ -1,416 +0,0 @@ -/** -* @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 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' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var ctors = require( '@stdlib/array-ctors' ); -var gfillBy = require( '@stdlib/blas-ext-base-gfill-by' ); -var filledArray = require( '@stdlib/array-base-filled-by' ); -var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var iterLength = require( '@stdlib/iter-length' ); -var defaults = require( '@stdlib/array-defaults' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport(); -var DEFAULT_DTYPE = defaults.get( 'dtypes.default' ); - - -// FUNCTIONS // - -/** -* Creates a filled "generic" array from an iterator. -* -* @private -* @param {Iterable} it - iterator -* @param {Callback} clbk - callback function -* @param {*} thisArg - callback function execution context -* @returns {Array} filled array -*/ -function filledArrayIterator( it, clbk, thisArg ) { - var arr; - var i; - var v; - - arr = []; - i = -1; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - i += 1; - arr.push( clbk.call( thisArg, i ) ); - } - return arr; -} - -/** -* Fills an array exposing accessors for getting and setting array elements. -* -* @private -* @param {Collection} arr - input array -* @param {Callback} clbk - callback function -* @param {*} thisArg - callback function execution context -* @returns {Collection} input array -*/ -function filledAccessors( arr, clbk, thisArg ) { - var i; - for ( i = 0; i < arr.length; i++ ) { - arr.set( clbk.call( thisArg, i ), i ); - } - return arr; -} - - -// MAIN // - -/** -* Creates a filled array according to a provided callback function. -* -* @param {(NonNegativeInteger|TypedArray|ArrayLikeObject|ArrayBuffer|Iterable)} [arg] - a length, typed array, array-like object, buffer, or iterable -* @param {NonNegativeInteger} [byteOffset=0] - byte offset -* @param {NonNegativeInteger} [length] - view length -* @param {string} [dtype="float64"] - data type -* @param {Callback} [clbk] - callback to invoke -* @param {*} [thisArg] - callback execution context -* @throws {TypeError} must provide a recognized data type -* @throws {TypeError} must provide a length, typed array, array-like object, buffer, or iterable -* @throws {TypeError} callback argument must be a function. -* @throws {Error} creating a generic array from an `ArrayBuffer` is not supported -* @returns {(TypedArray|Array)} array or typed array -* -* @example -* var arr = filledarrayBy(); -* // returns -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'generic', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( [ 0.5, 0.5 ], clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1; -* } -* -* var arr = filledarrayBy( [ 5, -3 ], 'int32', clbk ); -* // returns [ 1, 1 ] -* -* @example -* function clbk1() { -* return 10; -* } -* -* function clbk2() { -* return 1.0; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, clbk2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk1() { -* return 1.0; -* } -* -* function clbk2() { -* return 2; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, 'uint32', clbk2 ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 'float32', clbk ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, clbk ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, 'int32', clbk ); -* // returns [ 1, 1 ] -*/ -function filledarrayBy() { - var thisArg; - var nargs; - var dtype; - var clbk; - var ctor; - var arr; - var len; - var arg; - - nargs = arguments.length; - - // If we weren't provided any arguments, return an empty array... - if ( nargs === 0 ) { - ctor = ctors( DEFAULT_DTYPE ); - return new ctor( 0 ); - } - // Check if we were provided a dtype as the first argument... - dtype = arguments[ 0 ]; - if ( isString( dtype ) ) { - // Invoking this function with arguments `f( dtype, clbk[, thisArg] )` is not allowed (otherwise, we'd need to also allow `f( clbk[, thisArg] )`)... - if ( nargs > 1 ) { - throw new TypeError( format('00h05') ); - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '00h2Y', dtype ) ); - } - // Return an empty array having the specified dtype: - return new ctor( 0 ); - } - // For all other supported invocations, we need at least two arguments... - if ( nargs < 2 ) { - throw new TypeError( format('00h05') ); - } - // At this point, we need to do some argument juggling... - nargs -= 1; // henceforth, the number of available arguments is `nargs+1` - - // Determine whether the last argument is a callback or "this" context... - if ( isFunction( arguments[ nargs ] ) ) { - // 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... - if ( isFunction( arguments[ nargs-1 ] ) ) { - thisArg = arguments[ nargs ]; - nargs -= 1; - clbk = arguments[ nargs ]; - - // Check if we were provided only a callback and a "this" context.. - if ( nargs === 0 ) { - throw new TypeError( format('00h05') ); - } - } else { - // "this" context is left undefined... - clbk = arguments[ nargs ]; - } - } - // 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... - else if ( nargs >= 2 ) { - thisArg = arguments[ nargs ]; - nargs -= 1; - clbk = arguments[ nargs ]; - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '00h2b', clbk ) ); - } - } - // If were were only provided 2 arguments and the last argument was not a function, we've been provided an insufficient number of arguments... - else { - throw new TypeError( format('00h05') ); - } - // Now that we've processed the callback arguments, let's continue working backward to see if we've been provided a `dtype` argument... - nargs -= 1; - if ( nargs >= 0 && isString( arguments[ nargs ] ) ) { - dtype = arguments[ nargs ]; - nargs -= 1; - } else { - dtype = DEFAULT_DTYPE; - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '00h2Y', dtype ) ); - } - // At this point, we've resolved the output array data type, and now we can actually create the output array... - if ( dtype === 'generic' ) { - arg = arguments[ 0 ]; - if ( nargs === 0 ) { - if ( isNonNegativeInteger( arg ) ) { - len = arg; - } else if ( isCollection( arg ) ) { - len = arg.length; - } - if ( len !== void 0 ) { - return filledArray( len, clbk, thisArg ); - } - if ( isArrayBuffer( arg ) ) { - throw new Error( format('00h04') ); - } - if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( '00h2Z', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00h2a', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00h2a', arg ) ); - } - return filledArrayIterator( arg, clbk, thisArg ); - } - throw new TypeError( format( '00h2a', arg ) ); - } else if ( isArrayBuffer( arg ) ) { - throw new Error( format('00h04') ); - } - throw new TypeError( format( '00h2a', arg ) ); - } - if ( nargs === 0 ) { // length || array-like || ArrayBuffer || iterable - arg = arguments[ 0 ]; - if ( isCollection( arg ) ) { - arr = new ctor( arg.length ); - } else if ( isArrayBuffer( arg ) ) { - arr = new ctor( arg ); - } else if ( isNonNegativeInteger( arg ) ) { - arr = new ctor( arg ); - } else if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( '00h2Z', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00h2a', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00h2a', arg ) ); - } - arr = new ctor( iterLength( arg ) ); - } else { - throw new TypeError( format( '00h2a', arg ) ); - } - } else if ( nargs === 1 ) { - arr = new ctor( arguments[0], arguments[1] ); // (ArrayBuffer, byteOffset) - } else { - arr = new ctor( arguments[0], arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset, length) - } - if ( arr.length > 0 ) { - if ( isComplexDataType( dtype ) || isBooleanDataType( dtype ) ) { - filledAccessors( arr, clbk, thisArg ); - } else { - gfillBy( arr.length, arr, 1, callback ); - } - } - return arr; - - /** - * Callback which wraps a provided callback and is invoked for each array element. - * - * @private - * @param {*} value - element value - * @param {NonNegativeInteger} aidx - array index - * @param {NonNegativeInteger} sidx - strided index - * @param {Collection} array - input array/collection - * @returns {*} callback return value - */ - function callback( value, aidx ) { - return clbk.call( thisArg, aidx ); - } -} - - -// EXPORTS // - -module.exports = filledarrayBy; diff --git a/package.json b/package.json index b5ac3ab..b16be36 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Create a filled array according to a provided callback function.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,75 +13,6 @@ "bugs": { "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.2", - "@stdlib/array-ctors": "^0.3.0", - "@stdlib/array-defaults": "^0.3.0", - "@stdlib/assert-has-iterator-symbol-support": "^0.2.2", - "@stdlib/assert-is-arraybuffer": "^0.2.2", - "@stdlib/assert-is-collection": "^0.2.2", - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer": "^0.2.2", - "@stdlib/assert-is-object": "^0.2.2", - "@stdlib/assert-is-string": "^0.2.2", - "@stdlib/blas-ext-base-gfill-by": "^0.2.1", - "@stdlib/iter-length": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/symbol-iterator": "^0.2.2", - "@stdlib/types": "^0.4.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-bool": "^0.1.0", - "@stdlib/array-buffer": "^0.2.2", - "@stdlib/array-complex128": "^0.3.0", - "@stdlib/array-complex64": "^0.3.0", - "@stdlib/array-float32": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/array-int16": "^0.2.2", - "@stdlib/array-int32": "^0.2.2", - "@stdlib/array-int8": "^0.2.2", - "@stdlib/array-typed-real-dtypes": "^0.2.2", - "@stdlib/array-uint16": "^0.2.2", - "@stdlib/array-uint32": "^0.2.2", - "@stdlib/array-uint8": "^0.2.2", - "@stdlib/array-uint8c": "^0.2.2", - "@stdlib/assert-instance-of": "^0.2.2", - "@stdlib/assert-is-array": "^0.2.2", - "@stdlib/assert-is-typed-array": "^0.2.2", - "@stdlib/assert-is-typed-array-like": "^0.2.2", - "@stdlib/complex-float32-ctor": "^0.0.2", - "@stdlib/complex-float64-ctor": "^0.0.3", - "@stdlib/iter-constant": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/random-base-discrete-uniform": "^0.2.1", - "@stdlib/strided-base-reinterpret-boolean": "^0.0.2", - "@stdlib/strided-base-reinterpret-complex128": "^0.2.2", - "@stdlib/strided-base-reinterpret-complex64": "^0.2.1", - "@stdlib/utils-constant-function": "^0.2.2", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..e4cee9c --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index ca0cf25..0000000 --- a/test/test.js +++ /dev/null @@ -1,4397 +0,0 @@ -/** -* @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. -*/ - -/* eslint-disable max-len */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -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' ); -var iterConstant = require( '@stdlib/iter-constant' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var filledarrayBy = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': !hasIteratorSymbolSupport() -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof filledarrayBy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if only provided callback arguments', function test( t ) { - t.throws( clbk1, TypeError, 'throws an error' ); - t.throws( clbk2, TypeError, 'throws an error' ); - t.throws( clbk3, TypeError, 'throws an error' ); - t.end(); - - function clbk1() { - filledarrayBy( constantFunction( 1.0 ) ); - } - - function clbk2() { - filledarrayBy( constantFunction( 1.0 ), {} ); - } - - function clbk3() { - filledarrayBy( constantFunction( 1.0 ), constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (only argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (typed array; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (array-like object)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (array-like object; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 8 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 8 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, 1, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (iterator)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( iterConstant( 1.0 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (iterator; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( iterConstant( 1.0 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if only provided data type and callback arguments', function test( t ) { - t.throws( clbk1, TypeError, 'throws an error' ); - t.throws( clbk2, TypeError, 'throws an error' ); - t.throws( clbk3, TypeError, 'throws an error' ); - t.end(); - - function clbk1() { - filledarrayBy( 'float64', constantFunction( 1.0 ) ); - } - - function clbk2() { - filledarrayBy( 'float64', constantFunction( 1.0 ), {} ); - } - - function clbk3() { - filledarrayBy( 'float64', constantFunction( 1.0 ), constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (array-like object)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (array-like object; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, 1, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, 1, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (no iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (no iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (non-function iterator symbol property)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (non-function iterator symbol property; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (`next` property is not a function)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ) ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (`next` property is not a function; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ), {} ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (no iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (no iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (non-function iterator symbol property)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (non-function iterator symbol property; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (`next` property is not a function)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ) ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (`next` property is not a function; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ), {} ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 1, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 1, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function returns a filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - arr = filledarrayBy(); - - t.strictEqual( instanceOf( arr, Float64Array ), 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=float64)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - arr = filledarrayBy( 'float64' ); - - t.strictEqual( instanceOf( arr, Float64Array ), 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=float32)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( 0 ); - arr = filledarrayBy( 'float32' ); - - t.strictEqual( instanceOf( arr, Float32Array ), 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=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; - - expected = new Complex128Array( 0 ); - arr = filledarrayBy( 'complex128' ); - - t.strictEqual( instanceOf( arr, Complex128Array ), 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=complex64)', function test( t ) { - var expected; - var arr; - - expected = new Complex64Array( 0 ); - arr = filledarrayBy( 'complex64' ); - - t.strictEqual( instanceOf( arr, Complex64Array ), 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=int32)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( 0 ); - arr = filledarrayBy( 'int32' ); - - t.strictEqual( instanceOf( arr, Int32Array ), 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=uint32)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( 0 ); - arr = filledarrayBy( 'uint32' ); - - t.strictEqual( instanceOf( arr, Uint32Array ), 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=int16)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( 0 ); - arr = filledarrayBy( 'int16' ); - - t.strictEqual( instanceOf( arr, Int16Array ), 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=uint16)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( 0 ); - arr = filledarrayBy( 'uint16' ); - - t.strictEqual( instanceOf( arr, Uint16Array ), 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=int8)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( 0 ); - arr = filledarrayBy( 'int8' ); - - t.strictEqual( instanceOf( arr, Int8Array ), 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=uint8)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( 0 ); - arr = filledarrayBy( 'uint8' ); - - t.strictEqual( instanceOf( arr, Uint8Array ), 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=uint8c)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( 0 ); - arr = filledarrayBy( 'uint8c' ); - - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), 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=generic)', function test( t ) { - var expected; - var arr; - - expected = []; - arr = filledarrayBy( 'generic' ); - - t.strictEqual( instanceOf( arr, Array ), 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 (default, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, length=0)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array(); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 0, clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, clbk, ctx ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (default, length; thisArg=function)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, clbk, context ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this(); // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } - - function context() { - ctx.count += 1; - } -}); - -tape( 'the function returns a filled array (dtype=float64, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, 'float64', clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, length; thisArg=function)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, 'float64', clbk, context ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this(); // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } - - function context() { - ctx.count += 1; - } -}); - -tape( 'the function returns a filled array (dtype=float32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, 'float32', clbk ); - - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - 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; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = filledarrayBy( 5, 'complex128', clbk ); - - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = filledarrayBy( 5, 'complex64', clbk ); - - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int32Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int32', clbk ); - - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint32Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint32', clbk ); - - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int16Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int16', clbk ); - - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint16', clbk ); - - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int8Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int8', clbk ); - - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint8', clbk ); - - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint8c', clbk ); - - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = [ 1, 1, 1, 1, 1 ]; - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'generic', clbk ); - - t.strictEqual( instanceOf( arr, Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - 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; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = [ 1.0, 2.0 ]; - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = [ 1.0, 2.0 ]; - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int32', clbk ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, typed array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, typed array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - 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; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = new Float64Array( [ 1.0, 2.0 ] ); - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = new Float64Array( [ 1.0, 2.0 ] ); - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (default, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - 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; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer, byteoffset; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer, byteoffset; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - 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; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 48 ); - out = filledarrayBy( buf, 16, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 24 ); - out = filledarrayBy( buf, 8, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int32', clbk ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint8c', clbk ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - 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; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 64 ); - out = filledarrayBy( buf, 16, 2, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset, length)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 1, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 1, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled array (default, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, iterator; thisArg)', opts, function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - ctx = { - 'count': 0 - }; - indices = []; - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, iterator; thisArg)', opts, function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - ctx = { - 'count': 0 - }; - indices = []; - out = filledarrayBy( arr, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - 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; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = iterConstant( new Complex128( 3.0, 3.0 ), { - 'iter': 2 - }); - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = iterConstant( new Complex64( 3.0, 3.0 ), { - 'iter': 2 - }); - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); From bb9cc8f75a78eea288c3daba84ddb8b6d022f11c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 16 Jan 2026 21:26:22 +0000 Subject: [PATCH 084/117] Transform error messages --- lib/main.js | 38 +++++++++++++++++++------------------- package.json | 2 +- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/lib/main.js b/lib/main.js index d2128f5..32b6545 100644 --- a/lib/main.js +++ b/lib/main.js @@ -35,7 +35,7 @@ var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-supp var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); var iterLength = require( '@stdlib/iter-length' ); var defaults = require( '@stdlib/array-defaults' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -266,18 +266,18 @@ function filledarrayBy() { if ( isString( dtype ) ) { // Invoking this function with arguments `f( dtype, clbk[, thisArg] )` is not allowed (otherwise, we'd need to also allow `f( clbk[, thisArg] )`)... if ( nargs > 1 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format('00h05') ); } ctor = ctors( dtype ); if ( ctor === null ) { - throw new TypeError( format( 'invalid argument. Must provide a recognized data type. Value: `%s`.', dtype ) ); + throw new TypeError( format( '00h2Y', dtype ) ); } // Return an empty array having the specified dtype: return new ctor( 0 ); } // For all other supported invocations, we need at least two arguments... if ( nargs < 2 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format('00h05') ); } // At this point, we need to do some argument juggling... nargs -= 1; // henceforth, the number of available arguments is `nargs+1` @@ -292,7 +292,7 @@ function filledarrayBy() { // Check if we were provided only a callback and a "this" context.. if ( nargs === 0 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format('00h05') ); } } else { // "this" context is left undefined... @@ -305,12 +305,12 @@ function filledarrayBy() { nargs -= 1; clbk = arguments[ nargs ]; if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '00h2b', clbk ) ); } } // If we were only provided 2 arguments and the last argument was not a function, we've been provided an insufficient number of arguments... else { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format('00h05') ); } // Now that we've processed the callback arguments, let's continue working backward to see if we've been provided a `dtype` argument... nargs -= 1; @@ -322,7 +322,7 @@ function filledarrayBy() { } ctor = ctors( dtype ); if ( ctor === null ) { - throw new TypeError( format( 'invalid argument. Must provide a recognized data type. Value: `%s`.', dtype ) ); + throw new TypeError( format( '00h2Y', dtype ) ); } // At this point, we've resolved the output array data type, and now we can actually create the output array... if ( dtype === 'generic' ) { @@ -337,26 +337,26 @@ function filledarrayBy() { return filledArray( len, clbk, thisArg ); } if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format('00h04') ); } if ( isObject( arg ) ) { if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2Z', arg ) ); } if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } arg = arg[ ITERATOR_SYMBOL ](); if ( !isFunction( arg.next ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } return filledArrayIterator( arg, clbk, thisArg ); } - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } else if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format('00h04') ); } - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } if ( nargs === 0 ) { // length || array-like || ArrayBuffer || iterable arg = arguments[ 0 ]; @@ -368,18 +368,18 @@ function filledarrayBy() { arr = new ctor( arg ); } else if ( isObject( arg ) ) { if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2Z', arg ) ); } if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } arg = arg[ ITERATOR_SYMBOL ](); if ( !isFunction( arg.next ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } arr = new ctor( iterLength( arg ) ); } else { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } } else if ( nargs === 1 ) { arr = new ctor( arguments[0], arguments[1] ); // (ArrayBuffer, byteOffset) diff --git a/package.json b/package.json index 42e92b1..b5ac3ab 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "@stdlib/assert-is-string": "^0.2.2", "@stdlib/blas-ext-base-gfill-by": "^0.2.1", "@stdlib/iter-length": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/symbol-iterator": "^0.2.2", "@stdlib/types": "^0.4.3", "@stdlib/error-tools-fmtprodmsg": "^0.2.2" From 03e6c0c7311a6eac6f415a1994b08b68e95b9880 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 16 Jan 2026 21:26:41 +0000 Subject: [PATCH 085/117] Remove files --- index.d.ts | 322 ---- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5169 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index cb63cd1..0000000 --- a/index.d.ts +++ /dev/null @@ -1,322 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, RealOrComplexTypedArray, BooleanArray, DataType } from '@stdlib/types/array'; -import { IterableIterator } from '@stdlib/types/iter'; - -/** -* Array or typed array. -*/ -type ArrayOrTypedArray = Array | RealOrComplexTypedArray | BooleanArray; - -/** -* Nullary callback function. -* -* @returns fill value -*/ -type Nullary = () => any; - -/** -* Unary callback function. -* -* @param i - current array index -* @returns fill value -*/ -type Unary = ( i: number ) => any; - -/** -* Callback function. -* -* @param i - current array index -* @returns fill value -*/ -type Callback = Nullary | Unary; - -/** -* Creates a filled array according to a provided callback function and having a specified data type. -* -* @param dtype - data type -* @returns filled array -* -* @example -* var arr = filledarrayBy(); -* // returns -* -* @example -* var arr = filledarrayBy( 'float32' ); -* // returns -*/ -declare function filledarrayBy( dtype?: DataType ): ArrayOrTypedArray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Creates a filled array according to a provided callback function and having a specified `length`. -* -* @param length - array length -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* -* var arr = filledarrayBy( 5, constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( length: number, clbk: Callback, thisArg?: any ): ArrayOrTypedArray; - -/** -* Creates a filled array according to a provided callback function and having a specified `length`. -* -* @param length - array length -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* -* var arr = filledarrayBy( 5, 'float64', constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( length: number, dtype: DataType, clbk: Callback, thisArg?: any ): ArrayOrTypedArray; - -/** -* Creates a filled array from another `array` according to a provided callback function. -* -* @param array - typed array or array-like object -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* -* 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; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Creates a filled array from another `array` according to a provided callback function. -* -* @param array - typed array or array-like object -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* -* 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; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Creates a filled array from an iterable according to a callback function. -* -* @param iterable - iterable -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var iterConstant = require( '@stdlib/iter-constant' ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarrayBy( it, constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( iterable: IterableIterator, clbk: Callback, thisArg?: any ): ArrayOrTypedArray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Creates a filled array from an iterable according to a callback function. -* -* @param iterable - iterable -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var iterConstant = require( '@stdlib/iter-constant' ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarrayBy( it, 'float64', constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( iterable: IterableIterator, dtype: DataType, clbk: 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. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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 | BooleanArray; - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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 | BooleanArray; - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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 | BooleanArray; - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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 | BooleanArray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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 | BooleanArray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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 | BooleanArray; // eslint-disable-line @typescript-eslint/unified-signatures - - -// EXPORTS // - -export = filledarrayBy; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 668c2f7..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@v0.0.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-ctors@v0.3.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill-by@v0.2.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled-by@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@v0.2.2-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.3.0-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";var v=f(),g=j.get("dtypes.default");function c(){var f,j,c,b,y,x,u,E;if(0===(j=arguments.length))return new(y=d(g))(0);if(r(c=arguments[0])){if(j>1)throw new TypeError(w("00h05"));if(null===(y=d(c)))throw new TypeError(w("00h2Y",c));return new y(0)}if(j<2)throw new TypeError(w("00h05"));if(h(arguments[j-=1]))if(h(arguments[j-1])){if(f=arguments[j],b=arguments[j-=1],0===j)throw new TypeError(w("00h05"))}else b=arguments[j];else{if(!(j>=2))throw new TypeError(w("00h05"));if(f=arguments[j],!h(b=arguments[j-=1]))throw new TypeError(w("00h2b",b))}if((j-=1)>=0&&r(arguments[j])?(c=arguments[j],j-=1):c=g,null===(y=d(c)))throw new TypeError(w("00h2Y",c));if("generic"===c){if(E=arguments[0],0===j){if(e(E)?u=E:i(E)&&(u=E.length),void 0!==u)return m(u,b,f);if(n(E))throw new Error(w("00h04"));if(o(E)){if(!1===v)throw new TypeError(w("00h2Z",E));if(!h(E[p]))throw new TypeError(w("00h2a",E));if(E=E[p](),!h(E.next))throw new TypeError(w("00h2a",E));return function(r,e,t){var s,i;for(s=[],i=-1;!r.next().done;)i+=1,s.push(e.call(t,i));return s}(E,b,f)}throw new TypeError(w("00h2a",E))}if(n(E))throw new Error(w("00h04"));throw new TypeError(w("00h2a",E))}if(0===j)if(i(E=arguments[0]))x=new y(E.length);else if(n(E))x=new y(E);else if(e(E))x=new y(E);else{if(!o(E))throw new TypeError(w("00h2a",E));if(!1===v)throw new TypeError(w("00h2Z",E));if(!h(E[p]))throw new TypeError(w("00h2a",E));if(E=E[p](),!h(E.next))throw new TypeError(w("00h2a",E));x=new y(a(E))}else x=1===j?new y(arguments[0],arguments[1]):new y(arguments[0],arguments[1],arguments[2]);return x.length>0&&(t(c)||s(c)?function(r,e,t){var s;for(s=0;s\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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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( format('00h05') );\n\t\t}\n\t\tctor = ctors( dtype );\n\t\tif ( ctor === null ) {\n\t\t\tthrow new TypeError( format( '00h2Y', 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( format('00h05') );\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( format('00h05') );\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( '00h2b', 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( format('00h05') );\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( '00h2Y', 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( format('00h04') );\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( '00h2Z', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00h2a', 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( '00h2a', 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( '00h2a', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format('00h04') );\n\t\t}\n\t\tthrow new TypeError( format( '00h2a', 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( '00h2Z', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00h2a', 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( '00h2a', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00h2a', 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\nexport default filledarrayBy;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","DEFAULT_DTYPE","defaults","get","filledarrayBy","thisArg","nargs","dtype","clbk","ctor","arr","len","arg","arguments","length","ctors","isString","TypeError","format","isFunction","isNonNegativeInteger","isCollection","filledArray","isArrayBuffer","Error","isObject","ITERATOR_SYMBOL","next","it","i","done","push","call","filledArrayIterator","iterLength","isComplexDataType","isBooleanDataType","set","filledAccessors","gfillBy","value","aidx"],"mappings":";;sjDA0CA,IAAIA,EAAsBC,IACtBC,EAAgBC,EAASC,IAAK,kBA2MlC,SAASC,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAKJ,GAAe,KAHfN,EAAQO,UAAUC,QAKjB,OAAO,IADPL,EAAOM,EAAOd,IACG,GAIlB,GAAKe,EADLT,EAAQM,UAAW,IACM,CAExB,GAAKP,EAAQ,EACZ,MAAM,IAAIW,UAAWC,EAAO,UAG7B,GAAc,QADdT,EAAOM,EAAOR,IAEb,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,OAAO,IAAIE,EAAM,EACjB,CAED,GAAKH,EAAQ,EACZ,MAAM,IAAIW,UAAWC,EAAO,UAM7B,GAAKC,EAAYN,UAHjBP,GAAS,IAKR,GAAKa,EAAYN,UAAWP,EAAM,KAMjC,GALAD,EAAUQ,UAAWP,GAErBE,EAAOK,UADPP,GAAS,GAIM,IAAVA,EACJ,MAAM,IAAIW,UAAWC,EAAO,eAI7BV,EAAOK,UAAWP,OAIf,MAAKA,GAAS,GAUlB,MAAM,IAAIW,UAAWC,EAAO,UAN5B,GAHAb,EAAUQ,UAAWP,IAGfa,EADNX,EAAOK,UADPP,GAAS,IAGR,MAAM,IAAIW,UAAWC,EAAQ,QAASV,GAMvC,CAUD,IARAF,GAAS,IACK,GAAKU,EAAUH,UAAWP,KACvCC,EAAQM,UAAWP,GACnBA,GAAS,GAETC,EAAQN,EAGK,QADdQ,EAAOM,EAAOR,IAEb,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,GAAe,YAAVA,EAAsB,CAE1B,GADAK,EAAMC,UAAW,GACF,IAAVP,EAAc,CAMlB,GALKc,EAAsBR,GAC1BD,EAAMC,EACKS,EAAcT,KACzBD,EAAMC,EAAIE,aAEE,IAARH,EACJ,OAAOW,EAAaX,EAAKH,EAAMH,GAEhC,GAAKkB,EAAeX,GACnB,MAAM,IAAIY,MAAON,EAAO,UAEzB,GAAKO,EAAUb,GAAQ,CACtB,IAA6B,IAAxBb,EACJ,MAAM,IAAIkB,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAYP,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLP,EAAYP,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvC,OAvSJ,SAA8BgB,EAAIpB,EAAMH,GACvC,IAAIK,EACAmB,EAKJ,IAFAnB,EAAM,GACNmB,GAAK,GAEAD,EAAGD,OACAG,MAGPD,GAAK,EACLnB,EAAIqB,KAAMvB,EAAKwB,KAAM3B,EAASwB,IAE/B,OAAOnB,CACR,CAuRWuB,CAAqBrB,EAAKJ,EAAMH,EACvC,CACD,MAAM,IAAIY,UAAWC,EAAQ,QAASN,GACzC,CAAS,GAAKW,EAAeX,GAC1B,MAAM,IAAIY,MAAON,EAAO,UAEzB,MAAM,IAAID,UAAWC,EAAQ,QAASN,GACtC,CACD,GAAe,IAAVN,EAEJ,GAAKe,EADLT,EAAMC,UAAW,IAEhBH,EAAM,IAAID,EAAMG,EAAIE,aACd,GAAKS,EAAeX,GAC1BF,EAAM,IAAID,EAAMG,QACV,GAAKQ,EAAsBR,GACjCF,EAAM,IAAID,EAAMG,OACV,KAAKa,EAAUb,GAarB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAZtC,IAA6B,IAAxBb,EACJ,MAAM,IAAIkB,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAYP,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLP,EAAYP,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvCF,EAAM,IAAID,EAAMyB,EAAYtB,GAG5B,MAEDF,EADqB,IAAVJ,EACL,IAAIG,EAAMI,UAAU,GAAIA,UAAU,IAElC,IAAIJ,EAAMI,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKH,EAAII,OAAS,IACZqB,EAAmB5B,IAAW6B,EAAmB7B,GAjTxD,SAA0BG,EAAKF,EAAMH,GACpC,IAAIwB,EACJ,IAAMA,EAAI,EAAGA,EAAInB,EAAII,OAAQe,IAC5BnB,EAAI2B,IAAK7B,EAAKwB,KAAM3B,EAASwB,GAAKA,EAGpC,CA4SGS,CAAiB5B,EAAKF,EAAMH,GAE5BkC,EAAS7B,EAAII,OAAQJ,EAAK,GAe5B,SAAmB8B,EAAOC,GACzB,OAAOjC,EAAKwB,KAAM3B,EAASoC,EAC3B,KAdM/B,CAeR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index e4cee9c..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From a64098f8a4ba4daa4cee55f4761cded5b06194cc Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 16 Jan 2026 21:27:07 +0000 Subject: [PATCH 086/117] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 108 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 199 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 192 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 49 +- SECURITY.md | 5 - benchmark/benchmark.js | 341 -- benchmark/benchmark.length.bool.js | 97 - benchmark/benchmark.length.complex128.js | 98 - benchmark/benchmark.length.complex64.js | 98 - benchmark/benchmark.length.float32.js | 97 - benchmark/benchmark.length.float64.js | 97 - benchmark/benchmark.length.generic.js | 97 - benchmark/benchmark.length.int16.js | 97 - benchmark/benchmark.length.int32.js | 97 - benchmark/benchmark.length.int8.js | 97 - benchmark/benchmark.length.uint16.js | 97 - benchmark/benchmark.length.uint32.js | 97 - benchmark/benchmark.length.uint8.js | 97 - benchmark/benchmark.length.uint8c.js | 97 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 36 - dist/index.js.map | 7 - docs/repl.txt | 157 - docs/types/test.ts | 606 --- examples/index.js | 37 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 192 - lib/main.js | 416 -- package.json | 96 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 4397 ---------------- 56 files changed, 4870 insertions(+), 11253 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.length.bool.js delete mode 100644 benchmark/benchmark.length.complex128.js delete mode 100644 benchmark/benchmark.length.complex64.js delete mode 100644 benchmark/benchmark.length.float32.js delete mode 100644 benchmark/benchmark.length.float64.js delete mode 100644 benchmark/benchmark.length.generic.js delete mode 100644 benchmark/benchmark.length.int16.js delete mode 100644 benchmark/benchmark.length.int32.js delete mode 100644 benchmark/benchmark.length.int8.js delete mode 100644 benchmark/benchmark.length.uint16.js delete mode 100644 benchmark/benchmark.length.uint32.js delete mode 100644 benchmark/benchmark.length.uint8.js delete mode 100644 benchmark/benchmark.length.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 2d6aaee..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/contributing/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index f988046..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index b2c1f9c..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '42 6 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 83d50c4..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,821 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send notification to Zulip if job fails: - - name: 'Send notification to Zulip in case of failure' - # Pin action to full length commit SHA - uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 - if: failure() - with: - api-key: ${{ secrets.ZULIP_API_KEY }} - email: 'github-actions-bot@stdlib.zulipchat.com' - organization-url: 'https://stdlib.zulipchat.com' - to: 'workflows-standalone' - type: 'stream' - topic: ${{ github.event.repository.name }} - content: | - :cross_mark: **${{ github.workflow }}** workflow failed - - **Repository:** [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) - **Run:** [View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -278,7 +269,7 @@ for ( i = 0; i < dt.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -347,13 +338,13 @@ Copyright © 2016-2026. 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/dtypes]: https://github.com/stdlib-js/array-dtypes/tree/esm -[@stdlib/array/filled]: https://github.com/stdlib-js/array-filled +[@stdlib/array/filled]: https://github.com/stdlib-js/array-filled/tree/esm -[@stdlib/array/typed]: https://github.com/stdlib-js/array-typed +[@stdlib/array/typed]: https://github.com/stdlib-js/array-typed/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 17cfb5a..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,341 +0,0 @@ -/** -* @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 isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); -var isArray = require( '@stdlib/assert-is-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var Complex64 = require( '@stdlib/complex-float32-ctor' ); -var Complex128 = require( '@stdlib/complex-float64-ctor' ); -var pkg = require( './../package.json' ).name; -var filledarrayBy = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 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=float64', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'float64', 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=float32', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'float32', 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=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; - var i; - - clbk = constantFunction( new Complex128( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'complex128', 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=complex64', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( new Complex64( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'complex64', 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=int32', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int32', 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=uint32', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint32', 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=int16', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int16', 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=uint16', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint16', 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=int8', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int8', 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=uint8', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint8', 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=uint8c', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint8c', 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=generic', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'generic', clbk ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.length.bool.js b/benchmark/benchmark.length.bool.js deleted file mode 100644 index 3cdd152..0000000 --- a/benchmark/benchmark.length.bool.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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/benchmark/benchmark.length.complex128.js b/benchmark/benchmark.length.complex128.js deleted file mode 100644 index 122bc7c..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 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 Complex128 = require( '@stdlib/complex-float64-ctor' ); -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( new Complex128( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'complex128', 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=complex128,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.complex64.js b/benchmark/benchmark.length.complex64.js deleted file mode 100644 index e7a2d74..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 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 Complex64 = require( '@stdlib/complex-float32-ctor' ); -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( new Complex64( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'complex64', 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=complex64,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.float32.js b/benchmark/benchmark.length.float32.js deleted file mode 100644 index d2b2ba7..0000000 --- a/benchmark/benchmark.length.float32.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'float32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=float32,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.float64.js b/benchmark/benchmark.length.float64.js deleted file mode 100644 index 65064e3..0000000 --- a/benchmark/benchmark.length.float64.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'float64', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=float64,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.generic.js b/benchmark/benchmark.length.generic.js deleted file mode 100644 index eb87dfa..0000000 --- a/benchmark/benchmark.length.generic.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isArray = require( '@stdlib/assert-is-array' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'generic', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isArray( 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=generic,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int16.js b/benchmark/benchmark.length.int16.js deleted file mode 100644 index 914ff7c..0000000 --- a/benchmark/benchmark.length.int16.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int16', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=int16,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int32.js b/benchmark/benchmark.length.int32.js deleted file mode 100644 index cc0f678..0000000 --- a/benchmark/benchmark.length.int32.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=int32,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int8.js b/benchmark/benchmark.length.int8.js deleted file mode 100644 index 77553b0..0000000 --- a/benchmark/benchmark.length.int8.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int8', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=int8,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint16.js b/benchmark/benchmark.length.uint16.js deleted file mode 100644 index c68efdd..0000000 --- a/benchmark/benchmark.length.uint16.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint16', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint16,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint32.js b/benchmark/benchmark.length.uint32.js deleted file mode 100644 index 27c1742..0000000 --- a/benchmark/benchmark.length.uint32.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint32,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint8.js b/benchmark/benchmark.length.uint8.js deleted file mode 100644 index 2a26be4..0000000 --- a/benchmark/benchmark.length.uint8.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint8', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint8,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint8c.js b/benchmark/benchmark.length.uint8c.js deleted file mode 100644 index dd6e8c2..0000000 --- a/benchmark/benchmark.length.uint8c.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint8c', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint8c,len='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index c138144..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by" -%% click B href "https://github.com/stdlib-js/array-filled-by/tree/main" -%% click C href "https://github.com/stdlib-js/array-filled-by/tree/production" -%% click D href "https://github.com/stdlib-js/array-filled-by/tree/esm" -%% click E href "https://github.com/stdlib-js/array-filled-by/tree/deno" -%% click F href "https://github.com/stdlib-js/array-filled-by/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by -[production-url]: https://github.com/stdlib-js/array-filled-by/tree/production -[deno-url]: https://github.com/stdlib-js/array-filled-by/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-filled-by/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-filled-by/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-filled-by/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-filled-by/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-filled-by/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 188fc9b..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import filledarrayBy from '../docs/types/index'; -export = filledarrayBy; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 65ae3db..0000000 --- a/dist/index.js +++ /dev/null @@ -1,36 +0,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 deleted file mode 100644 index b348e92..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "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 we 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,YACjDC,EAAuB,QAAS,uCAAwC,EAAE,YAC1EC,EAAoB,QAAS,+DAAgE,EAC7FC,EAAoB,QAAS,gDAAiD,EAC9EC,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,EAAQ,UAAU,OAGbA,IAAU,EACd,OAAAE,EAAOrB,EAAOS,CAAc,EACrB,IAAIY,EAAM,CAAE,EAIpB,GADAD,EAAQ,UAAW,CAAE,EAChB5B,EAAU4B,CAAM,EAAI,CAExB,GAAKD,EAAQ,EACZ,MAAM,IAAI,UAAW,2FAA4F,EAGlH,GADAE,EAAOrB,EAAOoB,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWd,EAAQ,sEAAuEa,CAAM,CAAE,EAG7G,OAAO,IAAIC,EAAM,CAAE,CACpB,CAEA,GAAKF,EAAQ,EACZ,MAAM,IAAI,UAAW,2FAA4F,EAMlH,GAHAA,GAAS,EAGJpB,EAAY,UAAWoB,CAAM,CAAE,EAEnC,GAAKpB,EAAY,UAAWoB,EAAM,CAAE,CAAE,GAMrC,GALAN,EAAU,UAAWM,CAAM,EAC3BA,GAAS,EACTP,EAAO,UAAWO,CAAM,EAGnBA,IAAU,EACd,MAAM,IAAI,UAAW,2FAA4F,OAIlHP,EAAO,UAAWO,CAAM,UAIhBA,GAAS,GAIlB,GAHAN,EAAU,UAAWM,CAAM,EAC3BA,GAAS,EACTP,EAAO,UAAWO,CAAM,EACnB,CAACpB,EAAYa,CAAK,EACtB,MAAM,IAAI,UAAWL,EAAQ,uEAAwEK,CAAK,CAAE,MAK7G,OAAM,IAAI,UAAW,2FAA4F,EAWlH,GARAO,GAAS,EACJA,GAAS,GAAK3B,EAAU,UAAW2B,CAAM,CAAE,GAC/CC,EAAQ,UAAWD,CAAM,EACzBA,GAAS,GAETC,EAAQX,EAETY,EAAOrB,EAAOoB,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWd,EAAQ,sEAAuEa,CAAM,CAAE,EAG7G,GAAKA,IAAU,UAAY,CAE1B,GADAG,EAAM,UAAW,CAAE,EACdJ,IAAU,EAAI,CAMlB,GALK1B,EAAsB8B,CAAI,EAC9BD,EAAMC,EACK3B,EAAc2B,CAAI,IAC7BD,EAAMC,EAAI,QAEND,IAAQ,OACZ,OAAOpB,EAAaoB,EAAKV,EAAMC,CAAQ,EAExC,GAAKhB,EAAe0B,CAAI,EACvB,MAAM,IAAI,MAAO,mFAAoF,EAEtG,GAAKzB,EAAUyB,CAAI,EAAI,CACtB,GAAKf,IAAwB,GAC5B,MAAM,IAAI,UAAWD,EAAQ,sIAAuIgB,CAAI,CAAE,EAE3K,GAAK,CAACxB,EAAYwB,EAAKnB,CAAgB,CAAE,EACxC,MAAM,IAAI,UAAWG,EAAQ,wGAAyGgB,CAAI,CAAE,EAG7I,GADAA,EAAMA,EAAKnB,CAAgB,EAAE,EACxB,CAACL,EAAYwB,EAAI,IAAK,EAC1B,MAAM,IAAI,UAAWhB,EAAQ,wGAAyGgB,CAAI,CAAE,EAE7I,OAAOb,EAAqBa,EAAKX,EAAMC,CAAQ,CAChD,CACA,MAAM,IAAI,UAAWN,EAAQ,wGAAyGgB,CAAI,CAAE,CAC7I,SAAY1B,EAAe0B,CAAI,EAC9B,MAAM,IAAI,MAAO,mFAAoF,EAEtG,MAAM,IAAI,UAAWhB,EAAQ,wGAAyGgB,CAAI,CAAE,CAC7I,CACA,GAAKJ,IAAU,EAEd,GADAI,EAAM,UAAW,CAAE,EACd3B,EAAc2B,CAAI,EACtBT,EAAM,IAAIO,EAAME,EAAI,MAAO,UAChB1B,EAAe0B,CAAI,EAC9BT,EAAM,IAAIO,EAAME,CAAI,UACT9B,EAAsB8B,CAAI,EACrCT,EAAM,IAAIO,EAAME,CAAI,UACTzB,EAAUyB,CAAI,EAAI,CAC7B,GAAKf,IAAwB,GAC5B,MAAM,IAAI,UAAWD,EAAQ,sIAAuIgB,CAAI,CAAE,EAE3K,GAAK,CAACxB,EAAYwB,EAAKnB,CAAgB,CAAE,EACxC,MAAM,IAAI,UAAWG,EAAQ,wGAAyGgB,CAAI,CAAE,EAG7I,GADAA,EAAMA,EAAKnB,CAAgB,EAAE,EACxB,CAACL,EAAYwB,EAAI,IAAK,EAC1B,MAAM,IAAI,UAAWhB,EAAQ,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,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 deleted file mode 100644 index 06f3146..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,157 +0,0 @@ - -{{alias}}( [dtype] ) - Creates a filled array. - - Parameters - ---------- - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr = {{alias}}() - - > arr = {{alias}}( 'float32' ) - - - -{{alias}}( length[, dtype], clbk[, thisArg] ) - Returns a filled array according to a provided callback function and having - a specified length. - - Parameters - ---------- - length: integer - Array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > function clbk() { return 1.0; }; - > var arr = {{alias}}( 5, clbk ) - [ 1.0, 1.0, 1.0, 1.0, 1.0 ] - > arr = {{alias}}( 5, 'int32', clbk ) - [ 1, 1, 1, 1, 1 ] - - -{{alias}}( array[, dtype], clbk[, thisArg] ) - Creates a filled array from another array (or array-like object) according - to a provided callback function. - - Parameters - ---------- - array: ArrayLikeObject - Array from which to generate another array. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias}}( [ 0.5, 0.5, 0.5 ], {{alias:@stdlib/utils/constant-function}}( 2.0 ) ) - [ 2.0, 2.0, 2.0 ] - > var arr2 = {{alias}}( arr1, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( iterable[, dtype], clbk[, thisArg] ) - Creates a filled array from an iterable according to a provided callback - function. - - Parameters - ---------- - iterable: Iterable - Iterable from which to generate an array. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias:@stdlib/iter/constant}}( 3.0, {'iter': 3} ); - > var arr2 = {{alias}}( arr1, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( buffer[, byteOffset[, length]][, dtype], clbk[, thisArg] ) - Returns a filled typed array view of an ArrayBuffer according to a provided - callback function. - - The 'generic' array data type is *not* supported. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( buf, 0, 4, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0, 1.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index bb876ed..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,606 +0,0 @@ -/* -* @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. -*/ - -/// - -import { IterableIterator } from '@stdlib/types/iter'; -import filledarrayBy = require( './index' ); - - -/** -* Returns an iterator protocol-compliant object. -* -* @returns iterator protocol-compliant object -*/ -function iterator(): IterableIterator { - const obj: IterableIterator = { - [Symbol.iterator]: iterator, - 'next': next - }; - return obj; -} - -/** -* Implements the iterator protocol `next` method. -* -* @returns iterator protocol-compliant object -*/ -function next(): any { - return { - 'value': 1.0, - 'done': false - }; -} - -/** -* Callback function. -* -* @param i - current array index -* @returns return value -*/ -function clbk( i: number ): number { - return i; -} - - -// TESTS // - -// The function returns an array or typed array... -{ - filledarrayBy(); // $ExpectType ArrayOrTypedArray - filledarrayBy( 'float32' ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( 10, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( 10, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( 10, 'int32', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( 10, 'int32', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const x = new Float64Array( 10 ); - filledarrayBy( x, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( x, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( x, 'uint8', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( x, 'uint8', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const y = [ 2.0, 2.0, 2.0 ]; - filledarrayBy( y, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( y, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( y, 'float64', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( y, 'float64', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const it = iterator(); - filledarrayBy( it, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( it, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( it, 'uint8c', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( it, 'uint8c', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const buf = new ArrayBuffer( 32 ); - filledarrayBy( buf, clbk ); // $ExpectType RealOrComplexTypedArray | BooleanArray - filledarrayBy( buf, clbk, {} ); // $ExpectType RealOrComplexTypedArray | BooleanArray - - filledarrayBy( buf, 'uint32', clbk ); // $ExpectType RealOrComplexTypedArray | BooleanArray - filledarrayBy( buf, 'uint32', clbk, {} ); // $ExpectType RealOrComplexTypedArray | BooleanArray - - filledarrayBy( buf, 8, clbk ); // $ExpectType RealOrComplexTypedArray | BooleanArray - filledarrayBy( buf, 8, clbk, {} ); // $ExpectType RealOrComplexTypedArray | BooleanArray - - filledarrayBy( buf, 8, 'uint16', clbk ); // $ExpectType RealOrComplexTypedArray | BooleanArray - filledarrayBy( buf, 8, 'uint16', clbk, {} ); // $ExpectType RealOrComplexTypedArray | BooleanArray - - filledarrayBy( buf, 8, 2, clbk ); // $ExpectType RealOrComplexTypedArray | BooleanArray - filledarrayBy( buf, 8, 2, clbk, {} ); // $ExpectType RealOrComplexTypedArray | BooleanArray - - filledarrayBy( buf, 8, 2, 'int16', clbk ); // $ExpectType RealOrComplexTypedArray | BooleanArray - filledarrayBy( buf, 8, 2, 'int16', clbk, {} ); // $ExpectType RealOrComplexTypedArray | BooleanArray -} - -// The compiler throws an error if a callback function argument is not a function... -{ - filledarrayBy( 'float64', '5' ); // $ExpectError - filledarrayBy( 'float64', 1.0 ); // $ExpectError - filledarrayBy( 'float64', false ); // $ExpectError - filledarrayBy( 'float64', true ); // $ExpectError - filledarrayBy( 'float64', null ); // $ExpectError - filledarrayBy( 'float64', undefined ); // $ExpectError - filledarrayBy( 'float64', [] ); // $ExpectError - filledarrayBy( 'float64', {} ); // $ExpectError - - filledarrayBy( 'float64', '5', {} ); // $ExpectError - filledarrayBy( 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( 'float64', false, {} ); // $ExpectError - filledarrayBy( 'float64', true, {} ); // $ExpectError - filledarrayBy( 'float64', null, {} ); // $ExpectError - filledarrayBy( 'float64', undefined, {} ); // $ExpectError - filledarrayBy( 'float64', [], {} ); // $ExpectError - filledarrayBy( 'float64', {}, {} ); // $ExpectError - - filledarrayBy( 10, '5' ); // $ExpectError - filledarrayBy( 10, 1.0 ); // $ExpectError - filledarrayBy( 10, false ); // $ExpectError - filledarrayBy( 10, true ); // $ExpectError - filledarrayBy( 10, null ); // $ExpectError - filledarrayBy( 10, undefined ); // $ExpectError - filledarrayBy( 10, [] ); // $ExpectError - filledarrayBy( 10, {} ); // $ExpectError - - filledarrayBy( 10, '5', {} ); // $ExpectError - filledarrayBy( 10, 1.0, {} ); // $ExpectError - filledarrayBy( 10, false, {} ); // $ExpectError - filledarrayBy( 10, true, {} ); // $ExpectError - filledarrayBy( 10, null, {} ); // $ExpectError - filledarrayBy( 10, undefined, {} ); // $ExpectError - filledarrayBy( 10, [], {} ); // $ExpectError - filledarrayBy( 10, {}, {} ); // $ExpectError - - filledarrayBy( 10, 'float64', '5' ); // $ExpectError - filledarrayBy( 10, 'float64', 1.0 ); // $ExpectError - filledarrayBy( 10, 'float64', false ); // $ExpectError - filledarrayBy( 10, 'float64', true ); // $ExpectError - filledarrayBy( 10, 'float64', null ); // $ExpectError - filledarrayBy( 10, 'float64', undefined ); // $ExpectError - filledarrayBy( 10, 'float64', [] ); // $ExpectError - filledarrayBy( 10, 'float64', {} ); // $ExpectError - - filledarrayBy( 10, 'float64', '5', {} ); // $ExpectError - filledarrayBy( 10, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( 10, 'float64', false, {} ); // $ExpectError - filledarrayBy( 10, 'float64', true, {} ); // $ExpectError - filledarrayBy( 10, 'float64', null, {} ); // $ExpectError - filledarrayBy( 10, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( 10, 'float64', [], {} ); // $ExpectError - filledarrayBy( 10, 'float64', {}, {} ); // $ExpectError - - const x = new Float64Array( 10 ); - filledarrayBy( x, '5' ); // $ExpectError - filledarrayBy( x, 1.0 ); // $ExpectError - filledarrayBy( x, false ); // $ExpectError - filledarrayBy( x, true ); // $ExpectError - filledarrayBy( x, null ); // $ExpectError - filledarrayBy( x, undefined ); // $ExpectError - filledarrayBy( x, [] ); // $ExpectError - filledarrayBy( x, {} ); // $ExpectError - - filledarrayBy( x, '5', {} ); // $ExpectError - filledarrayBy( x, 1.0, {} ); // $ExpectError - filledarrayBy( x, false, {} ); // $ExpectError - filledarrayBy( x, true, {} ); // $ExpectError - filledarrayBy( x, null, {} ); // $ExpectError - filledarrayBy( x, undefined, {} ); // $ExpectError - filledarrayBy( x, [], {} ); // $ExpectError - filledarrayBy( x, {}, {} ); // $ExpectError - - filledarrayBy( x, 'float64', '5' ); // $ExpectError - filledarrayBy( x, 'float64', 1.0 ); // $ExpectError - filledarrayBy( x, 'float64', false ); // $ExpectError - filledarrayBy( x, 'float64', true ); // $ExpectError - filledarrayBy( x, 'float64', null ); // $ExpectError - filledarrayBy( x, 'float64', undefined ); // $ExpectError - filledarrayBy( x, 'float64', [] ); // $ExpectError - filledarrayBy( x, 'float64', {} ); // $ExpectError - - filledarrayBy( x, 'float64', '5', {} ); // $ExpectError - filledarrayBy( x, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( x, 'float64', false, {} ); // $ExpectError - filledarrayBy( x, 'float64', true, {} ); // $ExpectError - filledarrayBy( x, 'float64', null, {} ); // $ExpectError - filledarrayBy( x, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( x, 'float64', [], {} ); // $ExpectError - filledarrayBy( x, 'float64', {}, {} ); // $ExpectError - - const y = [ 2.0, 2.0, 2.0 ]; - filledarrayBy( y, '5' ); // $ExpectError - filledarrayBy( y, 1.0 ); // $ExpectError - filledarrayBy( y, false ); // $ExpectError - filledarrayBy( y, true ); // $ExpectError - filledarrayBy( y, null ); // $ExpectError - filledarrayBy( y, undefined ); // $ExpectError - filledarrayBy( y, [] ); // $ExpectError - filledarrayBy( y, {} ); // $ExpectError - - filledarrayBy( y, '5', {} ); // $ExpectError - filledarrayBy( y, 1.0, {} ); // $ExpectError - filledarrayBy( y, false, {} ); // $ExpectError - filledarrayBy( y, true, {} ); // $ExpectError - filledarrayBy( y, null, {} ); // $ExpectError - filledarrayBy( y, undefined, {} ); // $ExpectError - filledarrayBy( y, [], {} ); // $ExpectError - filledarrayBy( y, {}, {} ); // $ExpectError - - filledarrayBy( y, 'float64', '5' ); // $ExpectError - filledarrayBy( y, 'float64', 1.0 ); // $ExpectError - filledarrayBy( y, 'float64', false ); // $ExpectError - filledarrayBy( y, 'float64', true ); // $ExpectError - filledarrayBy( y, 'float64', null ); // $ExpectError - filledarrayBy( y, 'float64', undefined ); // $ExpectError - filledarrayBy( y, 'float64', [] ); // $ExpectError - filledarrayBy( y, 'float64', {} ); // $ExpectError - - filledarrayBy( y, 'float64', '5', {} ); // $ExpectError - filledarrayBy( y, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( y, 'float64', false, {} ); // $ExpectError - filledarrayBy( y, 'float64', true, {} ); // $ExpectError - filledarrayBy( y, 'float64', null, {} ); // $ExpectError - filledarrayBy( y, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( y, 'float64', [], {} ); // $ExpectError - filledarrayBy( y, 'float64', {}, {} ); // $ExpectError - - const it = iterator(); - filledarrayBy( it, '5' ); // $ExpectError - filledarrayBy( it, 1.0 ); // $ExpectError - filledarrayBy( it, false ); // $ExpectError - filledarrayBy( it, true ); // $ExpectError - filledarrayBy( it, null ); // $ExpectError - filledarrayBy( it, undefined ); // $ExpectError - filledarrayBy( it, [] ); // $ExpectError - filledarrayBy( it, {} ); // $ExpectError - - filledarrayBy( it, '5', {} ); // $ExpectError - filledarrayBy( it, 1.0, {} ); // $ExpectError - filledarrayBy( it, false, {} ); // $ExpectError - filledarrayBy( it, true, {} ); // $ExpectError - filledarrayBy( it, null, {} ); // $ExpectError - filledarrayBy( it, undefined, {} ); // $ExpectError - filledarrayBy( it, [], {} ); // $ExpectError - filledarrayBy( it, {}, {} ); // $ExpectError - - filledarrayBy( it, 'float64', '5' ); // $ExpectError - filledarrayBy( it, 'float64', 1.0 ); // $ExpectError - filledarrayBy( it, 'float64', false ); // $ExpectError - filledarrayBy( it, 'float64', true ); // $ExpectError - filledarrayBy( it, 'float64', null ); // $ExpectError - filledarrayBy( it, 'float64', undefined ); // $ExpectError - filledarrayBy( it, 'float64', [] ); // $ExpectError - filledarrayBy( it, 'float64', {} ); // $ExpectError - - filledarrayBy( it, 'float64', '5', {} ); // $ExpectError - filledarrayBy( it, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( it, 'float64', false, {} ); // $ExpectError - filledarrayBy( it, 'float64', true, {} ); // $ExpectError - filledarrayBy( it, 'float64', null, {} ); // $ExpectError - filledarrayBy( it, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( it, 'float64', [], {} ); // $ExpectError - filledarrayBy( it, 'float64', {}, {} ); // $ExpectError - - const buf = new ArrayBuffer( 32 ); - filledarrayBy( buf, '5' ); // $ExpectError - filledarrayBy( buf, 1.0 ); // $ExpectError - filledarrayBy( buf, false ); // $ExpectError - filledarrayBy( buf, true ); // $ExpectError - filledarrayBy( buf, null ); // $ExpectError - filledarrayBy( buf, undefined ); // $ExpectError - filledarrayBy( buf, [] ); // $ExpectError - filledarrayBy( buf, {} ); // $ExpectError - - filledarrayBy( buf, '5', {} ); // $ExpectError - filledarrayBy( buf, 1.0, {} ); // $ExpectError - filledarrayBy( buf, false, {} ); // $ExpectError - filledarrayBy( buf, true, {} ); // $ExpectError - filledarrayBy( buf, null, {} ); // $ExpectError - filledarrayBy( buf, undefined, {} ); // $ExpectError - filledarrayBy( buf, [], {} ); // $ExpectError - filledarrayBy( buf, {}, {} ); // $ExpectError - - filledarrayBy( buf, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 'float64', false ); // $ExpectError - filledarrayBy( buf, 'float64', true ); // $ExpectError - filledarrayBy( buf, 'float64', null ); // $ExpectError - filledarrayBy( buf, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 'float64', {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5' ); // $ExpectError - filledarrayBy( buf, 8, 1.0 ); // $ExpectError - filledarrayBy( buf, 8, false ); // $ExpectError - filledarrayBy( buf, 8, true ); // $ExpectError - filledarrayBy( buf, 8, null ); // $ExpectError - filledarrayBy( buf, 8, undefined ); // $ExpectError - filledarrayBy( buf, 8, [] ); // $ExpectError - filledarrayBy( buf, 8, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, false, {} ); // $ExpectError - filledarrayBy( buf, 8, true, {} ); // $ExpectError - filledarrayBy( buf, 8, null, {} ); // $ExpectError - filledarrayBy( buf, 8, undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, [], {} ); // $ExpectError - filledarrayBy( buf, 8, {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 8, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 'float64', false ); // $ExpectError - filledarrayBy( buf, 8, 'float64', true ); // $ExpectError - filledarrayBy( buf, 8, 'float64', null ); // $ExpectError - filledarrayBy( buf, 8, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 8, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 8, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 8, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, '5' ); // $ExpectError - filledarrayBy( buf, 8, 2, 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 2, false ); // $ExpectError - filledarrayBy( buf, 8, 2, true ); // $ExpectError - filledarrayBy( buf, 8, 2, null ); // $ExpectError - filledarrayBy( buf, 8, 2, undefined ); // $ExpectError - filledarrayBy( buf, 8, 2, [] ); // $ExpectError - filledarrayBy( buf, 8, 2, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, false, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, true, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, null, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, [], {} ); // $ExpectError - filledarrayBy( buf, 8, 2, {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', false ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', true ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', null ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', {}, {} ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid length, typed array, array-like object, `ArrayBuffer`, or iterable argument... -{ - filledarrayBy( false, clbk ); // $ExpectError - filledarrayBy( true, clbk ); // $ExpectError - filledarrayBy( null, clbk ); // $ExpectError - filledarrayBy( {}, clbk ); // $ExpectError - - filledarrayBy( false, clbk, {} ); // $ExpectError - filledarrayBy( true, clbk, {} ); // $ExpectError - filledarrayBy( null, clbk, {} ); // $ExpectError - filledarrayBy( {}, clbk, {} ); // $ExpectError - - filledarrayBy( false, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 'float64', clbk ); // $ExpectError - - filledarrayBy( false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, clbk ); // $ExpectError - filledarrayBy( 1.0, 8, clbk ); // $ExpectError - filledarrayBy( false, 8, clbk ); // $ExpectError - filledarrayBy( true, 8, clbk ); // $ExpectError - filledarrayBy( null, 8, clbk ); // $ExpectError - filledarrayBy( undefined, 8, clbk ); // $ExpectError - filledarrayBy( [], 8, clbk ); // $ExpectError - filledarrayBy( {}, 8, clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, clbk ); // $ExpectError - - filledarrayBy( '5', 8, clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, clbk, {} ); // $ExpectError - filledarrayBy( false, 8, clbk, {} ); // $ExpectError - filledarrayBy( true, 8, clbk, {} ); // $ExpectError - filledarrayBy( null, 8, clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, clbk, {} ); // $ExpectError - filledarrayBy( [], 8, clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 'float64', clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( false, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( [], 8, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 'float64', clbk ); // $ExpectError - - filledarrayBy( '5', 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 2, clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 2, clbk ); // $ExpectError - filledarrayBy( false, 8, 2, clbk ); // $ExpectError - filledarrayBy( true, 8, 2, clbk ); // $ExpectError - filledarrayBy( null, 8, 2, clbk ); // $ExpectError - filledarrayBy( undefined, 8, 2, clbk ); // $ExpectError - filledarrayBy( [], 8, 2, clbk ); // $ExpectError - filledarrayBy( {}, 8, 2, clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, clbk ); // $ExpectError - - filledarrayBy( '5', 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( false, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( [], 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, 'float64', clbk ); // $ExpectError - - filledarrayBy( '5', 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a byte offset argument which is not a number... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, false, clbk ); // $ExpectError - filledarrayBy( buf, true, clbk ); // $ExpectError - filledarrayBy( buf, null, clbk ); // $ExpectError - filledarrayBy( buf, [], clbk ); // $ExpectError - filledarrayBy( buf, {}, clbk ); // $ExpectError - - filledarrayBy( buf, false, clbk, {} ); // $ExpectError - filledarrayBy( buf, true, clbk, {} ); // $ExpectError - filledarrayBy( buf, null, clbk, {} ); // $ExpectError - filledarrayBy( buf, [], clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, clbk, {} ); // $ExpectError - - filledarrayBy( buf, '5', 'float64', clbk ); // $ExpectError - filledarrayBy( buf, false, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, true, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, null, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, [], 'float64', clbk ); // $ExpectError - filledarrayBy( buf, {}, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, '5', 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( buf, false, 2, clbk ); // $ExpectError - filledarrayBy( buf, true, 2, clbk ); // $ExpectError - filledarrayBy( buf, null, 2, clbk ); // $ExpectError - filledarrayBy( buf, [], 2, clbk ); // $ExpectError - filledarrayBy( buf, {}, 2, clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, clbk ); // $ExpectError - - filledarrayBy( buf, false, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, clbk, {} ); // $ExpectError - - filledarrayBy( buf, '5', 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, false, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, true, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, null, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, undefined, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, [], 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, {}, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, '5', 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, false, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, undefined, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a view length argument which is not a number... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, 8, false, clbk ); // $ExpectError - filledarrayBy( buf, 8, true, clbk ); // $ExpectError - filledarrayBy( buf, 8, null, clbk ); // $ExpectError - filledarrayBy( buf, 8, [], clbk ); // $ExpectError - filledarrayBy( buf, 8, {}, clbk ); // $ExpectError - - filledarrayBy( buf, 8, false, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, true, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, null, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, [], clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, {}, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, clbk, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5', 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, false, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, true, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, null, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, [], 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, {}, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, 8, '5', 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, [], 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, {}, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided too many arguments... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, 8, 2, 'float64', 1, clbk, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 997a381..0000000 --- a/examples/index.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ).factory; -var dtypes = require( '@stdlib/array-typed-real-dtypes' ); -var filledarrayBy = require( './../lib' ); - -// Create a pseudorandom number generator: -var rand = discreteUniform( 0, 100 ); - -// Get a list of array data types: -var dt = dtypes(); - -// Generate filled arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = filledarrayBy( 10, dt[ i ], rand ); - console.log( arr ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 764e40e..cb63cd1 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, RealOrComplexTypedArray, BooleanArray, DataType } from '@stdlib/types/array'; import { IterableIterator } from '@stdlib/types/iter'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..44a4dbe --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@v0.0.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-ctors@v0.3.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill-by@v0.2.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled-by@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@v0.2.2-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.3.0-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";var v=f(),g=j.get("dtypes.default");function c(){var f,j,c,b,y,x,u,E;if(0===(j=arguments.length))return new(y=d(g))(0);if(r(c=arguments[0])){if(j>1)throw new TypeError(w("00h05"));if(null===(y=d(c)))throw new TypeError(w("00h2Y",c));return new y(0)}if(j<2)throw new TypeError(w("00h05"));if(h(arguments[j-=1]))if(h(arguments[j-1])){if(f=arguments[j],b=arguments[j-=1],0===j)throw new TypeError(w("00h05"))}else b=arguments[j];else{if(!(j>=2))throw new TypeError(w("00h05"));if(f=arguments[j],!h(b=arguments[j-=1]))throw new TypeError(w("00h2b",b))}if((j-=1)>=0&&r(arguments[j])?(c=arguments[j],j-=1):c=g,null===(y=d(c)))throw new TypeError(w("00h2Y",c));if("generic"===c){if(E=arguments[0],0===j){if(e(E)?u=E:i(E)&&(u=E.length),void 0!==u)return m(u,b,f);if(n(E))throw new Error(w("00h04"));if(o(E)){if(!1===v)throw new TypeError(w("00h2Z",E));if(!h(E[p]))throw new TypeError(w("00h2a",E));if(E=E[p](),!h(E.next))throw new TypeError(w("00h2a",E));return function(r,e,t){var s,i;for(s=[],i=-1;!r.next().done;)i+=1,s.push(e.call(t,i));return s}(E,b,f)}throw new TypeError(w("00h2a",E))}if(n(E))throw new Error(w("00h04"));throw new TypeError(w("00h2a",E))}if(0===j)if(i(E=arguments[0]))x=new y(E.length);else if(n(E))x=new y(E);else if(e(E))x=new y(E);else{if(!o(E))throw new TypeError(w("00h2a",E));if(!1===v)throw new TypeError(w("00h2Z",E));if(!h(E[p]))throw new TypeError(w("00h2a",E));if(E=E[p](),!h(E.next))throw new TypeError(w("00h2a",E));x=new y(a(E))}else x=1===j?new y(arguments[0],arguments[1]):new y(arguments[0],arguments[1],arguments[2]);return x.length>0&&(t(c)||s(c)?function(r,e,t){var s;for(s=0;s\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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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( format('00h05') );\n\t\t}\n\t\tctor = ctors( dtype );\n\t\tif ( ctor === null ) {\n\t\t\tthrow new TypeError( format( '00h2Y', 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( format('00h05') );\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( format('00h05') );\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( '00h2b', clbk ) );\n\t\t}\n\t}\n\t// If we 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( format('00h05') );\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( '00h2Y', 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( format('00h04') );\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( '00h2Z', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00h2a', 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( '00h2a', 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( '00h2a', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format('00h04') );\n\t\t}\n\t\tthrow new TypeError( format( '00h2a', 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( '00h2Z', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00h2a', 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( '00h2a', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00h2a', 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\nexport default filledarrayBy;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","DEFAULT_DTYPE","defaults","get","filledarrayBy","thisArg","nargs","dtype","clbk","ctor","arr","len","arg","arguments","length","ctors","isString","TypeError","format","isFunction","isNonNegativeInteger","isCollection","filledArray","isArrayBuffer","Error","isObject","ITERATOR_SYMBOL","next","it","i","done","push","call","filledArrayIterator","iterLength","isComplexDataType","isBooleanDataType","set","filledAccessors","gfillBy","value","aidx"],"mappings":";;sjDA0CA,IAAIA,EAAsBC,IACtBC,EAAgBC,EAASC,IAAK,kBA2MlC,SAASC,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAKJ,GAAe,KAHfN,EAAQO,UAAUC,QAKjB,OAAO,IADPL,EAAOM,EAAOd,IACG,GAIlB,GAAKe,EADLT,EAAQM,UAAW,IACM,CAExB,GAAKP,EAAQ,EACZ,MAAM,IAAIW,UAAWC,EAAO,UAG7B,GAAc,QADdT,EAAOM,EAAOR,IAEb,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,OAAO,IAAIE,EAAM,EACjB,CAED,GAAKH,EAAQ,EACZ,MAAM,IAAIW,UAAWC,EAAO,UAM7B,GAAKC,EAAYN,UAHjBP,GAAS,IAKR,GAAKa,EAAYN,UAAWP,EAAM,KAMjC,GALAD,EAAUQ,UAAWP,GAErBE,EAAOK,UADPP,GAAS,GAIM,IAAVA,EACJ,MAAM,IAAIW,UAAWC,EAAO,eAI7BV,EAAOK,UAAWP,OAIf,MAAKA,GAAS,GAUlB,MAAM,IAAIW,UAAWC,EAAO,UAN5B,GAHAb,EAAUQ,UAAWP,IAGfa,EADNX,EAAOK,UADPP,GAAS,IAGR,MAAM,IAAIW,UAAWC,EAAQ,QAASV,GAMvC,CAUD,IARAF,GAAS,IACK,GAAKU,EAAUH,UAAWP,KACvCC,EAAQM,UAAWP,GACnBA,GAAS,GAETC,EAAQN,EAGK,QADdQ,EAAOM,EAAOR,IAEb,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,GAAe,YAAVA,EAAsB,CAE1B,GADAK,EAAMC,UAAW,GACF,IAAVP,EAAc,CAMlB,GALKc,EAAsBR,GAC1BD,EAAMC,EACKS,EAAcT,KACzBD,EAAMC,EAAIE,aAEE,IAARH,EACJ,OAAOW,EAAaX,EAAKH,EAAMH,GAEhC,GAAKkB,EAAeX,GACnB,MAAM,IAAIY,MAAON,EAAO,UAEzB,GAAKO,EAAUb,GAAQ,CACtB,IAA6B,IAAxBb,EACJ,MAAM,IAAIkB,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAYP,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLP,EAAYP,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvC,OAvSJ,SAA8BgB,EAAIpB,EAAMH,GACvC,IAAIK,EACAmB,EAKJ,IAFAnB,EAAM,GACNmB,GAAK,GAEAD,EAAGD,OACAG,MAGPD,GAAK,EACLnB,EAAIqB,KAAMvB,EAAKwB,KAAM3B,EAASwB,IAE/B,OAAOnB,CACR,CAuRWuB,CAAqBrB,EAAKJ,EAAMH,EACvC,CACD,MAAM,IAAIY,UAAWC,EAAQ,QAASN,GACzC,CAAS,GAAKW,EAAeX,GAC1B,MAAM,IAAIY,MAAON,EAAO,UAEzB,MAAM,IAAID,UAAWC,EAAQ,QAASN,GACtC,CACD,GAAe,IAAVN,EAEJ,GAAKe,EADLT,EAAMC,UAAW,IAEhBH,EAAM,IAAID,EAAMG,EAAIE,aACd,GAAKS,EAAeX,GAC1BF,EAAM,IAAID,EAAMG,QACV,GAAKQ,EAAsBR,GACjCF,EAAM,IAAID,EAAMG,OACV,KAAKa,EAAUb,GAarB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAZtC,IAA6B,IAAxBb,EACJ,MAAM,IAAIkB,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAYP,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLP,EAAYP,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvCF,EAAM,IAAID,EAAMyB,EAAYtB,GAG5B,MAEDF,EADqB,IAAVJ,EACL,IAAIG,EAAMI,UAAU,GAAIA,UAAU,IAElC,IAAIJ,EAAMI,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKH,EAAII,OAAS,IACZqB,EAAmB5B,IAAW6B,EAAmB7B,GAjTxD,SAA0BG,EAAKF,EAAMH,GACpC,IAAIwB,EACJ,IAAMA,EAAI,EAAGA,EAAInB,EAAII,OAAQe,IAC5BnB,EAAI2B,IAAK7B,EAAKwB,KAAM3B,EAASwB,GAAKA,EAGpC,CA4SGS,CAAiB5B,EAAKF,EAAMH,GAE5BkC,EAAS7B,EAAII,OAAQJ,EAAK,GAe5B,SAAmB8B,EAAOC,GACzB,OAAOjC,EAAKwB,KAAM3B,EAASoC,EAC3B,KAdM/B,CAeR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d115cf0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,192 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -/** -* Create a filled array according to a provided callback function. -* -* @module @stdlib/array-filled-by -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* var arr = filledarrayBy(); -* // returns -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'generic', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( [ 0.5, 0.5 ], clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1; -* } -* -* var arr = filledarrayBy( [ 5, -3 ], 'int32', clbk ); -* // returns [ 1, 1 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk1() { -* return 10; -* } -* -* function clbk2() { -* return 1.0; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, clbk2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk1() { -* return 1.0; -* } -* -* function clbk2() { -* return 2; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, 'uint32', clbk2 ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 'float32', clbk ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, clbk ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, 'int32', clbk ); -* // returns [ 1, 1 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 32b6545..0000000 --- a/lib/main.js +++ /dev/null @@ -1,416 +0,0 @@ -/** -* @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 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' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var ctors = require( '@stdlib/array-ctors' ); -var gfillBy = require( '@stdlib/blas-ext-base-gfill-by' ); -var filledArray = require( '@stdlib/array-base-filled-by' ); -var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var iterLength = require( '@stdlib/iter-length' ); -var defaults = require( '@stdlib/array-defaults' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport(); -var DEFAULT_DTYPE = defaults.get( 'dtypes.default' ); - - -// FUNCTIONS // - -/** -* Creates a filled "generic" array from an iterator. -* -* @private -* @param {Iterable} it - iterator -* @param {Callback} clbk - callback function -* @param {*} thisArg - callback function execution context -* @returns {Array} filled array -*/ -function filledArrayIterator( it, clbk, thisArg ) { - var arr; - var i; - var v; - - arr = []; - i = -1; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - i += 1; - arr.push( clbk.call( thisArg, i ) ); - } - return arr; -} - -/** -* Fills an array exposing accessors for getting and setting array elements. -* -* @private -* @param {Collection} arr - input array -* @param {Callback} clbk - callback function -* @param {*} thisArg - callback function execution context -* @returns {Collection} input array -*/ -function filledAccessors( arr, clbk, thisArg ) { - var i; - for ( i = 0; i < arr.length; i++ ) { - arr.set( clbk.call( thisArg, i ), i ); - } - return arr; -} - - -// MAIN // - -/** -* Creates a filled array according to a provided callback function. -* -* @param {(NonNegativeInteger|TypedArray|ArrayLikeObject|ArrayBuffer|Iterable)} [arg] - a length, typed array, array-like object, buffer, or iterable -* @param {NonNegativeInteger} [byteOffset=0] - byte offset -* @param {NonNegativeInteger} [length] - view length -* @param {string} [dtype="float64"] - data type -* @param {Callback} [clbk] - callback to invoke -* @param {*} [thisArg] - callback execution context -* @throws {TypeError} must provide a recognized data type -* @throws {TypeError} must provide a length, typed array, array-like object, buffer, or iterable -* @throws {TypeError} callback argument must be a function. -* @throws {Error} creating a generic array from an `ArrayBuffer` is not supported -* @returns {(TypedArray|Array)} array or typed array -* -* @example -* var arr = filledarrayBy(); -* // returns -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'generic', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( [ 0.5, 0.5 ], clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1; -* } -* -* var arr = filledarrayBy( [ 5, -3 ], 'int32', clbk ); -* // returns [ 1, 1 ] -* -* @example -* function clbk1() { -* return 10; -* } -* -* function clbk2() { -* return 1.0; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, clbk2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk1() { -* return 1.0; -* } -* -* function clbk2() { -* return 2; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, 'uint32', clbk2 ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 'float32', clbk ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, clbk ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, 'int32', clbk ); -* // returns [ 1, 1 ] -*/ -function filledarrayBy() { - var thisArg; - var nargs; - var dtype; - var clbk; - var ctor; - var arr; - var len; - var arg; - - nargs = arguments.length; - - // If we weren't provided any arguments, return an empty array... - if ( nargs === 0 ) { - ctor = ctors( DEFAULT_DTYPE ); - return new ctor( 0 ); - } - // Check if we were provided a dtype as the first argument... - dtype = arguments[ 0 ]; - if ( isString( dtype ) ) { - // Invoking this function with arguments `f( dtype, clbk[, thisArg] )` is not allowed (otherwise, we'd need to also allow `f( clbk[, thisArg] )`)... - if ( nargs > 1 ) { - throw new TypeError( format('00h05') ); - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '00h2Y', dtype ) ); - } - // Return an empty array having the specified dtype: - return new ctor( 0 ); - } - // For all other supported invocations, we need at least two arguments... - if ( nargs < 2 ) { - throw new TypeError( format('00h05') ); - } - // At this point, we need to do some argument juggling... - nargs -= 1; // henceforth, the number of available arguments is `nargs+1` - - // Determine whether the last argument is a callback or "this" context... - if ( isFunction( arguments[ nargs ] ) ) { - // 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... - if ( isFunction( arguments[ nargs-1 ] ) ) { - thisArg = arguments[ nargs ]; - nargs -= 1; - clbk = arguments[ nargs ]; - - // Check if we were provided only a callback and a "this" context.. - if ( nargs === 0 ) { - throw new TypeError( format('00h05') ); - } - } else { - // "this" context is left undefined... - clbk = arguments[ nargs ]; - } - } - // 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... - else if ( nargs >= 2 ) { - thisArg = arguments[ nargs ]; - nargs -= 1; - clbk = arguments[ nargs ]; - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '00h2b', clbk ) ); - } - } - // If we were only provided 2 arguments and the last argument was not a function, we've been provided an insufficient number of arguments... - else { - throw new TypeError( format('00h05') ); - } - // Now that we've processed the callback arguments, let's continue working backward to see if we've been provided a `dtype` argument... - nargs -= 1; - if ( nargs >= 0 && isString( arguments[ nargs ] ) ) { - dtype = arguments[ nargs ]; - nargs -= 1; - } else { - dtype = DEFAULT_DTYPE; - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '00h2Y', dtype ) ); - } - // At this point, we've resolved the output array data type, and now we can actually create the output array... - if ( dtype === 'generic' ) { - arg = arguments[ 0 ]; - if ( nargs === 0 ) { - if ( isNonNegativeInteger( arg ) ) { - len = arg; - } else if ( isCollection( arg ) ) { - len = arg.length; - } - if ( len !== void 0 ) { - return filledArray( len, clbk, thisArg ); - } - if ( isArrayBuffer( arg ) ) { - throw new Error( format('00h04') ); - } - if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( '00h2Z', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00h2a', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00h2a', arg ) ); - } - return filledArrayIterator( arg, clbk, thisArg ); - } - throw new TypeError( format( '00h2a', arg ) ); - } else if ( isArrayBuffer( arg ) ) { - throw new Error( format('00h04') ); - } - throw new TypeError( format( '00h2a', arg ) ); - } - if ( nargs === 0 ) { // length || array-like || ArrayBuffer || iterable - arg = arguments[ 0 ]; - if ( isCollection( arg ) ) { - arr = new ctor( arg.length ); - } else if ( isArrayBuffer( arg ) ) { - arr = new ctor( arg ); - } else if ( isNonNegativeInteger( arg ) ) { - arr = new ctor( arg ); - } else if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( '00h2Z', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00h2a', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00h2a', arg ) ); - } - arr = new ctor( iterLength( arg ) ); - } else { - throw new TypeError( format( '00h2a', arg ) ); - } - } else if ( nargs === 1 ) { - arr = new ctor( arguments[0], arguments[1] ); // (ArrayBuffer, byteOffset) - } else { - arr = new ctor( arguments[0], arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset, length) - } - if ( arr.length > 0 ) { - if ( isComplexDataType( dtype ) || isBooleanDataType( dtype ) ) { - filledAccessors( arr, clbk, thisArg ); - } else { - gfillBy( arr.length, arr, 1, callback ); - } - } - return arr; - - /** - * Callback which wraps a provided callback and is invoked for each array element. - * - * @private - * @param {*} value - element value - * @param {NonNegativeInteger} aidx - array index - * @param {NonNegativeInteger} sidx - strided index - * @param {Collection} array - input array/collection - * @returns {*} callback return value - */ - function callback( value, aidx ) { - return clbk.call( thisArg, aidx ); - } -} - - -// EXPORTS // - -module.exports = filledarrayBy; diff --git a/package.json b/package.json index b5ac3ab..b16be36 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Create a filled array according to a provided callback function.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,75 +13,6 @@ "bugs": { "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.2", - "@stdlib/array-ctors": "^0.3.0", - "@stdlib/array-defaults": "^0.3.0", - "@stdlib/assert-has-iterator-symbol-support": "^0.2.2", - "@stdlib/assert-is-arraybuffer": "^0.2.2", - "@stdlib/assert-is-collection": "^0.2.2", - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer": "^0.2.2", - "@stdlib/assert-is-object": "^0.2.2", - "@stdlib/assert-is-string": "^0.2.2", - "@stdlib/blas-ext-base-gfill-by": "^0.2.1", - "@stdlib/iter-length": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/symbol-iterator": "^0.2.2", - "@stdlib/types": "^0.4.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-bool": "^0.1.0", - "@stdlib/array-buffer": "^0.2.2", - "@stdlib/array-complex128": "^0.3.0", - "@stdlib/array-complex64": "^0.3.0", - "@stdlib/array-float32": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/array-int16": "^0.2.2", - "@stdlib/array-int32": "^0.2.2", - "@stdlib/array-int8": "^0.2.2", - "@stdlib/array-typed-real-dtypes": "^0.2.2", - "@stdlib/array-uint16": "^0.2.2", - "@stdlib/array-uint32": "^0.2.2", - "@stdlib/array-uint8": "^0.2.2", - "@stdlib/array-uint8c": "^0.2.2", - "@stdlib/assert-instance-of": "^0.2.2", - "@stdlib/assert-is-array": "^0.2.2", - "@stdlib/assert-is-typed-array": "^0.2.2", - "@stdlib/assert-is-typed-array-like": "^0.2.2", - "@stdlib/complex-float32-ctor": "^0.0.2", - "@stdlib/complex-float64-ctor": "^0.0.3", - "@stdlib/iter-constant": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/random-base-discrete-uniform": "^0.2.1", - "@stdlib/strided-base-reinterpret-boolean": "^0.0.2", - "@stdlib/strided-base-reinterpret-complex128": "^0.2.2", - "@stdlib/strided-base-reinterpret-complex64": "^0.2.1", - "@stdlib/utils-constant-function": "^0.2.2", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..93dc046 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index ca0cf25..0000000 --- a/test/test.js +++ /dev/null @@ -1,4397 +0,0 @@ -/** -* @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. -*/ - -/* eslint-disable max-len */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -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' ); -var iterConstant = require( '@stdlib/iter-constant' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var filledarrayBy = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': !hasIteratorSymbolSupport() -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof filledarrayBy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if only provided callback arguments', function test( t ) { - t.throws( clbk1, TypeError, 'throws an error' ); - t.throws( clbk2, TypeError, 'throws an error' ); - t.throws( clbk3, TypeError, 'throws an error' ); - t.end(); - - function clbk1() { - filledarrayBy( constantFunction( 1.0 ) ); - } - - function clbk2() { - filledarrayBy( constantFunction( 1.0 ), {} ); - } - - function clbk3() { - filledarrayBy( constantFunction( 1.0 ), constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (only argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (typed array; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (array-like object)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (array-like object; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 8 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 8 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, 1, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (iterator)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( iterConstant( 1.0 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (iterator; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( iterConstant( 1.0 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if only provided data type and callback arguments', function test( t ) { - t.throws( clbk1, TypeError, 'throws an error' ); - t.throws( clbk2, TypeError, 'throws an error' ); - t.throws( clbk3, TypeError, 'throws an error' ); - t.end(); - - function clbk1() { - filledarrayBy( 'float64', constantFunction( 1.0 ) ); - } - - function clbk2() { - filledarrayBy( 'float64', constantFunction( 1.0 ), {} ); - } - - function clbk3() { - filledarrayBy( 'float64', constantFunction( 1.0 ), constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (array-like object)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (array-like object; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, 1, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, 1, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (no iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (no iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (non-function iterator symbol property)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (non-function iterator symbol property; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (`next` property is not a function)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ) ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (`next` property is not a function; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ), {} ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (no iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (no iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (non-function iterator symbol property)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (non-function iterator symbol property; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (`next` property is not a function)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ) ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (`next` property is not a function; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ), {} ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 1, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 1, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function returns a filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - arr = filledarrayBy(); - - t.strictEqual( instanceOf( arr, Float64Array ), 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=float64)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - arr = filledarrayBy( 'float64' ); - - t.strictEqual( instanceOf( arr, Float64Array ), 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=float32)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( 0 ); - arr = filledarrayBy( 'float32' ); - - t.strictEqual( instanceOf( arr, Float32Array ), 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=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; - - expected = new Complex128Array( 0 ); - arr = filledarrayBy( 'complex128' ); - - t.strictEqual( instanceOf( arr, Complex128Array ), 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=complex64)', function test( t ) { - var expected; - var arr; - - expected = new Complex64Array( 0 ); - arr = filledarrayBy( 'complex64' ); - - t.strictEqual( instanceOf( arr, Complex64Array ), 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=int32)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( 0 ); - arr = filledarrayBy( 'int32' ); - - t.strictEqual( instanceOf( arr, Int32Array ), 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=uint32)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( 0 ); - arr = filledarrayBy( 'uint32' ); - - t.strictEqual( instanceOf( arr, Uint32Array ), 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=int16)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( 0 ); - arr = filledarrayBy( 'int16' ); - - t.strictEqual( instanceOf( arr, Int16Array ), 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=uint16)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( 0 ); - arr = filledarrayBy( 'uint16' ); - - t.strictEqual( instanceOf( arr, Uint16Array ), 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=int8)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( 0 ); - arr = filledarrayBy( 'int8' ); - - t.strictEqual( instanceOf( arr, Int8Array ), 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=uint8)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( 0 ); - arr = filledarrayBy( 'uint8' ); - - t.strictEqual( instanceOf( arr, Uint8Array ), 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=uint8c)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( 0 ); - arr = filledarrayBy( 'uint8c' ); - - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), 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=generic)', function test( t ) { - var expected; - var arr; - - expected = []; - arr = filledarrayBy( 'generic' ); - - t.strictEqual( instanceOf( arr, Array ), 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 (default, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, length=0)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array(); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 0, clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, clbk, ctx ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (default, length; thisArg=function)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, clbk, context ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this(); // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } - - function context() { - ctx.count += 1; - } -}); - -tape( 'the function returns a filled array (dtype=float64, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, 'float64', clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, length; thisArg=function)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, 'float64', clbk, context ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this(); // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } - - function context() { - ctx.count += 1; - } -}); - -tape( 'the function returns a filled array (dtype=float32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, 'float32', clbk ); - - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - 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; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = filledarrayBy( 5, 'complex128', clbk ); - - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = filledarrayBy( 5, 'complex64', clbk ); - - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int32Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int32', clbk ); - - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint32Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint32', clbk ); - - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int16Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int16', clbk ); - - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint16', clbk ); - - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int8Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int8', clbk ); - - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint8', clbk ); - - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint8c', clbk ); - - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = [ 1, 1, 1, 1, 1 ]; - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'generic', clbk ); - - t.strictEqual( instanceOf( arr, Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - 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; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = [ 1.0, 2.0 ]; - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = [ 1.0, 2.0 ]; - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int32', clbk ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, typed array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, typed array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - 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; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = new Float64Array( [ 1.0, 2.0 ] ); - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = new Float64Array( [ 1.0, 2.0 ] ); - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (default, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - 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; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer, byteoffset; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer, byteoffset; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - 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; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 48 ); - out = filledarrayBy( buf, 16, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 24 ); - out = filledarrayBy( buf, 8, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int32', clbk ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint8c', clbk ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - 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; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 64 ); - out = filledarrayBy( buf, 16, 2, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset, length)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 1, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 1, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled array (default, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, iterator; thisArg)', opts, function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - ctx = { - 'count': 0 - }; - indices = []; - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, iterator; thisArg)', opts, function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - ctx = { - 'count': 0 - }; - indices = []; - out = filledarrayBy( arr, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - 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; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = iterConstant( new Complex128( 3.0, 3.0 ), { - 'iter': 2 - }); - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = iterConstant( new Complex64( 3.0, 3.0 ), { - 'iter': 2 - }); - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); From 631a3cde146d7ace607464bb82e41424a777a8bd Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 31 Jan 2026 03:38:30 +0000 Subject: [PATCH 087/117] Transform error messages --- lib/main.js | 38 +++++++++++++++++++------------------- package.json | 2 +- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/lib/main.js b/lib/main.js index d2128f5..32b6545 100644 --- a/lib/main.js +++ b/lib/main.js @@ -35,7 +35,7 @@ var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-supp var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); var iterLength = require( '@stdlib/iter-length' ); var defaults = require( '@stdlib/array-defaults' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -266,18 +266,18 @@ function filledarrayBy() { if ( isString( dtype ) ) { // Invoking this function with arguments `f( dtype, clbk[, thisArg] )` is not allowed (otherwise, we'd need to also allow `f( clbk[, thisArg] )`)... if ( nargs > 1 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format('00h05') ); } ctor = ctors( dtype ); if ( ctor === null ) { - throw new TypeError( format( 'invalid argument. Must provide a recognized data type. Value: `%s`.', dtype ) ); + throw new TypeError( format( '00h2Y', dtype ) ); } // Return an empty array having the specified dtype: return new ctor( 0 ); } // For all other supported invocations, we need at least two arguments... if ( nargs < 2 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format('00h05') ); } // At this point, we need to do some argument juggling... nargs -= 1; // henceforth, the number of available arguments is `nargs+1` @@ -292,7 +292,7 @@ function filledarrayBy() { // Check if we were provided only a callback and a "this" context.. if ( nargs === 0 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format('00h05') ); } } else { // "this" context is left undefined... @@ -305,12 +305,12 @@ function filledarrayBy() { nargs -= 1; clbk = arguments[ nargs ]; if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '00h2b', clbk ) ); } } // If we were only provided 2 arguments and the last argument was not a function, we've been provided an insufficient number of arguments... else { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format('00h05') ); } // Now that we've processed the callback arguments, let's continue working backward to see if we've been provided a `dtype` argument... nargs -= 1; @@ -322,7 +322,7 @@ function filledarrayBy() { } ctor = ctors( dtype ); if ( ctor === null ) { - throw new TypeError( format( 'invalid argument. Must provide a recognized data type. Value: `%s`.', dtype ) ); + throw new TypeError( format( '00h2Y', dtype ) ); } // At this point, we've resolved the output array data type, and now we can actually create the output array... if ( dtype === 'generic' ) { @@ -337,26 +337,26 @@ function filledarrayBy() { return filledArray( len, clbk, thisArg ); } if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format('00h04') ); } if ( isObject( arg ) ) { if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2Z', arg ) ); } if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } arg = arg[ ITERATOR_SYMBOL ](); if ( !isFunction( arg.next ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } return filledArrayIterator( arg, clbk, thisArg ); } - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } else if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format('00h04') ); } - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } if ( nargs === 0 ) { // length || array-like || ArrayBuffer || iterable arg = arguments[ 0 ]; @@ -368,18 +368,18 @@ function filledarrayBy() { arr = new ctor( arg ); } else if ( isObject( arg ) ) { if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2Z', arg ) ); } if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } arg = arg[ ITERATOR_SYMBOL ](); if ( !isFunction( arg.next ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } arr = new ctor( iterLength( arg ) ); } else { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } } else if ( nargs === 1 ) { arr = new ctor( arguments[0], arguments[1] ); // (ArrayBuffer, byteOffset) diff --git a/package.json b/package.json index fad739d..7c90e3b 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "@stdlib/assert-is-string": "^0.2.2", "@stdlib/blas-ext-base-gfill-by": "^0.2.2", "@stdlib/iter-length": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/symbol-iterator": "^0.2.2", "@stdlib/types": "^0.4.3", "@stdlib/error-tools-fmtprodmsg": "^0.2.2" From b0fb8d707a5caed67c17247ba0b59c46eb63c3cd Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 31 Jan 2026 05:16:45 +0000 Subject: [PATCH 088/117] Remove files --- index.d.ts | 322 ---- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5169 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index cb63cd1..0000000 --- a/index.d.ts +++ /dev/null @@ -1,322 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, RealOrComplexTypedArray, BooleanArray, DataType } from '@stdlib/types/array'; -import { IterableIterator } from '@stdlib/types/iter'; - -/** -* Array or typed array. -*/ -type ArrayOrTypedArray = Array | RealOrComplexTypedArray | BooleanArray; - -/** -* Nullary callback function. -* -* @returns fill value -*/ -type Nullary = () => any; - -/** -* Unary callback function. -* -* @param i - current array index -* @returns fill value -*/ -type Unary = ( i: number ) => any; - -/** -* Callback function. -* -* @param i - current array index -* @returns fill value -*/ -type Callback = Nullary | Unary; - -/** -* Creates a filled array according to a provided callback function and having a specified data type. -* -* @param dtype - data type -* @returns filled array -* -* @example -* var arr = filledarrayBy(); -* // returns -* -* @example -* var arr = filledarrayBy( 'float32' ); -* // returns -*/ -declare function filledarrayBy( dtype?: DataType ): ArrayOrTypedArray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Creates a filled array according to a provided callback function and having a specified `length`. -* -* @param length - array length -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* -* var arr = filledarrayBy( 5, constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( length: number, clbk: Callback, thisArg?: any ): ArrayOrTypedArray; - -/** -* Creates a filled array according to a provided callback function and having a specified `length`. -* -* @param length - array length -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* -* var arr = filledarrayBy( 5, 'float64', constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( length: number, dtype: DataType, clbk: Callback, thisArg?: any ): ArrayOrTypedArray; - -/** -* Creates a filled array from another `array` according to a provided callback function. -* -* @param array - typed array or array-like object -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* -* 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; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Creates a filled array from another `array` according to a provided callback function. -* -* @param array - typed array or array-like object -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* -* 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; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Creates a filled array from an iterable according to a callback function. -* -* @param iterable - iterable -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var iterConstant = require( '@stdlib/iter-constant' ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarrayBy( it, constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( iterable: IterableIterator, clbk: Callback, thisArg?: any ): ArrayOrTypedArray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Creates a filled array from an iterable according to a callback function. -* -* @param iterable - iterable -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var iterConstant = require( '@stdlib/iter-constant' ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarrayBy( it, 'float64', constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( iterable: IterableIterator, dtype: DataType, clbk: 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. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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 | BooleanArray; - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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 | BooleanArray; - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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 | BooleanArray; - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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 | BooleanArray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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 | BooleanArray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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 | BooleanArray; // eslint-disable-line @typescript-eslint/unified-signatures - - -// EXPORTS // - -export = filledarrayBy; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 44a4dbe..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@v0.0.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-ctors@v0.3.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill-by@v0.2.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled-by@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@v0.2.2-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.3.0-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";var v=f(),g=j.get("dtypes.default");function c(){var f,j,c,b,y,x,u,E;if(0===(j=arguments.length))return new(y=d(g))(0);if(r(c=arguments[0])){if(j>1)throw new TypeError(w("00h05"));if(null===(y=d(c)))throw new TypeError(w("00h2Y",c));return new y(0)}if(j<2)throw new TypeError(w("00h05"));if(h(arguments[j-=1]))if(h(arguments[j-1])){if(f=arguments[j],b=arguments[j-=1],0===j)throw new TypeError(w("00h05"))}else b=arguments[j];else{if(!(j>=2))throw new TypeError(w("00h05"));if(f=arguments[j],!h(b=arguments[j-=1]))throw new TypeError(w("00h2b",b))}if((j-=1)>=0&&r(arguments[j])?(c=arguments[j],j-=1):c=g,null===(y=d(c)))throw new TypeError(w("00h2Y",c));if("generic"===c){if(E=arguments[0],0===j){if(e(E)?u=E:i(E)&&(u=E.length),void 0!==u)return m(u,b,f);if(n(E))throw new Error(w("00h04"));if(o(E)){if(!1===v)throw new TypeError(w("00h2Z",E));if(!h(E[p]))throw new TypeError(w("00h2a",E));if(E=E[p](),!h(E.next))throw new TypeError(w("00h2a",E));return function(r,e,t){var s,i;for(s=[],i=-1;!r.next().done;)i+=1,s.push(e.call(t,i));return s}(E,b,f)}throw new TypeError(w("00h2a",E))}if(n(E))throw new Error(w("00h04"));throw new TypeError(w("00h2a",E))}if(0===j)if(i(E=arguments[0]))x=new y(E.length);else if(n(E))x=new y(E);else if(e(E))x=new y(E);else{if(!o(E))throw new TypeError(w("00h2a",E));if(!1===v)throw new TypeError(w("00h2Z",E));if(!h(E[p]))throw new TypeError(w("00h2a",E));if(E=E[p](),!h(E.next))throw new TypeError(w("00h2a",E));x=new y(a(E))}else x=1===j?new y(arguments[0],arguments[1]):new y(arguments[0],arguments[1],arguments[2]);return x.length>0&&(t(c)||s(c)?function(r,e,t){var s;for(s=0;s\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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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( format('00h05') );\n\t\t}\n\t\tctor = ctors( dtype );\n\t\tif ( ctor === null ) {\n\t\t\tthrow new TypeError( format( '00h2Y', 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( format('00h05') );\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( format('00h05') );\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( '00h2b', clbk ) );\n\t\t}\n\t}\n\t// If we 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( format('00h05') );\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( '00h2Y', 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( format('00h04') );\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( '00h2Z', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00h2a', 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( '00h2a', 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( '00h2a', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format('00h04') );\n\t\t}\n\t\tthrow new TypeError( format( '00h2a', 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( '00h2Z', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00h2a', 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( '00h2a', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00h2a', 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\nexport default filledarrayBy;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","DEFAULT_DTYPE","defaults","get","filledarrayBy","thisArg","nargs","dtype","clbk","ctor","arr","len","arg","arguments","length","ctors","isString","TypeError","format","isFunction","isNonNegativeInteger","isCollection","filledArray","isArrayBuffer","Error","isObject","ITERATOR_SYMBOL","next","it","i","done","push","call","filledArrayIterator","iterLength","isComplexDataType","isBooleanDataType","set","filledAccessors","gfillBy","value","aidx"],"mappings":";;sjDA0CA,IAAIA,EAAsBC,IACtBC,EAAgBC,EAASC,IAAK,kBA2MlC,SAASC,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAKJ,GAAe,KAHfN,EAAQO,UAAUC,QAKjB,OAAO,IADPL,EAAOM,EAAOd,IACG,GAIlB,GAAKe,EADLT,EAAQM,UAAW,IACM,CAExB,GAAKP,EAAQ,EACZ,MAAM,IAAIW,UAAWC,EAAO,UAG7B,GAAc,QADdT,EAAOM,EAAOR,IAEb,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,OAAO,IAAIE,EAAM,EACjB,CAED,GAAKH,EAAQ,EACZ,MAAM,IAAIW,UAAWC,EAAO,UAM7B,GAAKC,EAAYN,UAHjBP,GAAS,IAKR,GAAKa,EAAYN,UAAWP,EAAM,KAMjC,GALAD,EAAUQ,UAAWP,GAErBE,EAAOK,UADPP,GAAS,GAIM,IAAVA,EACJ,MAAM,IAAIW,UAAWC,EAAO,eAI7BV,EAAOK,UAAWP,OAIf,MAAKA,GAAS,GAUlB,MAAM,IAAIW,UAAWC,EAAO,UAN5B,GAHAb,EAAUQ,UAAWP,IAGfa,EADNX,EAAOK,UADPP,GAAS,IAGR,MAAM,IAAIW,UAAWC,EAAQ,QAASV,GAMvC,CAUD,IARAF,GAAS,IACK,GAAKU,EAAUH,UAAWP,KACvCC,EAAQM,UAAWP,GACnBA,GAAS,GAETC,EAAQN,EAGK,QADdQ,EAAOM,EAAOR,IAEb,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,GAAe,YAAVA,EAAsB,CAE1B,GADAK,EAAMC,UAAW,GACF,IAAVP,EAAc,CAMlB,GALKc,EAAsBR,GAC1BD,EAAMC,EACKS,EAAcT,KACzBD,EAAMC,EAAIE,aAEE,IAARH,EACJ,OAAOW,EAAaX,EAAKH,EAAMH,GAEhC,GAAKkB,EAAeX,GACnB,MAAM,IAAIY,MAAON,EAAO,UAEzB,GAAKO,EAAUb,GAAQ,CACtB,IAA6B,IAAxBb,EACJ,MAAM,IAAIkB,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAYP,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLP,EAAYP,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvC,OAvSJ,SAA8BgB,EAAIpB,EAAMH,GACvC,IAAIK,EACAmB,EAKJ,IAFAnB,EAAM,GACNmB,GAAK,GAEAD,EAAGD,OACAG,MAGPD,GAAK,EACLnB,EAAIqB,KAAMvB,EAAKwB,KAAM3B,EAASwB,IAE/B,OAAOnB,CACR,CAuRWuB,CAAqBrB,EAAKJ,EAAMH,EACvC,CACD,MAAM,IAAIY,UAAWC,EAAQ,QAASN,GACzC,CAAS,GAAKW,EAAeX,GAC1B,MAAM,IAAIY,MAAON,EAAO,UAEzB,MAAM,IAAID,UAAWC,EAAQ,QAASN,GACtC,CACD,GAAe,IAAVN,EAEJ,GAAKe,EADLT,EAAMC,UAAW,IAEhBH,EAAM,IAAID,EAAMG,EAAIE,aACd,GAAKS,EAAeX,GAC1BF,EAAM,IAAID,EAAMG,QACV,GAAKQ,EAAsBR,GACjCF,EAAM,IAAID,EAAMG,OACV,KAAKa,EAAUb,GAarB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAZtC,IAA6B,IAAxBb,EACJ,MAAM,IAAIkB,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAYP,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLP,EAAYP,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvCF,EAAM,IAAID,EAAMyB,EAAYtB,GAG5B,MAEDF,EADqB,IAAVJ,EACL,IAAIG,EAAMI,UAAU,GAAIA,UAAU,IAElC,IAAIJ,EAAMI,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKH,EAAII,OAAS,IACZqB,EAAmB5B,IAAW6B,EAAmB7B,GAjTxD,SAA0BG,EAAKF,EAAMH,GACpC,IAAIwB,EACJ,IAAMA,EAAI,EAAGA,EAAInB,EAAII,OAAQe,IAC5BnB,EAAI2B,IAAK7B,EAAKwB,KAAM3B,EAASwB,GAAKA,EAGpC,CA4SGS,CAAiB5B,EAAKF,EAAMH,GAE5BkC,EAAS7B,EAAII,OAAQJ,EAAK,GAe5B,SAAmB8B,EAAOC,GACzB,OAAOjC,EAAKwB,KAAM3B,EAASoC,EAC3B,KAdM/B,CAeR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 93dc046..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From f082678ace652202190def523d9a09d95a1259a4 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 31 Jan 2026 05:17:09 +0000 Subject: [PATCH 089/117] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 108 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 199 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 192 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 49 +- SECURITY.md | 5 - benchmark/benchmark.js | 341 -- benchmark/benchmark.length.bool.js | 97 - benchmark/benchmark.length.complex128.js | 98 - benchmark/benchmark.length.complex64.js | 98 - benchmark/benchmark.length.float32.js | 97 - benchmark/benchmark.length.float64.js | 97 - benchmark/benchmark.length.generic.js | 97 - benchmark/benchmark.length.int16.js | 97 - benchmark/benchmark.length.int32.js | 97 - benchmark/benchmark.length.int8.js | 97 - benchmark/benchmark.length.uint16.js | 97 - benchmark/benchmark.length.uint32.js | 97 - benchmark/benchmark.length.uint8.js | 97 - benchmark/benchmark.length.uint8c.js | 97 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 36 - dist/index.js.map | 7 - docs/repl.txt | 157 - docs/types/test.ts | 606 --- examples/index.js | 37 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 192 - lib/main.js | 416 -- package.json | 96 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 4397 ---------------- 56 files changed, 4870 insertions(+), 11253 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.length.bool.js delete mode 100644 benchmark/benchmark.length.complex128.js delete mode 100644 benchmark/benchmark.length.complex64.js delete mode 100644 benchmark/benchmark.length.float32.js delete mode 100644 benchmark/benchmark.length.float64.js delete mode 100644 benchmark/benchmark.length.generic.js delete mode 100644 benchmark/benchmark.length.int16.js delete mode 100644 benchmark/benchmark.length.int32.js delete mode 100644 benchmark/benchmark.length.int8.js delete mode 100644 benchmark/benchmark.length.uint16.js delete mode 100644 benchmark/benchmark.length.uint32.js delete mode 100644 benchmark/benchmark.length.uint8.js delete mode 100644 benchmark/benchmark.length.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 2d6aaee..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/contributing/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index f988046..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index b2c1f9c..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '42 6 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 83d50c4..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,821 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send notification to Zulip if job fails: - - name: 'Send notification to Zulip in case of failure' - # Pin action to full length commit SHA - uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 - if: failure() - with: - api-key: ${{ secrets.ZULIP_API_KEY }} - email: 'github-actions-bot@stdlib.zulipchat.com' - organization-url: 'https://stdlib.zulipchat.com' - to: 'workflows-standalone' - type: 'stream' - topic: ${{ github.event.repository.name }} - content: | - :cross_mark: **${{ github.workflow }}** workflow failed - - **Repository:** [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) - **Run:** [View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -278,7 +269,7 @@ for ( i = 0; i < dt.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -347,13 +338,13 @@ Copyright © 2016-2026. 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/dtypes]: https://github.com/stdlib-js/array-dtypes/tree/esm -[@stdlib/array/filled]: https://github.com/stdlib-js/array-filled +[@stdlib/array/filled]: https://github.com/stdlib-js/array-filled/tree/esm -[@stdlib/array/typed]: https://github.com/stdlib-js/array-typed +[@stdlib/array/typed]: https://github.com/stdlib-js/array-typed/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 17cfb5a..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,341 +0,0 @@ -/** -* @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 isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); -var isArray = require( '@stdlib/assert-is-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var Complex64 = require( '@stdlib/complex-float32-ctor' ); -var Complex128 = require( '@stdlib/complex-float64-ctor' ); -var pkg = require( './../package.json' ).name; -var filledarrayBy = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 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=float64', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'float64', 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=float32', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'float32', 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=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; - var i; - - clbk = constantFunction( new Complex128( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'complex128', 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=complex64', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( new Complex64( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'complex64', 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=int32', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int32', 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=uint32', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint32', 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=int16', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int16', 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=uint16', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint16', 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=int8', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int8', 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=uint8', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint8', 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=uint8c', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint8c', 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=generic', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'generic', clbk ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.length.bool.js b/benchmark/benchmark.length.bool.js deleted file mode 100644 index 3cdd152..0000000 --- a/benchmark/benchmark.length.bool.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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/benchmark/benchmark.length.complex128.js b/benchmark/benchmark.length.complex128.js deleted file mode 100644 index 122bc7c..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 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 Complex128 = require( '@stdlib/complex-float64-ctor' ); -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( new Complex128( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'complex128', 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=complex128,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.complex64.js b/benchmark/benchmark.length.complex64.js deleted file mode 100644 index e7a2d74..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 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 Complex64 = require( '@stdlib/complex-float32-ctor' ); -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( new Complex64( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'complex64', 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=complex64,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.float32.js b/benchmark/benchmark.length.float32.js deleted file mode 100644 index d2b2ba7..0000000 --- a/benchmark/benchmark.length.float32.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'float32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=float32,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.float64.js b/benchmark/benchmark.length.float64.js deleted file mode 100644 index 65064e3..0000000 --- a/benchmark/benchmark.length.float64.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'float64', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=float64,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.generic.js b/benchmark/benchmark.length.generic.js deleted file mode 100644 index eb87dfa..0000000 --- a/benchmark/benchmark.length.generic.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isArray = require( '@stdlib/assert-is-array' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'generic', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isArray( 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=generic,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int16.js b/benchmark/benchmark.length.int16.js deleted file mode 100644 index 914ff7c..0000000 --- a/benchmark/benchmark.length.int16.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int16', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=int16,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int32.js b/benchmark/benchmark.length.int32.js deleted file mode 100644 index cc0f678..0000000 --- a/benchmark/benchmark.length.int32.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=int32,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int8.js b/benchmark/benchmark.length.int8.js deleted file mode 100644 index 77553b0..0000000 --- a/benchmark/benchmark.length.int8.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int8', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=int8,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint16.js b/benchmark/benchmark.length.uint16.js deleted file mode 100644 index c68efdd..0000000 --- a/benchmark/benchmark.length.uint16.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint16', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint16,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint32.js b/benchmark/benchmark.length.uint32.js deleted file mode 100644 index 27c1742..0000000 --- a/benchmark/benchmark.length.uint32.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint32,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint8.js b/benchmark/benchmark.length.uint8.js deleted file mode 100644 index 2a26be4..0000000 --- a/benchmark/benchmark.length.uint8.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint8', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint8,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint8c.js b/benchmark/benchmark.length.uint8c.js deleted file mode 100644 index dd6e8c2..0000000 --- a/benchmark/benchmark.length.uint8c.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint8c', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint8c,len='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index c138144..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by" -%% click B href "https://github.com/stdlib-js/array-filled-by/tree/main" -%% click C href "https://github.com/stdlib-js/array-filled-by/tree/production" -%% click D href "https://github.com/stdlib-js/array-filled-by/tree/esm" -%% click E href "https://github.com/stdlib-js/array-filled-by/tree/deno" -%% click F href "https://github.com/stdlib-js/array-filled-by/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by -[production-url]: https://github.com/stdlib-js/array-filled-by/tree/production -[deno-url]: https://github.com/stdlib-js/array-filled-by/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-filled-by/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-filled-by/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-filled-by/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-filled-by/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-filled-by/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 188fc9b..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import filledarrayBy from '../docs/types/index'; -export = filledarrayBy; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 65ae3db..0000000 --- a/dist/index.js +++ /dev/null @@ -1,36 +0,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 deleted file mode 100644 index b348e92..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "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 we 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,YACjDC,EAAuB,QAAS,uCAAwC,EAAE,YAC1EC,EAAoB,QAAS,+DAAgE,EAC7FC,EAAoB,QAAS,gDAAiD,EAC9EC,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,EAAQ,UAAU,OAGbA,IAAU,EACd,OAAAE,EAAOrB,EAAOS,CAAc,EACrB,IAAIY,EAAM,CAAE,EAIpB,GADAD,EAAQ,UAAW,CAAE,EAChB5B,EAAU4B,CAAM,EAAI,CAExB,GAAKD,EAAQ,EACZ,MAAM,IAAI,UAAW,2FAA4F,EAGlH,GADAE,EAAOrB,EAAOoB,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWd,EAAQ,sEAAuEa,CAAM,CAAE,EAG7G,OAAO,IAAIC,EAAM,CAAE,CACpB,CAEA,GAAKF,EAAQ,EACZ,MAAM,IAAI,UAAW,2FAA4F,EAMlH,GAHAA,GAAS,EAGJpB,EAAY,UAAWoB,CAAM,CAAE,EAEnC,GAAKpB,EAAY,UAAWoB,EAAM,CAAE,CAAE,GAMrC,GALAN,EAAU,UAAWM,CAAM,EAC3BA,GAAS,EACTP,EAAO,UAAWO,CAAM,EAGnBA,IAAU,EACd,MAAM,IAAI,UAAW,2FAA4F,OAIlHP,EAAO,UAAWO,CAAM,UAIhBA,GAAS,GAIlB,GAHAN,EAAU,UAAWM,CAAM,EAC3BA,GAAS,EACTP,EAAO,UAAWO,CAAM,EACnB,CAACpB,EAAYa,CAAK,EACtB,MAAM,IAAI,UAAWL,EAAQ,uEAAwEK,CAAK,CAAE,MAK7G,OAAM,IAAI,UAAW,2FAA4F,EAWlH,GARAO,GAAS,EACJA,GAAS,GAAK3B,EAAU,UAAW2B,CAAM,CAAE,GAC/CC,EAAQ,UAAWD,CAAM,EACzBA,GAAS,GAETC,EAAQX,EAETY,EAAOrB,EAAOoB,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWd,EAAQ,sEAAuEa,CAAM,CAAE,EAG7G,GAAKA,IAAU,UAAY,CAE1B,GADAG,EAAM,UAAW,CAAE,EACdJ,IAAU,EAAI,CAMlB,GALK1B,EAAsB8B,CAAI,EAC9BD,EAAMC,EACK3B,EAAc2B,CAAI,IAC7BD,EAAMC,EAAI,QAEND,IAAQ,OACZ,OAAOpB,EAAaoB,EAAKV,EAAMC,CAAQ,EAExC,GAAKhB,EAAe0B,CAAI,EACvB,MAAM,IAAI,MAAO,mFAAoF,EAEtG,GAAKzB,EAAUyB,CAAI,EAAI,CACtB,GAAKf,IAAwB,GAC5B,MAAM,IAAI,UAAWD,EAAQ,sIAAuIgB,CAAI,CAAE,EAE3K,GAAK,CAACxB,EAAYwB,EAAKnB,CAAgB,CAAE,EACxC,MAAM,IAAI,UAAWG,EAAQ,wGAAyGgB,CAAI,CAAE,EAG7I,GADAA,EAAMA,EAAKnB,CAAgB,EAAE,EACxB,CAACL,EAAYwB,EAAI,IAAK,EAC1B,MAAM,IAAI,UAAWhB,EAAQ,wGAAyGgB,CAAI,CAAE,EAE7I,OAAOb,EAAqBa,EAAKX,EAAMC,CAAQ,CAChD,CACA,MAAM,IAAI,UAAWN,EAAQ,wGAAyGgB,CAAI,CAAE,CAC7I,SAAY1B,EAAe0B,CAAI,EAC9B,MAAM,IAAI,MAAO,mFAAoF,EAEtG,MAAM,IAAI,UAAWhB,EAAQ,wGAAyGgB,CAAI,CAAE,CAC7I,CACA,GAAKJ,IAAU,EAEd,GADAI,EAAM,UAAW,CAAE,EACd3B,EAAc2B,CAAI,EACtBT,EAAM,IAAIO,EAAME,EAAI,MAAO,UAChB1B,EAAe0B,CAAI,EAC9BT,EAAM,IAAIO,EAAME,CAAI,UACT9B,EAAsB8B,CAAI,EACrCT,EAAM,IAAIO,EAAME,CAAI,UACTzB,EAAUyB,CAAI,EAAI,CAC7B,GAAKf,IAAwB,GAC5B,MAAM,IAAI,UAAWD,EAAQ,sIAAuIgB,CAAI,CAAE,EAE3K,GAAK,CAACxB,EAAYwB,EAAKnB,CAAgB,CAAE,EACxC,MAAM,IAAI,UAAWG,EAAQ,wGAAyGgB,CAAI,CAAE,EAG7I,GADAA,EAAMA,EAAKnB,CAAgB,EAAE,EACxB,CAACL,EAAYwB,EAAI,IAAK,EAC1B,MAAM,IAAI,UAAWhB,EAAQ,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,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 deleted file mode 100644 index 06f3146..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,157 +0,0 @@ - -{{alias}}( [dtype] ) - Creates a filled array. - - Parameters - ---------- - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr = {{alias}}() - - > arr = {{alias}}( 'float32' ) - - - -{{alias}}( length[, dtype], clbk[, thisArg] ) - Returns a filled array according to a provided callback function and having - a specified length. - - Parameters - ---------- - length: integer - Array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > function clbk() { return 1.0; }; - > var arr = {{alias}}( 5, clbk ) - [ 1.0, 1.0, 1.0, 1.0, 1.0 ] - > arr = {{alias}}( 5, 'int32', clbk ) - [ 1, 1, 1, 1, 1 ] - - -{{alias}}( array[, dtype], clbk[, thisArg] ) - Creates a filled array from another array (or array-like object) according - to a provided callback function. - - Parameters - ---------- - array: ArrayLikeObject - Array from which to generate another array. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias}}( [ 0.5, 0.5, 0.5 ], {{alias:@stdlib/utils/constant-function}}( 2.0 ) ) - [ 2.0, 2.0, 2.0 ] - > var arr2 = {{alias}}( arr1, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( iterable[, dtype], clbk[, thisArg] ) - Creates a filled array from an iterable according to a provided callback - function. - - Parameters - ---------- - iterable: Iterable - Iterable from which to generate an array. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias:@stdlib/iter/constant}}( 3.0, {'iter': 3} ); - > var arr2 = {{alias}}( arr1, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( buffer[, byteOffset[, length]][, dtype], clbk[, thisArg] ) - Returns a filled typed array view of an ArrayBuffer according to a provided - callback function. - - The 'generic' array data type is *not* supported. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( buf, 0, 4, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0, 1.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index bb876ed..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,606 +0,0 @@ -/* -* @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. -*/ - -/// - -import { IterableIterator } from '@stdlib/types/iter'; -import filledarrayBy = require( './index' ); - - -/** -* Returns an iterator protocol-compliant object. -* -* @returns iterator protocol-compliant object -*/ -function iterator(): IterableIterator { - const obj: IterableIterator = { - [Symbol.iterator]: iterator, - 'next': next - }; - return obj; -} - -/** -* Implements the iterator protocol `next` method. -* -* @returns iterator protocol-compliant object -*/ -function next(): any { - return { - 'value': 1.0, - 'done': false - }; -} - -/** -* Callback function. -* -* @param i - current array index -* @returns return value -*/ -function clbk( i: number ): number { - return i; -} - - -// TESTS // - -// The function returns an array or typed array... -{ - filledarrayBy(); // $ExpectType ArrayOrTypedArray - filledarrayBy( 'float32' ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( 10, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( 10, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( 10, 'int32', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( 10, 'int32', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const x = new Float64Array( 10 ); - filledarrayBy( x, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( x, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( x, 'uint8', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( x, 'uint8', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const y = [ 2.0, 2.0, 2.0 ]; - filledarrayBy( y, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( y, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( y, 'float64', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( y, 'float64', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const it = iterator(); - filledarrayBy( it, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( it, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( it, 'uint8c', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( it, 'uint8c', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const buf = new ArrayBuffer( 32 ); - filledarrayBy( buf, clbk ); // $ExpectType RealOrComplexTypedArray | BooleanArray - filledarrayBy( buf, clbk, {} ); // $ExpectType RealOrComplexTypedArray | BooleanArray - - filledarrayBy( buf, 'uint32', clbk ); // $ExpectType RealOrComplexTypedArray | BooleanArray - filledarrayBy( buf, 'uint32', clbk, {} ); // $ExpectType RealOrComplexTypedArray | BooleanArray - - filledarrayBy( buf, 8, clbk ); // $ExpectType RealOrComplexTypedArray | BooleanArray - filledarrayBy( buf, 8, clbk, {} ); // $ExpectType RealOrComplexTypedArray | BooleanArray - - filledarrayBy( buf, 8, 'uint16', clbk ); // $ExpectType RealOrComplexTypedArray | BooleanArray - filledarrayBy( buf, 8, 'uint16', clbk, {} ); // $ExpectType RealOrComplexTypedArray | BooleanArray - - filledarrayBy( buf, 8, 2, clbk ); // $ExpectType RealOrComplexTypedArray | BooleanArray - filledarrayBy( buf, 8, 2, clbk, {} ); // $ExpectType RealOrComplexTypedArray | BooleanArray - - filledarrayBy( buf, 8, 2, 'int16', clbk ); // $ExpectType RealOrComplexTypedArray | BooleanArray - filledarrayBy( buf, 8, 2, 'int16', clbk, {} ); // $ExpectType RealOrComplexTypedArray | BooleanArray -} - -// The compiler throws an error if a callback function argument is not a function... -{ - filledarrayBy( 'float64', '5' ); // $ExpectError - filledarrayBy( 'float64', 1.0 ); // $ExpectError - filledarrayBy( 'float64', false ); // $ExpectError - filledarrayBy( 'float64', true ); // $ExpectError - filledarrayBy( 'float64', null ); // $ExpectError - filledarrayBy( 'float64', undefined ); // $ExpectError - filledarrayBy( 'float64', [] ); // $ExpectError - filledarrayBy( 'float64', {} ); // $ExpectError - - filledarrayBy( 'float64', '5', {} ); // $ExpectError - filledarrayBy( 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( 'float64', false, {} ); // $ExpectError - filledarrayBy( 'float64', true, {} ); // $ExpectError - filledarrayBy( 'float64', null, {} ); // $ExpectError - filledarrayBy( 'float64', undefined, {} ); // $ExpectError - filledarrayBy( 'float64', [], {} ); // $ExpectError - filledarrayBy( 'float64', {}, {} ); // $ExpectError - - filledarrayBy( 10, '5' ); // $ExpectError - filledarrayBy( 10, 1.0 ); // $ExpectError - filledarrayBy( 10, false ); // $ExpectError - filledarrayBy( 10, true ); // $ExpectError - filledarrayBy( 10, null ); // $ExpectError - filledarrayBy( 10, undefined ); // $ExpectError - filledarrayBy( 10, [] ); // $ExpectError - filledarrayBy( 10, {} ); // $ExpectError - - filledarrayBy( 10, '5', {} ); // $ExpectError - filledarrayBy( 10, 1.0, {} ); // $ExpectError - filledarrayBy( 10, false, {} ); // $ExpectError - filledarrayBy( 10, true, {} ); // $ExpectError - filledarrayBy( 10, null, {} ); // $ExpectError - filledarrayBy( 10, undefined, {} ); // $ExpectError - filledarrayBy( 10, [], {} ); // $ExpectError - filledarrayBy( 10, {}, {} ); // $ExpectError - - filledarrayBy( 10, 'float64', '5' ); // $ExpectError - filledarrayBy( 10, 'float64', 1.0 ); // $ExpectError - filledarrayBy( 10, 'float64', false ); // $ExpectError - filledarrayBy( 10, 'float64', true ); // $ExpectError - filledarrayBy( 10, 'float64', null ); // $ExpectError - filledarrayBy( 10, 'float64', undefined ); // $ExpectError - filledarrayBy( 10, 'float64', [] ); // $ExpectError - filledarrayBy( 10, 'float64', {} ); // $ExpectError - - filledarrayBy( 10, 'float64', '5', {} ); // $ExpectError - filledarrayBy( 10, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( 10, 'float64', false, {} ); // $ExpectError - filledarrayBy( 10, 'float64', true, {} ); // $ExpectError - filledarrayBy( 10, 'float64', null, {} ); // $ExpectError - filledarrayBy( 10, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( 10, 'float64', [], {} ); // $ExpectError - filledarrayBy( 10, 'float64', {}, {} ); // $ExpectError - - const x = new Float64Array( 10 ); - filledarrayBy( x, '5' ); // $ExpectError - filledarrayBy( x, 1.0 ); // $ExpectError - filledarrayBy( x, false ); // $ExpectError - filledarrayBy( x, true ); // $ExpectError - filledarrayBy( x, null ); // $ExpectError - filledarrayBy( x, undefined ); // $ExpectError - filledarrayBy( x, [] ); // $ExpectError - filledarrayBy( x, {} ); // $ExpectError - - filledarrayBy( x, '5', {} ); // $ExpectError - filledarrayBy( x, 1.0, {} ); // $ExpectError - filledarrayBy( x, false, {} ); // $ExpectError - filledarrayBy( x, true, {} ); // $ExpectError - filledarrayBy( x, null, {} ); // $ExpectError - filledarrayBy( x, undefined, {} ); // $ExpectError - filledarrayBy( x, [], {} ); // $ExpectError - filledarrayBy( x, {}, {} ); // $ExpectError - - filledarrayBy( x, 'float64', '5' ); // $ExpectError - filledarrayBy( x, 'float64', 1.0 ); // $ExpectError - filledarrayBy( x, 'float64', false ); // $ExpectError - filledarrayBy( x, 'float64', true ); // $ExpectError - filledarrayBy( x, 'float64', null ); // $ExpectError - filledarrayBy( x, 'float64', undefined ); // $ExpectError - filledarrayBy( x, 'float64', [] ); // $ExpectError - filledarrayBy( x, 'float64', {} ); // $ExpectError - - filledarrayBy( x, 'float64', '5', {} ); // $ExpectError - filledarrayBy( x, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( x, 'float64', false, {} ); // $ExpectError - filledarrayBy( x, 'float64', true, {} ); // $ExpectError - filledarrayBy( x, 'float64', null, {} ); // $ExpectError - filledarrayBy( x, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( x, 'float64', [], {} ); // $ExpectError - filledarrayBy( x, 'float64', {}, {} ); // $ExpectError - - const y = [ 2.0, 2.0, 2.0 ]; - filledarrayBy( y, '5' ); // $ExpectError - filledarrayBy( y, 1.0 ); // $ExpectError - filledarrayBy( y, false ); // $ExpectError - filledarrayBy( y, true ); // $ExpectError - filledarrayBy( y, null ); // $ExpectError - filledarrayBy( y, undefined ); // $ExpectError - filledarrayBy( y, [] ); // $ExpectError - filledarrayBy( y, {} ); // $ExpectError - - filledarrayBy( y, '5', {} ); // $ExpectError - filledarrayBy( y, 1.0, {} ); // $ExpectError - filledarrayBy( y, false, {} ); // $ExpectError - filledarrayBy( y, true, {} ); // $ExpectError - filledarrayBy( y, null, {} ); // $ExpectError - filledarrayBy( y, undefined, {} ); // $ExpectError - filledarrayBy( y, [], {} ); // $ExpectError - filledarrayBy( y, {}, {} ); // $ExpectError - - filledarrayBy( y, 'float64', '5' ); // $ExpectError - filledarrayBy( y, 'float64', 1.0 ); // $ExpectError - filledarrayBy( y, 'float64', false ); // $ExpectError - filledarrayBy( y, 'float64', true ); // $ExpectError - filledarrayBy( y, 'float64', null ); // $ExpectError - filledarrayBy( y, 'float64', undefined ); // $ExpectError - filledarrayBy( y, 'float64', [] ); // $ExpectError - filledarrayBy( y, 'float64', {} ); // $ExpectError - - filledarrayBy( y, 'float64', '5', {} ); // $ExpectError - filledarrayBy( y, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( y, 'float64', false, {} ); // $ExpectError - filledarrayBy( y, 'float64', true, {} ); // $ExpectError - filledarrayBy( y, 'float64', null, {} ); // $ExpectError - filledarrayBy( y, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( y, 'float64', [], {} ); // $ExpectError - filledarrayBy( y, 'float64', {}, {} ); // $ExpectError - - const it = iterator(); - filledarrayBy( it, '5' ); // $ExpectError - filledarrayBy( it, 1.0 ); // $ExpectError - filledarrayBy( it, false ); // $ExpectError - filledarrayBy( it, true ); // $ExpectError - filledarrayBy( it, null ); // $ExpectError - filledarrayBy( it, undefined ); // $ExpectError - filledarrayBy( it, [] ); // $ExpectError - filledarrayBy( it, {} ); // $ExpectError - - filledarrayBy( it, '5', {} ); // $ExpectError - filledarrayBy( it, 1.0, {} ); // $ExpectError - filledarrayBy( it, false, {} ); // $ExpectError - filledarrayBy( it, true, {} ); // $ExpectError - filledarrayBy( it, null, {} ); // $ExpectError - filledarrayBy( it, undefined, {} ); // $ExpectError - filledarrayBy( it, [], {} ); // $ExpectError - filledarrayBy( it, {}, {} ); // $ExpectError - - filledarrayBy( it, 'float64', '5' ); // $ExpectError - filledarrayBy( it, 'float64', 1.0 ); // $ExpectError - filledarrayBy( it, 'float64', false ); // $ExpectError - filledarrayBy( it, 'float64', true ); // $ExpectError - filledarrayBy( it, 'float64', null ); // $ExpectError - filledarrayBy( it, 'float64', undefined ); // $ExpectError - filledarrayBy( it, 'float64', [] ); // $ExpectError - filledarrayBy( it, 'float64', {} ); // $ExpectError - - filledarrayBy( it, 'float64', '5', {} ); // $ExpectError - filledarrayBy( it, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( it, 'float64', false, {} ); // $ExpectError - filledarrayBy( it, 'float64', true, {} ); // $ExpectError - filledarrayBy( it, 'float64', null, {} ); // $ExpectError - filledarrayBy( it, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( it, 'float64', [], {} ); // $ExpectError - filledarrayBy( it, 'float64', {}, {} ); // $ExpectError - - const buf = new ArrayBuffer( 32 ); - filledarrayBy( buf, '5' ); // $ExpectError - filledarrayBy( buf, 1.0 ); // $ExpectError - filledarrayBy( buf, false ); // $ExpectError - filledarrayBy( buf, true ); // $ExpectError - filledarrayBy( buf, null ); // $ExpectError - filledarrayBy( buf, undefined ); // $ExpectError - filledarrayBy( buf, [] ); // $ExpectError - filledarrayBy( buf, {} ); // $ExpectError - - filledarrayBy( buf, '5', {} ); // $ExpectError - filledarrayBy( buf, 1.0, {} ); // $ExpectError - filledarrayBy( buf, false, {} ); // $ExpectError - filledarrayBy( buf, true, {} ); // $ExpectError - filledarrayBy( buf, null, {} ); // $ExpectError - filledarrayBy( buf, undefined, {} ); // $ExpectError - filledarrayBy( buf, [], {} ); // $ExpectError - filledarrayBy( buf, {}, {} ); // $ExpectError - - filledarrayBy( buf, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 'float64', false ); // $ExpectError - filledarrayBy( buf, 'float64', true ); // $ExpectError - filledarrayBy( buf, 'float64', null ); // $ExpectError - filledarrayBy( buf, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 'float64', {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5' ); // $ExpectError - filledarrayBy( buf, 8, 1.0 ); // $ExpectError - filledarrayBy( buf, 8, false ); // $ExpectError - filledarrayBy( buf, 8, true ); // $ExpectError - filledarrayBy( buf, 8, null ); // $ExpectError - filledarrayBy( buf, 8, undefined ); // $ExpectError - filledarrayBy( buf, 8, [] ); // $ExpectError - filledarrayBy( buf, 8, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, false, {} ); // $ExpectError - filledarrayBy( buf, 8, true, {} ); // $ExpectError - filledarrayBy( buf, 8, null, {} ); // $ExpectError - filledarrayBy( buf, 8, undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, [], {} ); // $ExpectError - filledarrayBy( buf, 8, {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 8, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 'float64', false ); // $ExpectError - filledarrayBy( buf, 8, 'float64', true ); // $ExpectError - filledarrayBy( buf, 8, 'float64', null ); // $ExpectError - filledarrayBy( buf, 8, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 8, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 8, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 8, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, '5' ); // $ExpectError - filledarrayBy( buf, 8, 2, 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 2, false ); // $ExpectError - filledarrayBy( buf, 8, 2, true ); // $ExpectError - filledarrayBy( buf, 8, 2, null ); // $ExpectError - filledarrayBy( buf, 8, 2, undefined ); // $ExpectError - filledarrayBy( buf, 8, 2, [] ); // $ExpectError - filledarrayBy( buf, 8, 2, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, false, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, true, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, null, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, [], {} ); // $ExpectError - filledarrayBy( buf, 8, 2, {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', false ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', true ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', null ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', {}, {} ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid length, typed array, array-like object, `ArrayBuffer`, or iterable argument... -{ - filledarrayBy( false, clbk ); // $ExpectError - filledarrayBy( true, clbk ); // $ExpectError - filledarrayBy( null, clbk ); // $ExpectError - filledarrayBy( {}, clbk ); // $ExpectError - - filledarrayBy( false, clbk, {} ); // $ExpectError - filledarrayBy( true, clbk, {} ); // $ExpectError - filledarrayBy( null, clbk, {} ); // $ExpectError - filledarrayBy( {}, clbk, {} ); // $ExpectError - - filledarrayBy( false, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 'float64', clbk ); // $ExpectError - - filledarrayBy( false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, clbk ); // $ExpectError - filledarrayBy( 1.0, 8, clbk ); // $ExpectError - filledarrayBy( false, 8, clbk ); // $ExpectError - filledarrayBy( true, 8, clbk ); // $ExpectError - filledarrayBy( null, 8, clbk ); // $ExpectError - filledarrayBy( undefined, 8, clbk ); // $ExpectError - filledarrayBy( [], 8, clbk ); // $ExpectError - filledarrayBy( {}, 8, clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, clbk ); // $ExpectError - - filledarrayBy( '5', 8, clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, clbk, {} ); // $ExpectError - filledarrayBy( false, 8, clbk, {} ); // $ExpectError - filledarrayBy( true, 8, clbk, {} ); // $ExpectError - filledarrayBy( null, 8, clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, clbk, {} ); // $ExpectError - filledarrayBy( [], 8, clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 'float64', clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( false, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( [], 8, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 'float64', clbk ); // $ExpectError - - filledarrayBy( '5', 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 2, clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 2, clbk ); // $ExpectError - filledarrayBy( false, 8, 2, clbk ); // $ExpectError - filledarrayBy( true, 8, 2, clbk ); // $ExpectError - filledarrayBy( null, 8, 2, clbk ); // $ExpectError - filledarrayBy( undefined, 8, 2, clbk ); // $ExpectError - filledarrayBy( [], 8, 2, clbk ); // $ExpectError - filledarrayBy( {}, 8, 2, clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, clbk ); // $ExpectError - - filledarrayBy( '5', 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( false, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( [], 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, 'float64', clbk ); // $ExpectError - - filledarrayBy( '5', 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a byte offset argument which is not a number... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, false, clbk ); // $ExpectError - filledarrayBy( buf, true, clbk ); // $ExpectError - filledarrayBy( buf, null, clbk ); // $ExpectError - filledarrayBy( buf, [], clbk ); // $ExpectError - filledarrayBy( buf, {}, clbk ); // $ExpectError - - filledarrayBy( buf, false, clbk, {} ); // $ExpectError - filledarrayBy( buf, true, clbk, {} ); // $ExpectError - filledarrayBy( buf, null, clbk, {} ); // $ExpectError - filledarrayBy( buf, [], clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, clbk, {} ); // $ExpectError - - filledarrayBy( buf, '5', 'float64', clbk ); // $ExpectError - filledarrayBy( buf, false, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, true, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, null, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, [], 'float64', clbk ); // $ExpectError - filledarrayBy( buf, {}, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, '5', 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( buf, false, 2, clbk ); // $ExpectError - filledarrayBy( buf, true, 2, clbk ); // $ExpectError - filledarrayBy( buf, null, 2, clbk ); // $ExpectError - filledarrayBy( buf, [], 2, clbk ); // $ExpectError - filledarrayBy( buf, {}, 2, clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, clbk ); // $ExpectError - - filledarrayBy( buf, false, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, clbk, {} ); // $ExpectError - - filledarrayBy( buf, '5', 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, false, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, true, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, null, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, undefined, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, [], 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, {}, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, '5', 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, false, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, undefined, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a view length argument which is not a number... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, 8, false, clbk ); // $ExpectError - filledarrayBy( buf, 8, true, clbk ); // $ExpectError - filledarrayBy( buf, 8, null, clbk ); // $ExpectError - filledarrayBy( buf, 8, [], clbk ); // $ExpectError - filledarrayBy( buf, 8, {}, clbk ); // $ExpectError - - filledarrayBy( buf, 8, false, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, true, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, null, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, [], clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, {}, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, clbk, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5', 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, false, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, true, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, null, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, [], 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, {}, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, 8, '5', 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, [], 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, {}, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided too many arguments... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, 8, 2, 'float64', 1, clbk, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 997a381..0000000 --- a/examples/index.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ).factory; -var dtypes = require( '@stdlib/array-typed-real-dtypes' ); -var filledarrayBy = require( './../lib' ); - -// Create a pseudorandom number generator: -var rand = discreteUniform( 0, 100 ); - -// Get a list of array data types: -var dt = dtypes(); - -// Generate filled arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = filledarrayBy( 10, dt[ i ], rand ); - console.log( arr ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 764e40e..cb63cd1 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, RealOrComplexTypedArray, BooleanArray, DataType } from '@stdlib/types/array'; import { IterableIterator } from '@stdlib/types/iter'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..1ee9290 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@v0.0.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-ctors@v0.3.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill-by@v0.2.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled-by@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@v0.2.2-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.4.0-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";var v=f(),g=j.get("dtypes.default");function c(){var f,j,c,b,y,x,u,E;if(0===(j=arguments.length))return new(y=d(g))(0);if(r(c=arguments[0])){if(j>1)throw new TypeError(w("00h05"));if(null===(y=d(c)))throw new TypeError(w("00h2Y",c));return new y(0)}if(j<2)throw new TypeError(w("00h05"));if(h(arguments[j-=1]))if(h(arguments[j-1])){if(f=arguments[j],b=arguments[j-=1],0===j)throw new TypeError(w("00h05"))}else b=arguments[j];else{if(!(j>=2))throw new TypeError(w("00h05"));if(f=arguments[j],!h(b=arguments[j-=1]))throw new TypeError(w("00h2b",b))}if((j-=1)>=0&&r(arguments[j])?(c=arguments[j],j-=1):c=g,null===(y=d(c)))throw new TypeError(w("00h2Y",c));if("generic"===c){if(E=arguments[0],0===j){if(e(E)?u=E:i(E)&&(u=E.length),void 0!==u)return m(u,b,f);if(n(E))throw new Error(w("00h04"));if(o(E)){if(!1===v)throw new TypeError(w("00h2Z",E));if(!h(E[p]))throw new TypeError(w("00h2a",E));if(E=E[p](),!h(E.next))throw new TypeError(w("00h2a",E));return function(r,e,t){var s,i;for(s=[],i=-1;!r.next().done;)i+=1,s.push(e.call(t,i));return s}(E,b,f)}throw new TypeError(w("00h2a",E))}if(n(E))throw new Error(w("00h04"));throw new TypeError(w("00h2a",E))}if(0===j)if(i(E=arguments[0]))x=new y(E.length);else if(n(E))x=new y(E);else if(e(E))x=new y(E);else{if(!o(E))throw new TypeError(w("00h2a",E));if(!1===v)throw new TypeError(w("00h2Z",E));if(!h(E[p]))throw new TypeError(w("00h2a",E));if(E=E[p](),!h(E.next))throw new TypeError(w("00h2a",E));x=new y(a(E))}else x=1===j?new y(arguments[0],arguments[1]):new y(arguments[0],arguments[1],arguments[2]);return x.length>0&&(t(c)||s(c)?function(r,e,t){var s;for(s=0;s\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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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( format('00h05') );\n\t\t}\n\t\tctor = ctors( dtype );\n\t\tif ( ctor === null ) {\n\t\t\tthrow new TypeError( format( '00h2Y', 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( format('00h05') );\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( format('00h05') );\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( '00h2b', clbk ) );\n\t\t}\n\t}\n\t// If we 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( format('00h05') );\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( '00h2Y', 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( format('00h04') );\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( '00h2Z', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00h2a', 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( '00h2a', 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( '00h2a', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format('00h04') );\n\t\t}\n\t\tthrow new TypeError( format( '00h2a', 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( '00h2Z', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00h2a', 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( '00h2a', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00h2a', 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\nexport default filledarrayBy;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","DEFAULT_DTYPE","defaults","get","filledarrayBy","thisArg","nargs","dtype","clbk","ctor","arr","len","arg","arguments","length","ctors","isString","TypeError","format","isFunction","isNonNegativeInteger","isCollection","filledArray","isArrayBuffer","Error","isObject","ITERATOR_SYMBOL","next","it","i","done","push","call","filledArrayIterator","iterLength","isComplexDataType","isBooleanDataType","set","filledAccessors","gfillBy","value","aidx"],"mappings":";;sjDA0CA,IAAIA,EAAsBC,IACtBC,EAAgBC,EAASC,IAAK,kBA2MlC,SAASC,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAKJ,GAAe,KAHfN,EAAQO,UAAUC,QAKjB,OAAO,IADPL,EAAOM,EAAOd,IACG,GAIlB,GAAKe,EADLT,EAAQM,UAAW,IACM,CAExB,GAAKP,EAAQ,EACZ,MAAM,IAAIW,UAAWC,EAAO,UAG7B,GAAc,QADdT,EAAOM,EAAOR,IAEb,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,OAAO,IAAIE,EAAM,EACjB,CAED,GAAKH,EAAQ,EACZ,MAAM,IAAIW,UAAWC,EAAO,UAM7B,GAAKC,EAAYN,UAHjBP,GAAS,IAKR,GAAKa,EAAYN,UAAWP,EAAM,KAMjC,GALAD,EAAUQ,UAAWP,GAErBE,EAAOK,UADPP,GAAS,GAIM,IAAVA,EACJ,MAAM,IAAIW,UAAWC,EAAO,eAI7BV,EAAOK,UAAWP,OAIf,MAAKA,GAAS,GAUlB,MAAM,IAAIW,UAAWC,EAAO,UAN5B,GAHAb,EAAUQ,UAAWP,IAGfa,EADNX,EAAOK,UADPP,GAAS,IAGR,MAAM,IAAIW,UAAWC,EAAQ,QAASV,GAMvC,CAUD,IARAF,GAAS,IACK,GAAKU,EAAUH,UAAWP,KACvCC,EAAQM,UAAWP,GACnBA,GAAS,GAETC,EAAQN,EAGK,QADdQ,EAAOM,EAAOR,IAEb,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,GAAe,YAAVA,EAAsB,CAE1B,GADAK,EAAMC,UAAW,GACF,IAAVP,EAAc,CAMlB,GALKc,EAAsBR,GAC1BD,EAAMC,EACKS,EAAcT,KACzBD,EAAMC,EAAIE,aAEE,IAARH,EACJ,OAAOW,EAAaX,EAAKH,EAAMH,GAEhC,GAAKkB,EAAeX,GACnB,MAAM,IAAIY,MAAON,EAAO,UAEzB,GAAKO,EAAUb,GAAQ,CACtB,IAA6B,IAAxBb,EACJ,MAAM,IAAIkB,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAYP,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLP,EAAYP,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvC,OAvSJ,SAA8BgB,EAAIpB,EAAMH,GACvC,IAAIK,EACAmB,EAKJ,IAFAnB,EAAM,GACNmB,GAAK,GAEAD,EAAGD,OACAG,MAGPD,GAAK,EACLnB,EAAIqB,KAAMvB,EAAKwB,KAAM3B,EAASwB,IAE/B,OAAOnB,CACR,CAuRWuB,CAAqBrB,EAAKJ,EAAMH,EACvC,CACD,MAAM,IAAIY,UAAWC,EAAQ,QAASN,GACzC,CAAS,GAAKW,EAAeX,GAC1B,MAAM,IAAIY,MAAON,EAAO,UAEzB,MAAM,IAAID,UAAWC,EAAQ,QAASN,GACtC,CACD,GAAe,IAAVN,EAEJ,GAAKe,EADLT,EAAMC,UAAW,IAEhBH,EAAM,IAAID,EAAMG,EAAIE,aACd,GAAKS,EAAeX,GAC1BF,EAAM,IAAID,EAAMG,QACV,GAAKQ,EAAsBR,GACjCF,EAAM,IAAID,EAAMG,OACV,KAAKa,EAAUb,GAarB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAZtC,IAA6B,IAAxBb,EACJ,MAAM,IAAIkB,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAYP,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLP,EAAYP,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvCF,EAAM,IAAID,EAAMyB,EAAYtB,GAG5B,MAEDF,EADqB,IAAVJ,EACL,IAAIG,EAAMI,UAAU,GAAIA,UAAU,IAElC,IAAIJ,EAAMI,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKH,EAAII,OAAS,IACZqB,EAAmB5B,IAAW6B,EAAmB7B,GAjTxD,SAA0BG,EAAKF,EAAMH,GACpC,IAAIwB,EACJ,IAAMA,EAAI,EAAGA,EAAInB,EAAII,OAAQe,IAC5BnB,EAAI2B,IAAK7B,EAAKwB,KAAM3B,EAASwB,GAAKA,EAGpC,CA4SGS,CAAiB5B,EAAKF,EAAMH,GAE5BkC,EAAS7B,EAAII,OAAQJ,EAAK,GAe5B,SAAmB8B,EAAOC,GACzB,OAAOjC,EAAKwB,KAAM3B,EAASoC,EAC3B,KAdM/B,CAeR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d115cf0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,192 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -/** -* Create a filled array according to a provided callback function. -* -* @module @stdlib/array-filled-by -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* var arr = filledarrayBy(); -* // returns -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'generic', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( [ 0.5, 0.5 ], clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1; -* } -* -* var arr = filledarrayBy( [ 5, -3 ], 'int32', clbk ); -* // returns [ 1, 1 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk1() { -* return 10; -* } -* -* function clbk2() { -* return 1.0; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, clbk2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk1() { -* return 1.0; -* } -* -* function clbk2() { -* return 2; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, 'uint32', clbk2 ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 'float32', clbk ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, clbk ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, 'int32', clbk ); -* // returns [ 1, 1 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 32b6545..0000000 --- a/lib/main.js +++ /dev/null @@ -1,416 +0,0 @@ -/** -* @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 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' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var ctors = require( '@stdlib/array-ctors' ); -var gfillBy = require( '@stdlib/blas-ext-base-gfill-by' ); -var filledArray = require( '@stdlib/array-base-filled-by' ); -var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var iterLength = require( '@stdlib/iter-length' ); -var defaults = require( '@stdlib/array-defaults' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport(); -var DEFAULT_DTYPE = defaults.get( 'dtypes.default' ); - - -// FUNCTIONS // - -/** -* Creates a filled "generic" array from an iterator. -* -* @private -* @param {Iterable} it - iterator -* @param {Callback} clbk - callback function -* @param {*} thisArg - callback function execution context -* @returns {Array} filled array -*/ -function filledArrayIterator( it, clbk, thisArg ) { - var arr; - var i; - var v; - - arr = []; - i = -1; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - i += 1; - arr.push( clbk.call( thisArg, i ) ); - } - return arr; -} - -/** -* Fills an array exposing accessors for getting and setting array elements. -* -* @private -* @param {Collection} arr - input array -* @param {Callback} clbk - callback function -* @param {*} thisArg - callback function execution context -* @returns {Collection} input array -*/ -function filledAccessors( arr, clbk, thisArg ) { - var i; - for ( i = 0; i < arr.length; i++ ) { - arr.set( clbk.call( thisArg, i ), i ); - } - return arr; -} - - -// MAIN // - -/** -* Creates a filled array according to a provided callback function. -* -* @param {(NonNegativeInteger|TypedArray|ArrayLikeObject|ArrayBuffer|Iterable)} [arg] - a length, typed array, array-like object, buffer, or iterable -* @param {NonNegativeInteger} [byteOffset=0] - byte offset -* @param {NonNegativeInteger} [length] - view length -* @param {string} [dtype="float64"] - data type -* @param {Callback} [clbk] - callback to invoke -* @param {*} [thisArg] - callback execution context -* @throws {TypeError} must provide a recognized data type -* @throws {TypeError} must provide a length, typed array, array-like object, buffer, or iterable -* @throws {TypeError} callback argument must be a function. -* @throws {Error} creating a generic array from an `ArrayBuffer` is not supported -* @returns {(TypedArray|Array)} array or typed array -* -* @example -* var arr = filledarrayBy(); -* // returns -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'generic', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( [ 0.5, 0.5 ], clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1; -* } -* -* var arr = filledarrayBy( [ 5, -3 ], 'int32', clbk ); -* // returns [ 1, 1 ] -* -* @example -* function clbk1() { -* return 10; -* } -* -* function clbk2() { -* return 1.0; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, clbk2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk1() { -* return 1.0; -* } -* -* function clbk2() { -* return 2; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, 'uint32', clbk2 ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 'float32', clbk ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, clbk ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, 'int32', clbk ); -* // returns [ 1, 1 ] -*/ -function filledarrayBy() { - var thisArg; - var nargs; - var dtype; - var clbk; - var ctor; - var arr; - var len; - var arg; - - nargs = arguments.length; - - // If we weren't provided any arguments, return an empty array... - if ( nargs === 0 ) { - ctor = ctors( DEFAULT_DTYPE ); - return new ctor( 0 ); - } - // Check if we were provided a dtype as the first argument... - dtype = arguments[ 0 ]; - if ( isString( dtype ) ) { - // Invoking this function with arguments `f( dtype, clbk[, thisArg] )` is not allowed (otherwise, we'd need to also allow `f( clbk[, thisArg] )`)... - if ( nargs > 1 ) { - throw new TypeError( format('00h05') ); - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '00h2Y', dtype ) ); - } - // Return an empty array having the specified dtype: - return new ctor( 0 ); - } - // For all other supported invocations, we need at least two arguments... - if ( nargs < 2 ) { - throw new TypeError( format('00h05') ); - } - // At this point, we need to do some argument juggling... - nargs -= 1; // henceforth, the number of available arguments is `nargs+1` - - // Determine whether the last argument is a callback or "this" context... - if ( isFunction( arguments[ nargs ] ) ) { - // 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... - if ( isFunction( arguments[ nargs-1 ] ) ) { - thisArg = arguments[ nargs ]; - nargs -= 1; - clbk = arguments[ nargs ]; - - // Check if we were provided only a callback and a "this" context.. - if ( nargs === 0 ) { - throw new TypeError( format('00h05') ); - } - } else { - // "this" context is left undefined... - clbk = arguments[ nargs ]; - } - } - // 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... - else if ( nargs >= 2 ) { - thisArg = arguments[ nargs ]; - nargs -= 1; - clbk = arguments[ nargs ]; - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '00h2b', clbk ) ); - } - } - // If we were only provided 2 arguments and the last argument was not a function, we've been provided an insufficient number of arguments... - else { - throw new TypeError( format('00h05') ); - } - // Now that we've processed the callback arguments, let's continue working backward to see if we've been provided a `dtype` argument... - nargs -= 1; - if ( nargs >= 0 && isString( arguments[ nargs ] ) ) { - dtype = arguments[ nargs ]; - nargs -= 1; - } else { - dtype = DEFAULT_DTYPE; - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '00h2Y', dtype ) ); - } - // At this point, we've resolved the output array data type, and now we can actually create the output array... - if ( dtype === 'generic' ) { - arg = arguments[ 0 ]; - if ( nargs === 0 ) { - if ( isNonNegativeInteger( arg ) ) { - len = arg; - } else if ( isCollection( arg ) ) { - len = arg.length; - } - if ( len !== void 0 ) { - return filledArray( len, clbk, thisArg ); - } - if ( isArrayBuffer( arg ) ) { - throw new Error( format('00h04') ); - } - if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( '00h2Z', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00h2a', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00h2a', arg ) ); - } - return filledArrayIterator( arg, clbk, thisArg ); - } - throw new TypeError( format( '00h2a', arg ) ); - } else if ( isArrayBuffer( arg ) ) { - throw new Error( format('00h04') ); - } - throw new TypeError( format( '00h2a', arg ) ); - } - if ( nargs === 0 ) { // length || array-like || ArrayBuffer || iterable - arg = arguments[ 0 ]; - if ( isCollection( arg ) ) { - arr = new ctor( arg.length ); - } else if ( isArrayBuffer( arg ) ) { - arr = new ctor( arg ); - } else if ( isNonNegativeInteger( arg ) ) { - arr = new ctor( arg ); - } else if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( '00h2Z', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00h2a', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00h2a', arg ) ); - } - arr = new ctor( iterLength( arg ) ); - } else { - throw new TypeError( format( '00h2a', arg ) ); - } - } else if ( nargs === 1 ) { - arr = new ctor( arguments[0], arguments[1] ); // (ArrayBuffer, byteOffset) - } else { - arr = new ctor( arguments[0], arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset, length) - } - if ( arr.length > 0 ) { - if ( isComplexDataType( dtype ) || isBooleanDataType( dtype ) ) { - filledAccessors( arr, clbk, thisArg ); - } else { - gfillBy( arr.length, arr, 1, callback ); - } - } - return arr; - - /** - * Callback which wraps a provided callback and is invoked for each array element. - * - * @private - * @param {*} value - element value - * @param {NonNegativeInteger} aidx - array index - * @param {NonNegativeInteger} sidx - strided index - * @param {Collection} array - input array/collection - * @returns {*} callback return value - */ - function callback( value, aidx ) { - return clbk.call( thisArg, aidx ); - } -} - - -// EXPORTS // - -module.exports = filledarrayBy; diff --git a/package.json b/package.json index 7c90e3b..e0039b0 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.3.0", "description": "Create a filled array according to a provided callback function.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,75 +13,6 @@ "bugs": { "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.2", - "@stdlib/array-ctors": "^0.3.0", - "@stdlib/array-defaults": "^0.4.0", - "@stdlib/assert-has-iterator-symbol-support": "^0.2.2", - "@stdlib/assert-is-arraybuffer": "^0.2.2", - "@stdlib/assert-is-collection": "^0.2.2", - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer": "^0.2.2", - "@stdlib/assert-is-object": "^0.2.2", - "@stdlib/assert-is-string": "^0.2.2", - "@stdlib/blas-ext-base-gfill-by": "^0.2.2", - "@stdlib/iter-length": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/symbol-iterator": "^0.2.2", - "@stdlib/types": "^0.4.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-bool": "^0.1.0", - "@stdlib/array-buffer": "^0.2.2", - "@stdlib/array-complex128": "^0.3.0", - "@stdlib/array-complex64": "^0.3.0", - "@stdlib/array-float32": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/array-int16": "^0.2.2", - "@stdlib/array-int32": "^0.2.2", - "@stdlib/array-int8": "^0.2.2", - "@stdlib/array-typed-real-dtypes": "^0.2.2", - "@stdlib/array-uint16": "^0.2.2", - "@stdlib/array-uint32": "^0.2.2", - "@stdlib/array-uint8": "^0.2.2", - "@stdlib/array-uint8c": "^0.2.2", - "@stdlib/assert-instance-of": "^0.3.0", - "@stdlib/assert-is-array": "^0.2.2", - "@stdlib/assert-is-typed-array": "^0.2.2", - "@stdlib/assert-is-typed-array-like": "^0.2.2", - "@stdlib/complex-float32-ctor": "^0.1.0", - "@stdlib/complex-float64-ctor": "^0.1.0", - "@stdlib/iter-constant": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/random-base-discrete-uniform": "^0.2.1", - "@stdlib/strided-base-reinterpret-boolean": "^0.0.2", - "@stdlib/strided-base-reinterpret-complex128": "^0.2.2", - "@stdlib/strided-base-reinterpret-complex64": "^0.2.1", - "@stdlib/utils-constant-function": "^0.2.2", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..e5cc823 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index ca0cf25..0000000 --- a/test/test.js +++ /dev/null @@ -1,4397 +0,0 @@ -/** -* @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. -*/ - -/* eslint-disable max-len */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -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' ); -var iterConstant = require( '@stdlib/iter-constant' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var filledarrayBy = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': !hasIteratorSymbolSupport() -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof filledarrayBy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if only provided callback arguments', function test( t ) { - t.throws( clbk1, TypeError, 'throws an error' ); - t.throws( clbk2, TypeError, 'throws an error' ); - t.throws( clbk3, TypeError, 'throws an error' ); - t.end(); - - function clbk1() { - filledarrayBy( constantFunction( 1.0 ) ); - } - - function clbk2() { - filledarrayBy( constantFunction( 1.0 ), {} ); - } - - function clbk3() { - filledarrayBy( constantFunction( 1.0 ), constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (only argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (typed array; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (array-like object)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (array-like object; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 8 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 8 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, 1, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (iterator)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( iterConstant( 1.0 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (iterator; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( iterConstant( 1.0 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if only provided data type and callback arguments', function test( t ) { - t.throws( clbk1, TypeError, 'throws an error' ); - t.throws( clbk2, TypeError, 'throws an error' ); - t.throws( clbk3, TypeError, 'throws an error' ); - t.end(); - - function clbk1() { - filledarrayBy( 'float64', constantFunction( 1.0 ) ); - } - - function clbk2() { - filledarrayBy( 'float64', constantFunction( 1.0 ), {} ); - } - - function clbk3() { - filledarrayBy( 'float64', constantFunction( 1.0 ), constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (array-like object)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (array-like object; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, 1, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, 1, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (no iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (no iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (non-function iterator symbol property)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (non-function iterator symbol property; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (`next` property is not a function)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ) ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (`next` property is not a function; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ), {} ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (no iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (no iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (non-function iterator symbol property)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (non-function iterator symbol property; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (`next` property is not a function)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ) ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (`next` property is not a function; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ), {} ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 1, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 1, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function returns a filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - arr = filledarrayBy(); - - t.strictEqual( instanceOf( arr, Float64Array ), 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=float64)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - arr = filledarrayBy( 'float64' ); - - t.strictEqual( instanceOf( arr, Float64Array ), 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=float32)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( 0 ); - arr = filledarrayBy( 'float32' ); - - t.strictEqual( instanceOf( arr, Float32Array ), 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=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; - - expected = new Complex128Array( 0 ); - arr = filledarrayBy( 'complex128' ); - - t.strictEqual( instanceOf( arr, Complex128Array ), 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=complex64)', function test( t ) { - var expected; - var arr; - - expected = new Complex64Array( 0 ); - arr = filledarrayBy( 'complex64' ); - - t.strictEqual( instanceOf( arr, Complex64Array ), 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=int32)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( 0 ); - arr = filledarrayBy( 'int32' ); - - t.strictEqual( instanceOf( arr, Int32Array ), 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=uint32)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( 0 ); - arr = filledarrayBy( 'uint32' ); - - t.strictEqual( instanceOf( arr, Uint32Array ), 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=int16)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( 0 ); - arr = filledarrayBy( 'int16' ); - - t.strictEqual( instanceOf( arr, Int16Array ), 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=uint16)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( 0 ); - arr = filledarrayBy( 'uint16' ); - - t.strictEqual( instanceOf( arr, Uint16Array ), 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=int8)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( 0 ); - arr = filledarrayBy( 'int8' ); - - t.strictEqual( instanceOf( arr, Int8Array ), 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=uint8)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( 0 ); - arr = filledarrayBy( 'uint8' ); - - t.strictEqual( instanceOf( arr, Uint8Array ), 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=uint8c)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( 0 ); - arr = filledarrayBy( 'uint8c' ); - - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), 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=generic)', function test( t ) { - var expected; - var arr; - - expected = []; - arr = filledarrayBy( 'generic' ); - - t.strictEqual( instanceOf( arr, Array ), 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 (default, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, length=0)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array(); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 0, clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, clbk, ctx ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (default, length; thisArg=function)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, clbk, context ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this(); // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } - - function context() { - ctx.count += 1; - } -}); - -tape( 'the function returns a filled array (dtype=float64, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, 'float64', clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, length; thisArg=function)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, 'float64', clbk, context ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this(); // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } - - function context() { - ctx.count += 1; - } -}); - -tape( 'the function returns a filled array (dtype=float32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, 'float32', clbk ); - - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - 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; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = filledarrayBy( 5, 'complex128', clbk ); - - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = filledarrayBy( 5, 'complex64', clbk ); - - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int32Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int32', clbk ); - - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint32Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint32', clbk ); - - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int16Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int16', clbk ); - - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint16', clbk ); - - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int8Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int8', clbk ); - - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint8', clbk ); - - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint8c', clbk ); - - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = [ 1, 1, 1, 1, 1 ]; - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'generic', clbk ); - - t.strictEqual( instanceOf( arr, Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - 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; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = [ 1.0, 2.0 ]; - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = [ 1.0, 2.0 ]; - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int32', clbk ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, typed array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, typed array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - 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; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = new Float64Array( [ 1.0, 2.0 ] ); - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = new Float64Array( [ 1.0, 2.0 ] ); - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (default, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - 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; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer, byteoffset; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer, byteoffset; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - 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; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 48 ); - out = filledarrayBy( buf, 16, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 24 ); - out = filledarrayBy( buf, 8, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int32', clbk ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint8c', clbk ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - 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; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 64 ); - out = filledarrayBy( buf, 16, 2, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset, length)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 1, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 1, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled array (default, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, iterator; thisArg)', opts, function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - ctx = { - 'count': 0 - }; - indices = []; - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, iterator; thisArg)', opts, function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - ctx = { - 'count': 0 - }; - indices = []; - out = filledarrayBy( arr, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - 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; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = iterConstant( new Complex128( 3.0, 3.0 ), { - 'iter': 2 - }); - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = iterConstant( new Complex64( 3.0, 3.0 ), { - 'iter': 2 - }); - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); From 211963eca0291fb1b1769daa2464dc6f7edd9a09 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 31 Jan 2026 05:54:29 +0000 Subject: [PATCH 090/117] Update README.md for ESM bundle v0.3.0 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c180d7b..c56b3ce 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import filledarrayBy from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-filled-by@esm/index.mjs'; +import filledarrayBy from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-filled-by@v0.3.0-esm/index.mjs'; ``` #### filledarrayBy( \[dtype] ) @@ -212,7 +212,7 @@ arr = filledarrayBy( buf, 10, 4, 'int16', clbk ); var discreteUniform = require( 'https://cdn.jsdelivr.net/gh/stdlib-js/random-base-discrete-uniform' ).factory; import dtypes from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-typed-real-dtypes@esm/index.mjs'; -import filledarrayBy from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-filled-by@esm/index.mjs'; +import filledarrayBy from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-filled-by@v0.3.0-esm/index.mjs'; // Create a pseudorandom number generator: var rand = discreteUniform( 0, 100 ); From 5a7a485890ff2ef98cdc8f8c5afebd7bf55fe020 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 31 Jan 2026 05:54:29 +0000 Subject: [PATCH 091/117] Auto-generated commit --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c56b3ce..1e0e3ed 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,11 @@ limitations under the License. ## Usage +```javascript +import filledarrayBy from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-filled-by@esm/index.mjs'; +``` +The previous example will load the latest bundled code from the esm branch. Alternatively, you may load a specific version by loading the file from one of the [tagged bundles](https://github.com/stdlib-js/array-filled-by/tags). For example, + ```javascript import filledarrayBy from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-filled-by@v0.3.0-esm/index.mjs'; ``` @@ -212,7 +217,7 @@ arr = filledarrayBy( buf, 10, 4, 'int16', clbk ); var discreteUniform = require( 'https://cdn.jsdelivr.net/gh/stdlib-js/random-base-discrete-uniform' ).factory; import dtypes from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-typed-real-dtypes@esm/index.mjs'; -import filledarrayBy from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-filled-by@v0.3.0-esm/index.mjs'; +import filledarrayBy from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-filled-by@esm/index.mjs'; // Create a pseudorandom number generator: var rand = discreteUniform( 0, 100 ); From eb4b75a6de7ef834853b0813532e98b94af1e9b6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 8 Feb 2026 20:37:12 +0000 Subject: [PATCH 092/117] Transform error messages --- lib/main.js | 38 +++++++++++++++++++------------------- package.json | 2 +- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/lib/main.js b/lib/main.js index d2128f5..32b6545 100644 --- a/lib/main.js +++ b/lib/main.js @@ -35,7 +35,7 @@ var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-supp var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); var iterLength = require( '@stdlib/iter-length' ); var defaults = require( '@stdlib/array-defaults' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -266,18 +266,18 @@ function filledarrayBy() { if ( isString( dtype ) ) { // Invoking this function with arguments `f( dtype, clbk[, thisArg] )` is not allowed (otherwise, we'd need to also allow `f( clbk[, thisArg] )`)... if ( nargs > 1 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format('00h05') ); } ctor = ctors( dtype ); if ( ctor === null ) { - throw new TypeError( format( 'invalid argument. Must provide a recognized data type. Value: `%s`.', dtype ) ); + throw new TypeError( format( '00h2Y', dtype ) ); } // Return an empty array having the specified dtype: return new ctor( 0 ); } // For all other supported invocations, we need at least two arguments... if ( nargs < 2 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format('00h05') ); } // At this point, we need to do some argument juggling... nargs -= 1; // henceforth, the number of available arguments is `nargs+1` @@ -292,7 +292,7 @@ function filledarrayBy() { // Check if we were provided only a callback and a "this" context.. if ( nargs === 0 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format('00h05') ); } } else { // "this" context is left undefined... @@ -305,12 +305,12 @@ function filledarrayBy() { nargs -= 1; clbk = arguments[ nargs ]; if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '00h2b', clbk ) ); } } // If we were only provided 2 arguments and the last argument was not a function, we've been provided an insufficient number of arguments... else { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format('00h05') ); } // Now that we've processed the callback arguments, let's continue working backward to see if we've been provided a `dtype` argument... nargs -= 1; @@ -322,7 +322,7 @@ function filledarrayBy() { } ctor = ctors( dtype ); if ( ctor === null ) { - throw new TypeError( format( 'invalid argument. Must provide a recognized data type. Value: `%s`.', dtype ) ); + throw new TypeError( format( '00h2Y', dtype ) ); } // At this point, we've resolved the output array data type, and now we can actually create the output array... if ( dtype === 'generic' ) { @@ -337,26 +337,26 @@ function filledarrayBy() { return filledArray( len, clbk, thisArg ); } if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format('00h04') ); } if ( isObject( arg ) ) { if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2Z', arg ) ); } if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } arg = arg[ ITERATOR_SYMBOL ](); if ( !isFunction( arg.next ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } return filledArrayIterator( arg, clbk, thisArg ); } - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } else if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format('00h04') ); } - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } if ( nargs === 0 ) { // length || array-like || ArrayBuffer || iterable arg = arguments[ 0 ]; @@ -368,18 +368,18 @@ function filledarrayBy() { arr = new ctor( arg ); } else if ( isObject( arg ) ) { if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2Z', arg ) ); } if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } arg = arg[ ITERATOR_SYMBOL ](); if ( !isFunction( arg.next ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } arr = new ctor( iterLength( arg ) ); } else { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } } else if ( nargs === 1 ) { arr = new ctor( arguments[0], arguments[1] ); // (ArrayBuffer, byteOffset) diff --git a/package.json b/package.json index 22df00e..0c2284a 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "@stdlib/assert-is-string": "^0.2.3", "@stdlib/blas-ext-base-gfill-by": "^0.2.3", "@stdlib/iter-length": "^0.2.3", - "@stdlib/string-format": "^0.2.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.3", "@stdlib/symbol-iterator": "^0.2.3", "@stdlib/types": "^0.4.3", "@stdlib/error-tools-fmtprodmsg": "^0.2.3" From c4ade916bc01160c34c0f61a8311f7a1ba562f6b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 8 Feb 2026 21:48:09 +0000 Subject: [PATCH 093/117] Remove files --- index.d.ts | 322 ---- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5169 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index cb63cd1..0000000 --- a/index.d.ts +++ /dev/null @@ -1,322 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, RealOrComplexTypedArray, BooleanArray, DataType } from '@stdlib/types/array'; -import { IterableIterator } from '@stdlib/types/iter'; - -/** -* Array or typed array. -*/ -type ArrayOrTypedArray = Array | RealOrComplexTypedArray | BooleanArray; - -/** -* Nullary callback function. -* -* @returns fill value -*/ -type Nullary = () => any; - -/** -* Unary callback function. -* -* @param i - current array index -* @returns fill value -*/ -type Unary = ( i: number ) => any; - -/** -* Callback function. -* -* @param i - current array index -* @returns fill value -*/ -type Callback = Nullary | Unary; - -/** -* Creates a filled array according to a provided callback function and having a specified data type. -* -* @param dtype - data type -* @returns filled array -* -* @example -* var arr = filledarrayBy(); -* // returns -* -* @example -* var arr = filledarrayBy( 'float32' ); -* // returns -*/ -declare function filledarrayBy( dtype?: DataType ): ArrayOrTypedArray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Creates a filled array according to a provided callback function and having a specified `length`. -* -* @param length - array length -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* -* var arr = filledarrayBy( 5, constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( length: number, clbk: Callback, thisArg?: any ): ArrayOrTypedArray; - -/** -* Creates a filled array according to a provided callback function and having a specified `length`. -* -* @param length - array length -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* -* var arr = filledarrayBy( 5, 'float64', constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( length: number, dtype: DataType, clbk: Callback, thisArg?: any ): ArrayOrTypedArray; - -/** -* Creates a filled array from another `array` according to a provided callback function. -* -* @param array - typed array or array-like object -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* -* 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; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Creates a filled array from another `array` according to a provided callback function. -* -* @param array - typed array or array-like object -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* -* 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; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Creates a filled array from an iterable according to a callback function. -* -* @param iterable - iterable -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var iterConstant = require( '@stdlib/iter-constant' ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarrayBy( it, constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( iterable: IterableIterator, clbk: Callback, thisArg?: any ): ArrayOrTypedArray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Creates a filled array from an iterable according to a callback function. -* -* @param iterable - iterable -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var iterConstant = require( '@stdlib/iter-constant' ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarrayBy( it, 'float64', constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( iterable: IterableIterator, dtype: DataType, clbk: 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. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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 | BooleanArray; - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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 | BooleanArray; - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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 | BooleanArray; - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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 | BooleanArray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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 | BooleanArray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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 | BooleanArray; // eslint-disable-line @typescript-eslint/unified-signatures - - -// EXPORTS // - -export = filledarrayBy; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 1ee9290..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@v0.0.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-ctors@v0.3.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill-by@v0.2.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled-by@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@v0.2.2-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.4.0-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";var v=f(),g=j.get("dtypes.default");function c(){var f,j,c,b,y,x,u,E;if(0===(j=arguments.length))return new(y=d(g))(0);if(r(c=arguments[0])){if(j>1)throw new TypeError(w("00h05"));if(null===(y=d(c)))throw new TypeError(w("00h2Y",c));return new y(0)}if(j<2)throw new TypeError(w("00h05"));if(h(arguments[j-=1]))if(h(arguments[j-1])){if(f=arguments[j],b=arguments[j-=1],0===j)throw new TypeError(w("00h05"))}else b=arguments[j];else{if(!(j>=2))throw new TypeError(w("00h05"));if(f=arguments[j],!h(b=arguments[j-=1]))throw new TypeError(w("00h2b",b))}if((j-=1)>=0&&r(arguments[j])?(c=arguments[j],j-=1):c=g,null===(y=d(c)))throw new TypeError(w("00h2Y",c));if("generic"===c){if(E=arguments[0],0===j){if(e(E)?u=E:i(E)&&(u=E.length),void 0!==u)return m(u,b,f);if(n(E))throw new Error(w("00h04"));if(o(E)){if(!1===v)throw new TypeError(w("00h2Z",E));if(!h(E[p]))throw new TypeError(w("00h2a",E));if(E=E[p](),!h(E.next))throw new TypeError(w("00h2a",E));return function(r,e,t){var s,i;for(s=[],i=-1;!r.next().done;)i+=1,s.push(e.call(t,i));return s}(E,b,f)}throw new TypeError(w("00h2a",E))}if(n(E))throw new Error(w("00h04"));throw new TypeError(w("00h2a",E))}if(0===j)if(i(E=arguments[0]))x=new y(E.length);else if(n(E))x=new y(E);else if(e(E))x=new y(E);else{if(!o(E))throw new TypeError(w("00h2a",E));if(!1===v)throw new TypeError(w("00h2Z",E));if(!h(E[p]))throw new TypeError(w("00h2a",E));if(E=E[p](),!h(E.next))throw new TypeError(w("00h2a",E));x=new y(a(E))}else x=1===j?new y(arguments[0],arguments[1]):new y(arguments[0],arguments[1],arguments[2]);return x.length>0&&(t(c)||s(c)?function(r,e,t){var s;for(s=0;s\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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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( format('00h05') );\n\t\t}\n\t\tctor = ctors( dtype );\n\t\tif ( ctor === null ) {\n\t\t\tthrow new TypeError( format( '00h2Y', 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( format('00h05') );\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( format('00h05') );\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( '00h2b', clbk ) );\n\t\t}\n\t}\n\t// If we 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( format('00h05') );\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( '00h2Y', 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( format('00h04') );\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( '00h2Z', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00h2a', 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( '00h2a', 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( '00h2a', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format('00h04') );\n\t\t}\n\t\tthrow new TypeError( format( '00h2a', 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( '00h2Z', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00h2a', 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( '00h2a', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00h2a', 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\nexport default filledarrayBy;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","DEFAULT_DTYPE","defaults","get","filledarrayBy","thisArg","nargs","dtype","clbk","ctor","arr","len","arg","arguments","length","ctors","isString","TypeError","format","isFunction","isNonNegativeInteger","isCollection","filledArray","isArrayBuffer","Error","isObject","ITERATOR_SYMBOL","next","it","i","done","push","call","filledArrayIterator","iterLength","isComplexDataType","isBooleanDataType","set","filledAccessors","gfillBy","value","aidx"],"mappings":";;sjDA0CA,IAAIA,EAAsBC,IACtBC,EAAgBC,EAASC,IAAK,kBA2MlC,SAASC,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAKJ,GAAe,KAHfN,EAAQO,UAAUC,QAKjB,OAAO,IADPL,EAAOM,EAAOd,IACG,GAIlB,GAAKe,EADLT,EAAQM,UAAW,IACM,CAExB,GAAKP,EAAQ,EACZ,MAAM,IAAIW,UAAWC,EAAO,UAG7B,GAAc,QADdT,EAAOM,EAAOR,IAEb,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,OAAO,IAAIE,EAAM,EACjB,CAED,GAAKH,EAAQ,EACZ,MAAM,IAAIW,UAAWC,EAAO,UAM7B,GAAKC,EAAYN,UAHjBP,GAAS,IAKR,GAAKa,EAAYN,UAAWP,EAAM,KAMjC,GALAD,EAAUQ,UAAWP,GAErBE,EAAOK,UADPP,GAAS,GAIM,IAAVA,EACJ,MAAM,IAAIW,UAAWC,EAAO,eAI7BV,EAAOK,UAAWP,OAIf,MAAKA,GAAS,GAUlB,MAAM,IAAIW,UAAWC,EAAO,UAN5B,GAHAb,EAAUQ,UAAWP,IAGfa,EADNX,EAAOK,UADPP,GAAS,IAGR,MAAM,IAAIW,UAAWC,EAAQ,QAASV,GAMvC,CAUD,IARAF,GAAS,IACK,GAAKU,EAAUH,UAAWP,KACvCC,EAAQM,UAAWP,GACnBA,GAAS,GAETC,EAAQN,EAGK,QADdQ,EAAOM,EAAOR,IAEb,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,GAAe,YAAVA,EAAsB,CAE1B,GADAK,EAAMC,UAAW,GACF,IAAVP,EAAc,CAMlB,GALKc,EAAsBR,GAC1BD,EAAMC,EACKS,EAAcT,KACzBD,EAAMC,EAAIE,aAEE,IAARH,EACJ,OAAOW,EAAaX,EAAKH,EAAMH,GAEhC,GAAKkB,EAAeX,GACnB,MAAM,IAAIY,MAAON,EAAO,UAEzB,GAAKO,EAAUb,GAAQ,CACtB,IAA6B,IAAxBb,EACJ,MAAM,IAAIkB,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAYP,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLP,EAAYP,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvC,OAvSJ,SAA8BgB,EAAIpB,EAAMH,GACvC,IAAIK,EACAmB,EAKJ,IAFAnB,EAAM,GACNmB,GAAK,GAEAD,EAAGD,OACAG,MAGPD,GAAK,EACLnB,EAAIqB,KAAMvB,EAAKwB,KAAM3B,EAASwB,IAE/B,OAAOnB,CACR,CAuRWuB,CAAqBrB,EAAKJ,EAAMH,EACvC,CACD,MAAM,IAAIY,UAAWC,EAAQ,QAASN,GACzC,CAAS,GAAKW,EAAeX,GAC1B,MAAM,IAAIY,MAAON,EAAO,UAEzB,MAAM,IAAID,UAAWC,EAAQ,QAASN,GACtC,CACD,GAAe,IAAVN,EAEJ,GAAKe,EADLT,EAAMC,UAAW,IAEhBH,EAAM,IAAID,EAAMG,EAAIE,aACd,GAAKS,EAAeX,GAC1BF,EAAM,IAAID,EAAMG,QACV,GAAKQ,EAAsBR,GACjCF,EAAM,IAAID,EAAMG,OACV,KAAKa,EAAUb,GAarB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAZtC,IAA6B,IAAxBb,EACJ,MAAM,IAAIkB,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAYP,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLP,EAAYP,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvCF,EAAM,IAAID,EAAMyB,EAAYtB,GAG5B,MAEDF,EADqB,IAAVJ,EACL,IAAIG,EAAMI,UAAU,GAAIA,UAAU,IAElC,IAAIJ,EAAMI,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKH,EAAII,OAAS,IACZqB,EAAmB5B,IAAW6B,EAAmB7B,GAjTxD,SAA0BG,EAAKF,EAAMH,GACpC,IAAIwB,EACJ,IAAMA,EAAI,EAAGA,EAAInB,EAAII,OAAQe,IAC5BnB,EAAI2B,IAAK7B,EAAKwB,KAAM3B,EAASwB,GAAKA,EAGpC,CA4SGS,CAAiB5B,EAAKF,EAAMH,GAE5BkC,EAAS7B,EAAII,OAAQJ,EAAK,GAe5B,SAAmB8B,EAAOC,GACzB,OAAOjC,EAAKwB,KAAM3B,EAASoC,EAC3B,KAdM/B,CAeR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index e5cc823..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From ed0e5c1bf2fed3324169f4d4866693f5c8bb696a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 8 Feb 2026 21:48:29 +0000 Subject: [PATCH 094/117] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 101 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 199 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 202 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 49 +- SECURITY.md | 5 - benchmark/benchmark.js | 341 -- benchmark/benchmark.length.bool.js | 97 - benchmark/benchmark.length.complex128.js | 98 - benchmark/benchmark.length.complex64.js | 98 - benchmark/benchmark.length.float32.js | 97 - benchmark/benchmark.length.float64.js | 97 - benchmark/benchmark.length.generic.js | 97 - benchmark/benchmark.length.int16.js | 97 - benchmark/benchmark.length.int32.js | 97 - benchmark/benchmark.length.int8.js | 97 - benchmark/benchmark.length.uint16.js | 97 - benchmark/benchmark.length.uint32.js | 97 - benchmark/benchmark.length.uint8.js | 97 - benchmark/benchmark.length.uint8c.js | 97 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 36 - dist/index.js.map | 7 - docs/repl.txt | 157 - docs/types/test.ts | 606 --- examples/index.js | 37 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 192 - lib/main.js | 416 -- package.json | 96 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 4397 ---------------- 56 files changed, 4870 insertions(+), 11256 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.length.bool.js delete mode 100644 benchmark/benchmark.length.complex128.js delete mode 100644 benchmark/benchmark.length.complex64.js delete mode 100644 benchmark/benchmark.length.float32.js delete mode 100644 benchmark/benchmark.length.float64.js delete mode 100644 benchmark/benchmark.length.generic.js delete mode 100644 benchmark/benchmark.length.int16.js delete mode 100644 benchmark/benchmark.length.int32.js delete mode 100644 benchmark/benchmark.length.int8.js delete mode 100644 benchmark/benchmark.length.uint16.js delete mode 100644 benchmark/benchmark.length.uint32.js delete mode 100644 benchmark/benchmark.length.uint8.js delete mode 100644 benchmark/benchmark.length.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 2d6aaee..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/contributing/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index f988046..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index b2c1f9c..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '42 6 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 83d50c4..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,821 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send notification to Zulip if job fails: - - name: 'Send notification to Zulip in case of failure' - # Pin action to full length commit SHA - uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 - if: failure() - with: - api-key: ${{ secrets.ZULIP_API_KEY }} - email: 'github-actions-bot@stdlib.zulipchat.com' - organization-url: 'https://stdlib.zulipchat.com' - to: 'workflows-standalone' - type: 'stream' - topic: ${{ github.event.repository.name }} - content: | - :cross_mark: **${{ github.workflow }}** workflow failed - - **Repository:** [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) - **Run:** [View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -278,7 +269,7 @@ for ( i = 0; i < dt.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -347,13 +338,13 @@ Copyright © 2016-2026. 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/dtypes]: https://github.com/stdlib-js/array-dtypes/tree/esm -[@stdlib/array/filled]: https://github.com/stdlib-js/array-filled +[@stdlib/array/filled]: https://github.com/stdlib-js/array-filled/tree/esm -[@stdlib/array/typed]: https://github.com/stdlib-js/array-typed +[@stdlib/array/typed]: https://github.com/stdlib-js/array-typed/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 17cfb5a..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,341 +0,0 @@ -/** -* @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 isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); -var isArray = require( '@stdlib/assert-is-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var Complex64 = require( '@stdlib/complex-float32-ctor' ); -var Complex128 = require( '@stdlib/complex-float64-ctor' ); -var pkg = require( './../package.json' ).name; -var filledarrayBy = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 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=float64', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'float64', 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=float32', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'float32', 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=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; - var i; - - clbk = constantFunction( new Complex128( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'complex128', 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=complex64', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( new Complex64( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'complex64', 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=int32', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int32', 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=uint32', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint32', 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=int16', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int16', 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=uint16', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint16', 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=int8', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int8', 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=uint8', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint8', 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=uint8c', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint8c', 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=generic', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'generic', clbk ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.length.bool.js b/benchmark/benchmark.length.bool.js deleted file mode 100644 index 3cdd152..0000000 --- a/benchmark/benchmark.length.bool.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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/benchmark/benchmark.length.complex128.js b/benchmark/benchmark.length.complex128.js deleted file mode 100644 index 122bc7c..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 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 Complex128 = require( '@stdlib/complex-float64-ctor' ); -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( new Complex128( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'complex128', 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=complex128,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.complex64.js b/benchmark/benchmark.length.complex64.js deleted file mode 100644 index e7a2d74..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 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 Complex64 = require( '@stdlib/complex-float32-ctor' ); -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( new Complex64( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'complex64', 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=complex64,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.float32.js b/benchmark/benchmark.length.float32.js deleted file mode 100644 index d2b2ba7..0000000 --- a/benchmark/benchmark.length.float32.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'float32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=float32,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.float64.js b/benchmark/benchmark.length.float64.js deleted file mode 100644 index 65064e3..0000000 --- a/benchmark/benchmark.length.float64.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'float64', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=float64,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.generic.js b/benchmark/benchmark.length.generic.js deleted file mode 100644 index eb87dfa..0000000 --- a/benchmark/benchmark.length.generic.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isArray = require( '@stdlib/assert-is-array' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'generic', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isArray( 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=generic,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int16.js b/benchmark/benchmark.length.int16.js deleted file mode 100644 index 914ff7c..0000000 --- a/benchmark/benchmark.length.int16.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int16', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=int16,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int32.js b/benchmark/benchmark.length.int32.js deleted file mode 100644 index cc0f678..0000000 --- a/benchmark/benchmark.length.int32.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=int32,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int8.js b/benchmark/benchmark.length.int8.js deleted file mode 100644 index 77553b0..0000000 --- a/benchmark/benchmark.length.int8.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int8', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=int8,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint16.js b/benchmark/benchmark.length.uint16.js deleted file mode 100644 index c68efdd..0000000 --- a/benchmark/benchmark.length.uint16.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint16', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint16,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint32.js b/benchmark/benchmark.length.uint32.js deleted file mode 100644 index 27c1742..0000000 --- a/benchmark/benchmark.length.uint32.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint32,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint8.js b/benchmark/benchmark.length.uint8.js deleted file mode 100644 index 2a26be4..0000000 --- a/benchmark/benchmark.length.uint8.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint8', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint8,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint8c.js b/benchmark/benchmark.length.uint8c.js deleted file mode 100644 index dd6e8c2..0000000 --- a/benchmark/benchmark.length.uint8c.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint8c', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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=uint8c,len='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index c138144..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by" -%% click B href "https://github.com/stdlib-js/array-filled-by/tree/main" -%% click C href "https://github.com/stdlib-js/array-filled-by/tree/production" -%% click D href "https://github.com/stdlib-js/array-filled-by/tree/esm" -%% click E href "https://github.com/stdlib-js/array-filled-by/tree/deno" -%% click F href "https://github.com/stdlib-js/array-filled-by/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by -[production-url]: https://github.com/stdlib-js/array-filled-by/tree/production -[deno-url]: https://github.com/stdlib-js/array-filled-by/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-filled-by/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-filled-by/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-filled-by/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-filled-by/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-filled-by/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 188fc9b..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import filledarrayBy from '../docs/types/index'; -export = filledarrayBy; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 65ae3db..0000000 --- a/dist/index.js +++ /dev/null @@ -1,36 +0,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 deleted file mode 100644 index b348e92..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "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 we 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,YACjDC,EAAuB,QAAS,uCAAwC,EAAE,YAC1EC,EAAoB,QAAS,+DAAgE,EAC7FC,EAAoB,QAAS,gDAAiD,EAC9EC,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,EAAQ,UAAU,OAGbA,IAAU,EACd,OAAAE,EAAOrB,EAAOS,CAAc,EACrB,IAAIY,EAAM,CAAE,EAIpB,GADAD,EAAQ,UAAW,CAAE,EAChB5B,EAAU4B,CAAM,EAAI,CAExB,GAAKD,EAAQ,EACZ,MAAM,IAAI,UAAW,2FAA4F,EAGlH,GADAE,EAAOrB,EAAOoB,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWd,EAAQ,sEAAuEa,CAAM,CAAE,EAG7G,OAAO,IAAIC,EAAM,CAAE,CACpB,CAEA,GAAKF,EAAQ,EACZ,MAAM,IAAI,UAAW,2FAA4F,EAMlH,GAHAA,GAAS,EAGJpB,EAAY,UAAWoB,CAAM,CAAE,EAEnC,GAAKpB,EAAY,UAAWoB,EAAM,CAAE,CAAE,GAMrC,GALAN,EAAU,UAAWM,CAAM,EAC3BA,GAAS,EACTP,EAAO,UAAWO,CAAM,EAGnBA,IAAU,EACd,MAAM,IAAI,UAAW,2FAA4F,OAIlHP,EAAO,UAAWO,CAAM,UAIhBA,GAAS,GAIlB,GAHAN,EAAU,UAAWM,CAAM,EAC3BA,GAAS,EACTP,EAAO,UAAWO,CAAM,EACnB,CAACpB,EAAYa,CAAK,EACtB,MAAM,IAAI,UAAWL,EAAQ,uEAAwEK,CAAK,CAAE,MAK7G,OAAM,IAAI,UAAW,2FAA4F,EAWlH,GARAO,GAAS,EACJA,GAAS,GAAK3B,EAAU,UAAW2B,CAAM,CAAE,GAC/CC,EAAQ,UAAWD,CAAM,EACzBA,GAAS,GAETC,EAAQX,EAETY,EAAOrB,EAAOoB,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWd,EAAQ,sEAAuEa,CAAM,CAAE,EAG7G,GAAKA,IAAU,UAAY,CAE1B,GADAG,EAAM,UAAW,CAAE,EACdJ,IAAU,EAAI,CAMlB,GALK1B,EAAsB8B,CAAI,EAC9BD,EAAMC,EACK3B,EAAc2B,CAAI,IAC7BD,EAAMC,EAAI,QAEND,IAAQ,OACZ,OAAOpB,EAAaoB,EAAKV,EAAMC,CAAQ,EAExC,GAAKhB,EAAe0B,CAAI,EACvB,MAAM,IAAI,MAAO,mFAAoF,EAEtG,GAAKzB,EAAUyB,CAAI,EAAI,CACtB,GAAKf,IAAwB,GAC5B,MAAM,IAAI,UAAWD,EAAQ,sIAAuIgB,CAAI,CAAE,EAE3K,GAAK,CAACxB,EAAYwB,EAAKnB,CAAgB,CAAE,EACxC,MAAM,IAAI,UAAWG,EAAQ,wGAAyGgB,CAAI,CAAE,EAG7I,GADAA,EAAMA,EAAKnB,CAAgB,EAAE,EACxB,CAACL,EAAYwB,EAAI,IAAK,EAC1B,MAAM,IAAI,UAAWhB,EAAQ,wGAAyGgB,CAAI,CAAE,EAE7I,OAAOb,EAAqBa,EAAKX,EAAMC,CAAQ,CAChD,CACA,MAAM,IAAI,UAAWN,EAAQ,wGAAyGgB,CAAI,CAAE,CAC7I,SAAY1B,EAAe0B,CAAI,EAC9B,MAAM,IAAI,MAAO,mFAAoF,EAEtG,MAAM,IAAI,UAAWhB,EAAQ,wGAAyGgB,CAAI,CAAE,CAC7I,CACA,GAAKJ,IAAU,EAEd,GADAI,EAAM,UAAW,CAAE,EACd3B,EAAc2B,CAAI,EACtBT,EAAM,IAAIO,EAAME,EAAI,MAAO,UAChB1B,EAAe0B,CAAI,EAC9BT,EAAM,IAAIO,EAAME,CAAI,UACT9B,EAAsB8B,CAAI,EACrCT,EAAM,IAAIO,EAAME,CAAI,UACTzB,EAAUyB,CAAI,EAAI,CAC7B,GAAKf,IAAwB,GAC5B,MAAM,IAAI,UAAWD,EAAQ,sIAAuIgB,CAAI,CAAE,EAE3K,GAAK,CAACxB,EAAYwB,EAAKnB,CAAgB,CAAE,EACxC,MAAM,IAAI,UAAWG,EAAQ,wGAAyGgB,CAAI,CAAE,EAG7I,GADAA,EAAMA,EAAKnB,CAAgB,EAAE,EACxB,CAACL,EAAYwB,EAAI,IAAK,EAC1B,MAAM,IAAI,UAAWhB,EAAQ,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,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 deleted file mode 100644 index 06f3146..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,157 +0,0 @@ - -{{alias}}( [dtype] ) - Creates a filled array. - - Parameters - ---------- - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr = {{alias}}() - - > arr = {{alias}}( 'float32' ) - - - -{{alias}}( length[, dtype], clbk[, thisArg] ) - Returns a filled array according to a provided callback function and having - a specified length. - - Parameters - ---------- - length: integer - Array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > function clbk() { return 1.0; }; - > var arr = {{alias}}( 5, clbk ) - [ 1.0, 1.0, 1.0, 1.0, 1.0 ] - > arr = {{alias}}( 5, 'int32', clbk ) - [ 1, 1, 1, 1, 1 ] - - -{{alias}}( array[, dtype], clbk[, thisArg] ) - Creates a filled array from another array (or array-like object) according - to a provided callback function. - - Parameters - ---------- - array: ArrayLikeObject - Array from which to generate another array. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias}}( [ 0.5, 0.5, 0.5 ], {{alias:@stdlib/utils/constant-function}}( 2.0 ) ) - [ 2.0, 2.0, 2.0 ] - > var arr2 = {{alias}}( arr1, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( iterable[, dtype], clbk[, thisArg] ) - Creates a filled array from an iterable according to a provided callback - function. - - Parameters - ---------- - iterable: Iterable - Iterable from which to generate an array. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias:@stdlib/iter/constant}}( 3.0, {'iter': 3} ); - > var arr2 = {{alias}}( arr1, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( buffer[, byteOffset[, length]][, dtype], clbk[, thisArg] ) - Returns a filled typed array view of an ArrayBuffer according to a provided - callback function. - - The 'generic' array data type is *not* supported. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( buf, 0, 4, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0, 1.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index bb876ed..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,606 +0,0 @@ -/* -* @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. -*/ - -/// - -import { IterableIterator } from '@stdlib/types/iter'; -import filledarrayBy = require( './index' ); - - -/** -* Returns an iterator protocol-compliant object. -* -* @returns iterator protocol-compliant object -*/ -function iterator(): IterableIterator { - const obj: IterableIterator = { - [Symbol.iterator]: iterator, - 'next': next - }; - return obj; -} - -/** -* Implements the iterator protocol `next` method. -* -* @returns iterator protocol-compliant object -*/ -function next(): any { - return { - 'value': 1.0, - 'done': false - }; -} - -/** -* Callback function. -* -* @param i - current array index -* @returns return value -*/ -function clbk( i: number ): number { - return i; -} - - -// TESTS // - -// The function returns an array or typed array... -{ - filledarrayBy(); // $ExpectType ArrayOrTypedArray - filledarrayBy( 'float32' ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( 10, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( 10, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( 10, 'int32', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( 10, 'int32', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const x = new Float64Array( 10 ); - filledarrayBy( x, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( x, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( x, 'uint8', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( x, 'uint8', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const y = [ 2.0, 2.0, 2.0 ]; - filledarrayBy( y, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( y, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( y, 'float64', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( y, 'float64', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const it = iterator(); - filledarrayBy( it, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( it, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( it, 'uint8c', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( it, 'uint8c', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const buf = new ArrayBuffer( 32 ); - filledarrayBy( buf, clbk ); // $ExpectType RealOrComplexTypedArray | BooleanArray - filledarrayBy( buf, clbk, {} ); // $ExpectType RealOrComplexTypedArray | BooleanArray - - filledarrayBy( buf, 'uint32', clbk ); // $ExpectType RealOrComplexTypedArray | BooleanArray - filledarrayBy( buf, 'uint32', clbk, {} ); // $ExpectType RealOrComplexTypedArray | BooleanArray - - filledarrayBy( buf, 8, clbk ); // $ExpectType RealOrComplexTypedArray | BooleanArray - filledarrayBy( buf, 8, clbk, {} ); // $ExpectType RealOrComplexTypedArray | BooleanArray - - filledarrayBy( buf, 8, 'uint16', clbk ); // $ExpectType RealOrComplexTypedArray | BooleanArray - filledarrayBy( buf, 8, 'uint16', clbk, {} ); // $ExpectType RealOrComplexTypedArray | BooleanArray - - filledarrayBy( buf, 8, 2, clbk ); // $ExpectType RealOrComplexTypedArray | BooleanArray - filledarrayBy( buf, 8, 2, clbk, {} ); // $ExpectType RealOrComplexTypedArray | BooleanArray - - filledarrayBy( buf, 8, 2, 'int16', clbk ); // $ExpectType RealOrComplexTypedArray | BooleanArray - filledarrayBy( buf, 8, 2, 'int16', clbk, {} ); // $ExpectType RealOrComplexTypedArray | BooleanArray -} - -// The compiler throws an error if a callback function argument is not a function... -{ - filledarrayBy( 'float64', '5' ); // $ExpectError - filledarrayBy( 'float64', 1.0 ); // $ExpectError - filledarrayBy( 'float64', false ); // $ExpectError - filledarrayBy( 'float64', true ); // $ExpectError - filledarrayBy( 'float64', null ); // $ExpectError - filledarrayBy( 'float64', undefined ); // $ExpectError - filledarrayBy( 'float64', [] ); // $ExpectError - filledarrayBy( 'float64', {} ); // $ExpectError - - filledarrayBy( 'float64', '5', {} ); // $ExpectError - filledarrayBy( 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( 'float64', false, {} ); // $ExpectError - filledarrayBy( 'float64', true, {} ); // $ExpectError - filledarrayBy( 'float64', null, {} ); // $ExpectError - filledarrayBy( 'float64', undefined, {} ); // $ExpectError - filledarrayBy( 'float64', [], {} ); // $ExpectError - filledarrayBy( 'float64', {}, {} ); // $ExpectError - - filledarrayBy( 10, '5' ); // $ExpectError - filledarrayBy( 10, 1.0 ); // $ExpectError - filledarrayBy( 10, false ); // $ExpectError - filledarrayBy( 10, true ); // $ExpectError - filledarrayBy( 10, null ); // $ExpectError - filledarrayBy( 10, undefined ); // $ExpectError - filledarrayBy( 10, [] ); // $ExpectError - filledarrayBy( 10, {} ); // $ExpectError - - filledarrayBy( 10, '5', {} ); // $ExpectError - filledarrayBy( 10, 1.0, {} ); // $ExpectError - filledarrayBy( 10, false, {} ); // $ExpectError - filledarrayBy( 10, true, {} ); // $ExpectError - filledarrayBy( 10, null, {} ); // $ExpectError - filledarrayBy( 10, undefined, {} ); // $ExpectError - filledarrayBy( 10, [], {} ); // $ExpectError - filledarrayBy( 10, {}, {} ); // $ExpectError - - filledarrayBy( 10, 'float64', '5' ); // $ExpectError - filledarrayBy( 10, 'float64', 1.0 ); // $ExpectError - filledarrayBy( 10, 'float64', false ); // $ExpectError - filledarrayBy( 10, 'float64', true ); // $ExpectError - filledarrayBy( 10, 'float64', null ); // $ExpectError - filledarrayBy( 10, 'float64', undefined ); // $ExpectError - filledarrayBy( 10, 'float64', [] ); // $ExpectError - filledarrayBy( 10, 'float64', {} ); // $ExpectError - - filledarrayBy( 10, 'float64', '5', {} ); // $ExpectError - filledarrayBy( 10, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( 10, 'float64', false, {} ); // $ExpectError - filledarrayBy( 10, 'float64', true, {} ); // $ExpectError - filledarrayBy( 10, 'float64', null, {} ); // $ExpectError - filledarrayBy( 10, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( 10, 'float64', [], {} ); // $ExpectError - filledarrayBy( 10, 'float64', {}, {} ); // $ExpectError - - const x = new Float64Array( 10 ); - filledarrayBy( x, '5' ); // $ExpectError - filledarrayBy( x, 1.0 ); // $ExpectError - filledarrayBy( x, false ); // $ExpectError - filledarrayBy( x, true ); // $ExpectError - filledarrayBy( x, null ); // $ExpectError - filledarrayBy( x, undefined ); // $ExpectError - filledarrayBy( x, [] ); // $ExpectError - filledarrayBy( x, {} ); // $ExpectError - - filledarrayBy( x, '5', {} ); // $ExpectError - filledarrayBy( x, 1.0, {} ); // $ExpectError - filledarrayBy( x, false, {} ); // $ExpectError - filledarrayBy( x, true, {} ); // $ExpectError - filledarrayBy( x, null, {} ); // $ExpectError - filledarrayBy( x, undefined, {} ); // $ExpectError - filledarrayBy( x, [], {} ); // $ExpectError - filledarrayBy( x, {}, {} ); // $ExpectError - - filledarrayBy( x, 'float64', '5' ); // $ExpectError - filledarrayBy( x, 'float64', 1.0 ); // $ExpectError - filledarrayBy( x, 'float64', false ); // $ExpectError - filledarrayBy( x, 'float64', true ); // $ExpectError - filledarrayBy( x, 'float64', null ); // $ExpectError - filledarrayBy( x, 'float64', undefined ); // $ExpectError - filledarrayBy( x, 'float64', [] ); // $ExpectError - filledarrayBy( x, 'float64', {} ); // $ExpectError - - filledarrayBy( x, 'float64', '5', {} ); // $ExpectError - filledarrayBy( x, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( x, 'float64', false, {} ); // $ExpectError - filledarrayBy( x, 'float64', true, {} ); // $ExpectError - filledarrayBy( x, 'float64', null, {} ); // $ExpectError - filledarrayBy( x, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( x, 'float64', [], {} ); // $ExpectError - filledarrayBy( x, 'float64', {}, {} ); // $ExpectError - - const y = [ 2.0, 2.0, 2.0 ]; - filledarrayBy( y, '5' ); // $ExpectError - filledarrayBy( y, 1.0 ); // $ExpectError - filledarrayBy( y, false ); // $ExpectError - filledarrayBy( y, true ); // $ExpectError - filledarrayBy( y, null ); // $ExpectError - filledarrayBy( y, undefined ); // $ExpectError - filledarrayBy( y, [] ); // $ExpectError - filledarrayBy( y, {} ); // $ExpectError - - filledarrayBy( y, '5', {} ); // $ExpectError - filledarrayBy( y, 1.0, {} ); // $ExpectError - filledarrayBy( y, false, {} ); // $ExpectError - filledarrayBy( y, true, {} ); // $ExpectError - filledarrayBy( y, null, {} ); // $ExpectError - filledarrayBy( y, undefined, {} ); // $ExpectError - filledarrayBy( y, [], {} ); // $ExpectError - filledarrayBy( y, {}, {} ); // $ExpectError - - filledarrayBy( y, 'float64', '5' ); // $ExpectError - filledarrayBy( y, 'float64', 1.0 ); // $ExpectError - filledarrayBy( y, 'float64', false ); // $ExpectError - filledarrayBy( y, 'float64', true ); // $ExpectError - filledarrayBy( y, 'float64', null ); // $ExpectError - filledarrayBy( y, 'float64', undefined ); // $ExpectError - filledarrayBy( y, 'float64', [] ); // $ExpectError - filledarrayBy( y, 'float64', {} ); // $ExpectError - - filledarrayBy( y, 'float64', '5', {} ); // $ExpectError - filledarrayBy( y, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( y, 'float64', false, {} ); // $ExpectError - filledarrayBy( y, 'float64', true, {} ); // $ExpectError - filledarrayBy( y, 'float64', null, {} ); // $ExpectError - filledarrayBy( y, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( y, 'float64', [], {} ); // $ExpectError - filledarrayBy( y, 'float64', {}, {} ); // $ExpectError - - const it = iterator(); - filledarrayBy( it, '5' ); // $ExpectError - filledarrayBy( it, 1.0 ); // $ExpectError - filledarrayBy( it, false ); // $ExpectError - filledarrayBy( it, true ); // $ExpectError - filledarrayBy( it, null ); // $ExpectError - filledarrayBy( it, undefined ); // $ExpectError - filledarrayBy( it, [] ); // $ExpectError - filledarrayBy( it, {} ); // $ExpectError - - filledarrayBy( it, '5', {} ); // $ExpectError - filledarrayBy( it, 1.0, {} ); // $ExpectError - filledarrayBy( it, false, {} ); // $ExpectError - filledarrayBy( it, true, {} ); // $ExpectError - filledarrayBy( it, null, {} ); // $ExpectError - filledarrayBy( it, undefined, {} ); // $ExpectError - filledarrayBy( it, [], {} ); // $ExpectError - filledarrayBy( it, {}, {} ); // $ExpectError - - filledarrayBy( it, 'float64', '5' ); // $ExpectError - filledarrayBy( it, 'float64', 1.0 ); // $ExpectError - filledarrayBy( it, 'float64', false ); // $ExpectError - filledarrayBy( it, 'float64', true ); // $ExpectError - filledarrayBy( it, 'float64', null ); // $ExpectError - filledarrayBy( it, 'float64', undefined ); // $ExpectError - filledarrayBy( it, 'float64', [] ); // $ExpectError - filledarrayBy( it, 'float64', {} ); // $ExpectError - - filledarrayBy( it, 'float64', '5', {} ); // $ExpectError - filledarrayBy( it, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( it, 'float64', false, {} ); // $ExpectError - filledarrayBy( it, 'float64', true, {} ); // $ExpectError - filledarrayBy( it, 'float64', null, {} ); // $ExpectError - filledarrayBy( it, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( it, 'float64', [], {} ); // $ExpectError - filledarrayBy( it, 'float64', {}, {} ); // $ExpectError - - const buf = new ArrayBuffer( 32 ); - filledarrayBy( buf, '5' ); // $ExpectError - filledarrayBy( buf, 1.0 ); // $ExpectError - filledarrayBy( buf, false ); // $ExpectError - filledarrayBy( buf, true ); // $ExpectError - filledarrayBy( buf, null ); // $ExpectError - filledarrayBy( buf, undefined ); // $ExpectError - filledarrayBy( buf, [] ); // $ExpectError - filledarrayBy( buf, {} ); // $ExpectError - - filledarrayBy( buf, '5', {} ); // $ExpectError - filledarrayBy( buf, 1.0, {} ); // $ExpectError - filledarrayBy( buf, false, {} ); // $ExpectError - filledarrayBy( buf, true, {} ); // $ExpectError - filledarrayBy( buf, null, {} ); // $ExpectError - filledarrayBy( buf, undefined, {} ); // $ExpectError - filledarrayBy( buf, [], {} ); // $ExpectError - filledarrayBy( buf, {}, {} ); // $ExpectError - - filledarrayBy( buf, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 'float64', false ); // $ExpectError - filledarrayBy( buf, 'float64', true ); // $ExpectError - filledarrayBy( buf, 'float64', null ); // $ExpectError - filledarrayBy( buf, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 'float64', {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5' ); // $ExpectError - filledarrayBy( buf, 8, 1.0 ); // $ExpectError - filledarrayBy( buf, 8, false ); // $ExpectError - filledarrayBy( buf, 8, true ); // $ExpectError - filledarrayBy( buf, 8, null ); // $ExpectError - filledarrayBy( buf, 8, undefined ); // $ExpectError - filledarrayBy( buf, 8, [] ); // $ExpectError - filledarrayBy( buf, 8, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, false, {} ); // $ExpectError - filledarrayBy( buf, 8, true, {} ); // $ExpectError - filledarrayBy( buf, 8, null, {} ); // $ExpectError - filledarrayBy( buf, 8, undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, [], {} ); // $ExpectError - filledarrayBy( buf, 8, {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 8, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 'float64', false ); // $ExpectError - filledarrayBy( buf, 8, 'float64', true ); // $ExpectError - filledarrayBy( buf, 8, 'float64', null ); // $ExpectError - filledarrayBy( buf, 8, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 8, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 8, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 8, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, '5' ); // $ExpectError - filledarrayBy( buf, 8, 2, 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 2, false ); // $ExpectError - filledarrayBy( buf, 8, 2, true ); // $ExpectError - filledarrayBy( buf, 8, 2, null ); // $ExpectError - filledarrayBy( buf, 8, 2, undefined ); // $ExpectError - filledarrayBy( buf, 8, 2, [] ); // $ExpectError - filledarrayBy( buf, 8, 2, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, false, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, true, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, null, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, [], {} ); // $ExpectError - filledarrayBy( buf, 8, 2, {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', false ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', true ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', null ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', {}, {} ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid length, typed array, array-like object, `ArrayBuffer`, or iterable argument... -{ - filledarrayBy( false, clbk ); // $ExpectError - filledarrayBy( true, clbk ); // $ExpectError - filledarrayBy( null, clbk ); // $ExpectError - filledarrayBy( {}, clbk ); // $ExpectError - - filledarrayBy( false, clbk, {} ); // $ExpectError - filledarrayBy( true, clbk, {} ); // $ExpectError - filledarrayBy( null, clbk, {} ); // $ExpectError - filledarrayBy( {}, clbk, {} ); // $ExpectError - - filledarrayBy( false, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 'float64', clbk ); // $ExpectError - - filledarrayBy( false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, clbk ); // $ExpectError - filledarrayBy( 1.0, 8, clbk ); // $ExpectError - filledarrayBy( false, 8, clbk ); // $ExpectError - filledarrayBy( true, 8, clbk ); // $ExpectError - filledarrayBy( null, 8, clbk ); // $ExpectError - filledarrayBy( undefined, 8, clbk ); // $ExpectError - filledarrayBy( [], 8, clbk ); // $ExpectError - filledarrayBy( {}, 8, clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, clbk ); // $ExpectError - - filledarrayBy( '5', 8, clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, clbk, {} ); // $ExpectError - filledarrayBy( false, 8, clbk, {} ); // $ExpectError - filledarrayBy( true, 8, clbk, {} ); // $ExpectError - filledarrayBy( null, 8, clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, clbk, {} ); // $ExpectError - filledarrayBy( [], 8, clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 'float64', clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( false, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( [], 8, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 'float64', clbk ); // $ExpectError - - filledarrayBy( '5', 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 2, clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 2, clbk ); // $ExpectError - filledarrayBy( false, 8, 2, clbk ); // $ExpectError - filledarrayBy( true, 8, 2, clbk ); // $ExpectError - filledarrayBy( null, 8, 2, clbk ); // $ExpectError - filledarrayBy( undefined, 8, 2, clbk ); // $ExpectError - filledarrayBy( [], 8, 2, clbk ); // $ExpectError - filledarrayBy( {}, 8, 2, clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, clbk ); // $ExpectError - - filledarrayBy( '5', 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( false, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( [], 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, 'float64', clbk ); // $ExpectError - - filledarrayBy( '5', 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a byte offset argument which is not a number... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, false, clbk ); // $ExpectError - filledarrayBy( buf, true, clbk ); // $ExpectError - filledarrayBy( buf, null, clbk ); // $ExpectError - filledarrayBy( buf, [], clbk ); // $ExpectError - filledarrayBy( buf, {}, clbk ); // $ExpectError - - filledarrayBy( buf, false, clbk, {} ); // $ExpectError - filledarrayBy( buf, true, clbk, {} ); // $ExpectError - filledarrayBy( buf, null, clbk, {} ); // $ExpectError - filledarrayBy( buf, [], clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, clbk, {} ); // $ExpectError - - filledarrayBy( buf, '5', 'float64', clbk ); // $ExpectError - filledarrayBy( buf, false, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, true, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, null, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, [], 'float64', clbk ); // $ExpectError - filledarrayBy( buf, {}, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, '5', 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( buf, false, 2, clbk ); // $ExpectError - filledarrayBy( buf, true, 2, clbk ); // $ExpectError - filledarrayBy( buf, null, 2, clbk ); // $ExpectError - filledarrayBy( buf, [], 2, clbk ); // $ExpectError - filledarrayBy( buf, {}, 2, clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, clbk ); // $ExpectError - - filledarrayBy( buf, false, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, clbk, {} ); // $ExpectError - - filledarrayBy( buf, '5', 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, false, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, true, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, null, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, undefined, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, [], 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, {}, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, '5', 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, false, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, undefined, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a view length argument which is not a number... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, 8, false, clbk ); // $ExpectError - filledarrayBy( buf, 8, true, clbk ); // $ExpectError - filledarrayBy( buf, 8, null, clbk ); // $ExpectError - filledarrayBy( buf, 8, [], clbk ); // $ExpectError - filledarrayBy( buf, 8, {}, clbk ); // $ExpectError - - filledarrayBy( buf, 8, false, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, true, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, null, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, [], clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, {}, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, clbk, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5', 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, false, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, true, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, null, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, [], 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, {}, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, 8, '5', 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, [], 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, {}, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided too many arguments... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, 8, 2, 'float64', 1, clbk, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 997a381..0000000 --- a/examples/index.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ).factory; -var dtypes = require( '@stdlib/array-typed-real-dtypes' ); -var filledarrayBy = require( './../lib' ); - -// Create a pseudorandom number generator: -var rand = discreteUniform( 0, 100 ); - -// Get a list of array data types: -var dt = dtypes(); - -// Generate filled arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = filledarrayBy( 10, dt[ i ], rand ); - console.log( arr ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 764e40e..cb63cd1 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, RealOrComplexTypedArray, BooleanArray, DataType } from '@stdlib/types/array'; import { IterableIterator } from '@stdlib/types/iter'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..92c5f77 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.3-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.3-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@v0.0.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.3-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.3-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.3-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-ctors@v0.3.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill-by@v0.2.2-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled-by@v0.2.3-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.2.3-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.3-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@v0.2.3-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.4.1-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";var v=f(),g=j.get("dtypes.default");function c(){var f,j,c,b,y,x,u,E;if(0===(j=arguments.length))return new(y=d(g))(0);if(r(c=arguments[0])){if(j>1)throw new TypeError(w("00h05"));if(null===(y=d(c)))throw new TypeError(w("00h2Y",c));return new y(0)}if(j<2)throw new TypeError(w("00h05"));if(h(arguments[j-=1]))if(h(arguments[j-1])){if(f=arguments[j],b=arguments[j-=1],0===j)throw new TypeError(w("00h05"))}else b=arguments[j];else{if(!(j>=2))throw new TypeError(w("00h05"));if(f=arguments[j],!h(b=arguments[j-=1]))throw new TypeError(w("00h2b",b))}if((j-=1)>=0&&r(arguments[j])?(c=arguments[j],j-=1):c=g,null===(y=d(c)))throw new TypeError(w("00h2Y",c));if("generic"===c){if(E=arguments[0],0===j){if(e(E)?u=E:i(E)&&(u=E.length),void 0!==u)return m(u,b,f);if(n(E))throw new Error(w("00h04"));if(o(E)){if(!1===v)throw new TypeError(w("00h2Z",E));if(!h(E[p]))throw new TypeError(w("00h2a",E));if(E=E[p](),!h(E.next))throw new TypeError(w("00h2a",E));return function(r,e,t){var s,i;for(s=[],i=-1;!r.next().done;)i+=1,s.push(e.call(t,i));return s}(E,b,f)}throw new TypeError(w("00h2a",E))}if(n(E))throw new Error(w("00h04"));throw new TypeError(w("00h2a",E))}if(0===j)if(i(E=arguments[0]))x=new y(E.length);else if(n(E))x=new y(E);else if(e(E))x=new y(E);else{if(!o(E))throw new TypeError(w("00h2a",E));if(!1===v)throw new TypeError(w("00h2Z",E));if(!h(E[p]))throw new TypeError(w("00h2a",E));if(E=E[p](),!h(E.next))throw new TypeError(w("00h2a",E));x=new y(a(E))}else x=1===j?new y(arguments[0],arguments[1]):new y(arguments[0],arguments[1],arguments[2]);return x.length>0&&(t(c)||s(c)?function(r,e,t){var s;for(s=0;s\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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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( format('00h05') );\n\t\t}\n\t\tctor = ctors( dtype );\n\t\tif ( ctor === null ) {\n\t\t\tthrow new TypeError( format( '00h2Y', 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( format('00h05') );\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( format('00h05') );\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( '00h2b', clbk ) );\n\t\t}\n\t}\n\t// If we 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( format('00h05') );\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( '00h2Y', 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( format('00h04') );\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( '00h2Z', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00h2a', 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( '00h2a', 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( '00h2a', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format('00h04') );\n\t\t}\n\t\tthrow new TypeError( format( '00h2a', 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( '00h2Z', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00h2a', 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( '00h2a', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00h2a', 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\nexport default filledarrayBy;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","DEFAULT_DTYPE","defaults","get","filledarrayBy","thisArg","nargs","dtype","clbk","ctor","arr","len","arg","arguments","length","ctors","isString","TypeError","format","isFunction","isNonNegativeInteger","isCollection","filledArray","isArrayBuffer","Error","isObject","ITERATOR_SYMBOL","next","it","i","done","push","call","filledArrayIterator","iterLength","isComplexDataType","isBooleanDataType","set","filledAccessors","gfillBy","value","aidx"],"mappings":";;sjDA0CA,IAAIA,EAAsBC,IACtBC,EAAgBC,EAASC,IAAK,kBA2MlC,SAASC,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAKJ,GAAe,KAHfN,EAAQO,UAAUC,QAKjB,OAAO,IADPL,EAAOM,EAAOd,IACG,GAIlB,GAAKe,EADLT,EAAQM,UAAW,IACM,CAExB,GAAKP,EAAQ,EACZ,MAAM,IAAIW,UAAWC,EAAO,UAG7B,GAAc,QADdT,EAAOM,EAAOR,IAEb,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,OAAO,IAAIE,EAAM,EACjB,CAED,GAAKH,EAAQ,EACZ,MAAM,IAAIW,UAAWC,EAAO,UAM7B,GAAKC,EAAYN,UAHjBP,GAAS,IAKR,GAAKa,EAAYN,UAAWP,EAAM,KAMjC,GALAD,EAAUQ,UAAWP,GAErBE,EAAOK,UADPP,GAAS,GAIM,IAAVA,EACJ,MAAM,IAAIW,UAAWC,EAAO,eAI7BV,EAAOK,UAAWP,OAIf,MAAKA,GAAS,GAUlB,MAAM,IAAIW,UAAWC,EAAO,UAN5B,GAHAb,EAAUQ,UAAWP,IAGfa,EADNX,EAAOK,UADPP,GAAS,IAGR,MAAM,IAAIW,UAAWC,EAAQ,QAASV,GAMvC,CAUD,IARAF,GAAS,IACK,GAAKU,EAAUH,UAAWP,KACvCC,EAAQM,UAAWP,GACnBA,GAAS,GAETC,EAAQN,EAGK,QADdQ,EAAOM,EAAOR,IAEb,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,GAAe,YAAVA,EAAsB,CAE1B,GADAK,EAAMC,UAAW,GACF,IAAVP,EAAc,CAMlB,GALKc,EAAsBR,GAC1BD,EAAMC,EACKS,EAAcT,KACzBD,EAAMC,EAAIE,aAEE,IAARH,EACJ,OAAOW,EAAaX,EAAKH,EAAMH,GAEhC,GAAKkB,EAAeX,GACnB,MAAM,IAAIY,MAAON,EAAO,UAEzB,GAAKO,EAAUb,GAAQ,CACtB,IAA6B,IAAxBb,EACJ,MAAM,IAAIkB,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAYP,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLP,EAAYP,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvC,OAvSJ,SAA8BgB,EAAIpB,EAAMH,GACvC,IAAIK,EACAmB,EAKJ,IAFAnB,EAAM,GACNmB,GAAK,GAEAD,EAAGD,OACAG,MAGPD,GAAK,EACLnB,EAAIqB,KAAMvB,EAAKwB,KAAM3B,EAASwB,IAE/B,OAAOnB,CACR,CAuRWuB,CAAqBrB,EAAKJ,EAAMH,EACvC,CACD,MAAM,IAAIY,UAAWC,EAAQ,QAASN,GACzC,CAAS,GAAKW,EAAeX,GAC1B,MAAM,IAAIY,MAAON,EAAO,UAEzB,MAAM,IAAID,UAAWC,EAAQ,QAASN,GACtC,CACD,GAAe,IAAVN,EAEJ,GAAKe,EADLT,EAAMC,UAAW,IAEhBH,EAAM,IAAID,EAAMG,EAAIE,aACd,GAAKS,EAAeX,GAC1BF,EAAM,IAAID,EAAMG,QACV,GAAKQ,EAAsBR,GACjCF,EAAM,IAAID,EAAMG,OACV,KAAKa,EAAUb,GAarB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAZtC,IAA6B,IAAxBb,EACJ,MAAM,IAAIkB,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAYP,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLP,EAAYP,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvCF,EAAM,IAAID,EAAMyB,EAAYtB,GAG5B,MAEDF,EADqB,IAAVJ,EACL,IAAIG,EAAMI,UAAU,GAAIA,UAAU,IAElC,IAAIJ,EAAMI,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKH,EAAII,OAAS,IACZqB,EAAmB5B,IAAW6B,EAAmB7B,GAjTxD,SAA0BG,EAAKF,EAAMH,GACpC,IAAIwB,EACJ,IAAMA,EAAI,EAAGA,EAAInB,EAAII,OAAQe,IAC5BnB,EAAI2B,IAAK7B,EAAKwB,KAAM3B,EAASwB,GAAKA,EAGpC,CA4SGS,CAAiB5B,EAAKF,EAAMH,GAE5BkC,EAAS7B,EAAII,OAAQJ,EAAK,GAe5B,SAAmB8B,EAAOC,GACzB,OAAOjC,EAAKwB,KAAM3B,EAASoC,EAC3B,KAdM/B,CAeR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d115cf0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,192 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -/** -* Create a filled array according to a provided callback function. -* -* @module @stdlib/array-filled-by -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* var arr = filledarrayBy(); -* // returns -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'generic', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( [ 0.5, 0.5 ], clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1; -* } -* -* var arr = filledarrayBy( [ 5, -3 ], 'int32', clbk ); -* // returns [ 1, 1 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk1() { -* return 10; -* } -* -* function clbk2() { -* return 1.0; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, clbk2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk1() { -* return 1.0; -* } -* -* function clbk2() { -* return 2; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, 'uint32', clbk2 ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 'float32', clbk ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, clbk ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, 'int32', clbk ); -* // returns [ 1, 1 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 32b6545..0000000 --- a/lib/main.js +++ /dev/null @@ -1,416 +0,0 @@ -/** -* @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 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' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var ctors = require( '@stdlib/array-ctors' ); -var gfillBy = require( '@stdlib/blas-ext-base-gfill-by' ); -var filledArray = require( '@stdlib/array-base-filled-by' ); -var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var iterLength = require( '@stdlib/iter-length' ); -var defaults = require( '@stdlib/array-defaults' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport(); -var DEFAULT_DTYPE = defaults.get( 'dtypes.default' ); - - -// FUNCTIONS // - -/** -* Creates a filled "generic" array from an iterator. -* -* @private -* @param {Iterable} it - iterator -* @param {Callback} clbk - callback function -* @param {*} thisArg - callback function execution context -* @returns {Array} filled array -*/ -function filledArrayIterator( it, clbk, thisArg ) { - var arr; - var i; - var v; - - arr = []; - i = -1; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - i += 1; - arr.push( clbk.call( thisArg, i ) ); - } - return arr; -} - -/** -* Fills an array exposing accessors for getting and setting array elements. -* -* @private -* @param {Collection} arr - input array -* @param {Callback} clbk - callback function -* @param {*} thisArg - callback function execution context -* @returns {Collection} input array -*/ -function filledAccessors( arr, clbk, thisArg ) { - var i; - for ( i = 0; i < arr.length; i++ ) { - arr.set( clbk.call( thisArg, i ), i ); - } - return arr; -} - - -// MAIN // - -/** -* Creates a filled array according to a provided callback function. -* -* @param {(NonNegativeInteger|TypedArray|ArrayLikeObject|ArrayBuffer|Iterable)} [arg] - a length, typed array, array-like object, buffer, or iterable -* @param {NonNegativeInteger} [byteOffset=0] - byte offset -* @param {NonNegativeInteger} [length] - view length -* @param {string} [dtype="float64"] - data type -* @param {Callback} [clbk] - callback to invoke -* @param {*} [thisArg] - callback execution context -* @throws {TypeError} must provide a recognized data type -* @throws {TypeError} must provide a length, typed array, array-like object, buffer, or iterable -* @throws {TypeError} callback argument must be a function. -* @throws {Error} creating a generic array from an `ArrayBuffer` is not supported -* @returns {(TypedArray|Array)} array or typed array -* -* @example -* var arr = filledarrayBy(); -* // returns -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'generic', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( [ 0.5, 0.5 ], clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1; -* } -* -* var arr = filledarrayBy( [ 5, -3 ], 'int32', clbk ); -* // returns [ 1, 1 ] -* -* @example -* function clbk1() { -* return 10; -* } -* -* function clbk2() { -* return 1.0; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, clbk2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk1() { -* return 1.0; -* } -* -* function clbk2() { -* return 2; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, 'uint32', clbk2 ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 'float32', clbk ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, clbk ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, 'int32', clbk ); -* // returns [ 1, 1 ] -*/ -function filledarrayBy() { - var thisArg; - var nargs; - var dtype; - var clbk; - var ctor; - var arr; - var len; - var arg; - - nargs = arguments.length; - - // If we weren't provided any arguments, return an empty array... - if ( nargs === 0 ) { - ctor = ctors( DEFAULT_DTYPE ); - return new ctor( 0 ); - } - // Check if we were provided a dtype as the first argument... - dtype = arguments[ 0 ]; - if ( isString( dtype ) ) { - // Invoking this function with arguments `f( dtype, clbk[, thisArg] )` is not allowed (otherwise, we'd need to also allow `f( clbk[, thisArg] )`)... - if ( nargs > 1 ) { - throw new TypeError( format('00h05') ); - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '00h2Y', dtype ) ); - } - // Return an empty array having the specified dtype: - return new ctor( 0 ); - } - // For all other supported invocations, we need at least two arguments... - if ( nargs < 2 ) { - throw new TypeError( format('00h05') ); - } - // At this point, we need to do some argument juggling... - nargs -= 1; // henceforth, the number of available arguments is `nargs+1` - - // Determine whether the last argument is a callback or "this" context... - if ( isFunction( arguments[ nargs ] ) ) { - // 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... - if ( isFunction( arguments[ nargs-1 ] ) ) { - thisArg = arguments[ nargs ]; - nargs -= 1; - clbk = arguments[ nargs ]; - - // Check if we were provided only a callback and a "this" context.. - if ( nargs === 0 ) { - throw new TypeError( format('00h05') ); - } - } else { - // "this" context is left undefined... - clbk = arguments[ nargs ]; - } - } - // 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... - else if ( nargs >= 2 ) { - thisArg = arguments[ nargs ]; - nargs -= 1; - clbk = arguments[ nargs ]; - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '00h2b', clbk ) ); - } - } - // If we were only provided 2 arguments and the last argument was not a function, we've been provided an insufficient number of arguments... - else { - throw new TypeError( format('00h05') ); - } - // Now that we've processed the callback arguments, let's continue working backward to see if we've been provided a `dtype` argument... - nargs -= 1; - if ( nargs >= 0 && isString( arguments[ nargs ] ) ) { - dtype = arguments[ nargs ]; - nargs -= 1; - } else { - dtype = DEFAULT_DTYPE; - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '00h2Y', dtype ) ); - } - // At this point, we've resolved the output array data type, and now we can actually create the output array... - if ( dtype === 'generic' ) { - arg = arguments[ 0 ]; - if ( nargs === 0 ) { - if ( isNonNegativeInteger( arg ) ) { - len = arg; - } else if ( isCollection( arg ) ) { - len = arg.length; - } - if ( len !== void 0 ) { - return filledArray( len, clbk, thisArg ); - } - if ( isArrayBuffer( arg ) ) { - throw new Error( format('00h04') ); - } - if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( '00h2Z', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00h2a', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00h2a', arg ) ); - } - return filledArrayIterator( arg, clbk, thisArg ); - } - throw new TypeError( format( '00h2a', arg ) ); - } else if ( isArrayBuffer( arg ) ) { - throw new Error( format('00h04') ); - } - throw new TypeError( format( '00h2a', arg ) ); - } - if ( nargs === 0 ) { // length || array-like || ArrayBuffer || iterable - arg = arguments[ 0 ]; - if ( isCollection( arg ) ) { - arr = new ctor( arg.length ); - } else if ( isArrayBuffer( arg ) ) { - arr = new ctor( arg ); - } else if ( isNonNegativeInteger( arg ) ) { - arr = new ctor( arg ); - } else if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( '00h2Z', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00h2a', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00h2a', arg ) ); - } - arr = new ctor( iterLength( arg ) ); - } else { - throw new TypeError( format( '00h2a', arg ) ); - } - } else if ( nargs === 1 ) { - arr = new ctor( arguments[0], arguments[1] ); // (ArrayBuffer, byteOffset) - } else { - arr = new ctor( arguments[0], arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset, length) - } - if ( arr.length > 0 ) { - if ( isComplexDataType( dtype ) || isBooleanDataType( dtype ) ) { - filledAccessors( arr, clbk, thisArg ); - } else { - gfillBy( arr.length, arr, 1, callback ); - } - } - return arr; - - /** - * Callback which wraps a provided callback and is invoked for each array element. - * - * @private - * @param {*} value - element value - * @param {NonNegativeInteger} aidx - array index - * @param {NonNegativeInteger} sidx - strided index - * @param {Collection} array - input array/collection - * @returns {*} callback return value - */ - function callback( value, aidx ) { - return clbk.call( thisArg, aidx ); - } -} - - -// EXPORTS // - -module.exports = filledarrayBy; diff --git a/package.json b/package.json index 0c2284a..026d062 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.3.1", "description": "Create a filled array according to a provided callback function.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,75 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-assert-is-boolean-data-type": "^0.0.2", - "@stdlib/array-base-assert-is-complex-floating-point-data-type": "^0.2.2", - "@stdlib/array-base-filled-by": "^0.2.3", - "@stdlib/array-ctors": "^0.3.1", - "@stdlib/array-defaults": "^0.4.1", - "@stdlib/assert-has-iterator-symbol-support": "^0.2.3", - "@stdlib/assert-is-arraybuffer": "^0.2.3", - "@stdlib/assert-is-collection": "^0.2.3", - "@stdlib/assert-is-function": "^0.2.3", - "@stdlib/assert-is-nonnegative-integer": "^0.2.3", - "@stdlib/assert-is-object": "^0.2.3", - "@stdlib/assert-is-string": "^0.2.3", - "@stdlib/blas-ext-base-gfill-by": "^0.2.3", - "@stdlib/iter-length": "^0.2.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3", - "@stdlib/symbol-iterator": "^0.2.3", - "@stdlib/types": "^0.4.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3" - }, - "devDependencies": { - "@stdlib/array-bool": "^0.1.2", - "@stdlib/array-buffer": "^0.2.3", - "@stdlib/array-complex128": "^0.3.2", - "@stdlib/array-complex64": "^0.3.2", - "@stdlib/array-float32": "^0.2.3", - "@stdlib/array-float64": "^0.2.3", - "@stdlib/array-int16": "^0.2.3", - "@stdlib/array-int32": "^0.2.3", - "@stdlib/array-int8": "^0.2.3", - "@stdlib/array-typed-real-dtypes": "^0.2.3", - "@stdlib/array-uint16": "^0.2.3", - "@stdlib/array-uint32": "^0.2.3", - "@stdlib/array-uint8": "^0.2.3", - "@stdlib/array-uint8c": "^0.2.3", - "@stdlib/assert-instance-of": "^0.3.1", - "@stdlib/assert-is-array": "^0.2.3", - "@stdlib/assert-is-typed-array": "^0.2.3", - "@stdlib/assert-is-typed-array-like": "^0.2.3", - "@stdlib/complex-float32-ctor": "^0.1.1", - "@stdlib/complex-float64-ctor": "^0.1.2", - "@stdlib/iter-constant": "^0.2.3", - "@stdlib/math-base-special-pow": "^0.3.1", - "@stdlib/random-base-discrete-uniform": "^0.2.1", - "@stdlib/strided-base-reinterpret-boolean": "^0.0.3", - "@stdlib/strided-base-reinterpret-complex128": "^0.2.3", - "@stdlib/strided-base-reinterpret-complex64": "^0.2.2", - "@stdlib/utils-constant-function": "^0.2.3", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.3" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..8f6a4e4 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index ca0cf25..0000000 --- a/test/test.js +++ /dev/null @@ -1,4397 +0,0 @@ -/** -* @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. -*/ - -/* eslint-disable max-len */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -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' ); -var iterConstant = require( '@stdlib/iter-constant' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var filledarrayBy = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': !hasIteratorSymbolSupport() -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof filledarrayBy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if only provided callback arguments', function test( t ) { - t.throws( clbk1, TypeError, 'throws an error' ); - t.throws( clbk2, TypeError, 'throws an error' ); - t.throws( clbk3, TypeError, 'throws an error' ); - t.end(); - - function clbk1() { - filledarrayBy( constantFunction( 1.0 ) ); - } - - function clbk2() { - filledarrayBy( constantFunction( 1.0 ), {} ); - } - - function clbk3() { - filledarrayBy( constantFunction( 1.0 ), constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (only argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (typed array; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (array-like object)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (array-like object; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 8 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 8 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, 1, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (iterator)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( iterConstant( 1.0 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (iterator; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( iterConstant( 1.0 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if only provided data type and callback arguments', function test( t ) { - t.throws( clbk1, TypeError, 'throws an error' ); - t.throws( clbk2, TypeError, 'throws an error' ); - t.throws( clbk3, TypeError, 'throws an error' ); - t.end(); - - function clbk1() { - filledarrayBy( 'float64', constantFunction( 1.0 ) ); - } - - function clbk2() { - filledarrayBy( 'float64', constantFunction( 1.0 ), {} ); - } - - function clbk3() { - filledarrayBy( 'float64', constantFunction( 1.0 ), constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (array-like object)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (array-like object; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, 1, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, 1, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (no iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (no iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (non-function iterator symbol property)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (non-function iterator symbol property; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (`next` property is not a function)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ) ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (`next` property is not a function; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ), {} ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (no iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (no iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (non-function iterator symbol property)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (non-function iterator symbol property; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (`next` property is not a function)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ) ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (`next` property is not a function; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ), {} ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 1, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 1, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function returns a filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - arr = filledarrayBy(); - - t.strictEqual( instanceOf( arr, Float64Array ), 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=float64)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - arr = filledarrayBy( 'float64' ); - - t.strictEqual( instanceOf( arr, Float64Array ), 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=float32)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( 0 ); - arr = filledarrayBy( 'float32' ); - - t.strictEqual( instanceOf( arr, Float32Array ), 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=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; - - expected = new Complex128Array( 0 ); - arr = filledarrayBy( 'complex128' ); - - t.strictEqual( instanceOf( arr, Complex128Array ), 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=complex64)', function test( t ) { - var expected; - var arr; - - expected = new Complex64Array( 0 ); - arr = filledarrayBy( 'complex64' ); - - t.strictEqual( instanceOf( arr, Complex64Array ), 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=int32)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( 0 ); - arr = filledarrayBy( 'int32' ); - - t.strictEqual( instanceOf( arr, Int32Array ), 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=uint32)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( 0 ); - arr = filledarrayBy( 'uint32' ); - - t.strictEqual( instanceOf( arr, Uint32Array ), 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=int16)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( 0 ); - arr = filledarrayBy( 'int16' ); - - t.strictEqual( instanceOf( arr, Int16Array ), 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=uint16)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( 0 ); - arr = filledarrayBy( 'uint16' ); - - t.strictEqual( instanceOf( arr, Uint16Array ), 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=int8)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( 0 ); - arr = filledarrayBy( 'int8' ); - - t.strictEqual( instanceOf( arr, Int8Array ), 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=uint8)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( 0 ); - arr = filledarrayBy( 'uint8' ); - - t.strictEqual( instanceOf( arr, Uint8Array ), 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=uint8c)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( 0 ); - arr = filledarrayBy( 'uint8c' ); - - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), 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=generic)', function test( t ) { - var expected; - var arr; - - expected = []; - arr = filledarrayBy( 'generic' ); - - t.strictEqual( instanceOf( arr, Array ), 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 (default, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, length=0)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array(); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 0, clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, clbk, ctx ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (default, length; thisArg=function)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, clbk, context ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this(); // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } - - function context() { - ctx.count += 1; - } -}); - -tape( 'the function returns a filled array (dtype=float64, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, 'float64', clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, length; thisArg=function)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, 'float64', clbk, context ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this(); // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } - - function context() { - ctx.count += 1; - } -}); - -tape( 'the function returns a filled array (dtype=float32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, 'float32', clbk ); - - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - 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; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = filledarrayBy( 5, 'complex128', clbk ); - - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = filledarrayBy( 5, 'complex64', clbk ); - - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int32Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int32', clbk ); - - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint32Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint32', clbk ); - - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int16Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int16', clbk ); - - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint16', clbk ); - - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int8Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int8', clbk ); - - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint8', clbk ); - - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint8c', clbk ); - - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = [ 1, 1, 1, 1, 1 ]; - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'generic', clbk ); - - t.strictEqual( instanceOf( arr, Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - 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; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = [ 1.0, 2.0 ]; - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = [ 1.0, 2.0 ]; - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int32', clbk ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, typed array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, typed array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - 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; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = new Float64Array( [ 1.0, 2.0 ] ); - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = new Float64Array( [ 1.0, 2.0 ] ); - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (default, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - 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; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer, byteoffset; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer, byteoffset; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - 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; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 48 ); - out = filledarrayBy( buf, 16, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 24 ); - out = filledarrayBy( buf, 8, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int32', clbk ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint8c', clbk ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - 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; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 64 ); - out = filledarrayBy( buf, 16, 2, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset, length)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 1, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 1, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled array (default, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, iterator; thisArg)', opts, function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - ctx = { - 'count': 0 - }; - indices = []; - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, iterator; thisArg)', opts, function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - ctx = { - 'count': 0 - }; - indices = []; - out = filledarrayBy( arr, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - 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; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = iterConstant( new Complex128( 3.0, 3.0 ), { - 'iter': 2 - }); - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = iterConstant( new Complex64( 3.0, 3.0 ), { - 'iter': 2 - }); - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); From 8628cfc20f2c4be81f7f1b38178ec17d5a3e9ef8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 8 Feb 2026 22:21:42 +0000 Subject: [PATCH 095/117] Update README.md for ESM bundle v0.3.1 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ad50331..d6a5f44 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import filledarrayBy from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-filled-by@esm/index.mjs'; +import filledarrayBy from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-filled-by@v0.3.1-esm/index.mjs'; ``` #### filledarrayBy( \[dtype] ) @@ -212,7 +212,7 @@ arr = filledarrayBy( buf, 10, 4, 'int16', clbk ); var discreteUniform = require( 'https://cdn.jsdelivr.net/gh/stdlib-js/random-base-discrete-uniform' ).factory; import dtypes from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-typed-real-dtypes@esm/index.mjs'; -import filledarrayBy from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-filled-by@esm/index.mjs'; +import filledarrayBy from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-filled-by@v0.3.1-esm/index.mjs'; // Create a pseudorandom number generator: var rand = discreteUniform( 0, 100 ); From d4daeda33e4d61ac7c853a8e8cf09d45a0f76421 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 8 Feb 2026 22:21:43 +0000 Subject: [PATCH 096/117] Auto-generated commit --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d6a5f44..41cff8e 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,11 @@ limitations under the License. ## Usage +```javascript +import filledarrayBy from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-filled-by@esm/index.mjs'; +``` +The previous example will load the latest bundled code from the esm branch. Alternatively, you may load a specific version by loading the file from one of the [tagged bundles](https://github.com/stdlib-js/array-filled-by/tags). For example, + ```javascript import filledarrayBy from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-filled-by@v0.3.1-esm/index.mjs'; ``` @@ -212,7 +217,7 @@ arr = filledarrayBy( buf, 10, 4, 'int16', clbk ); var discreteUniform = require( 'https://cdn.jsdelivr.net/gh/stdlib-js/random-base-discrete-uniform' ).factory; import dtypes from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-typed-real-dtypes@esm/index.mjs'; -import filledarrayBy from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-filled-by@v0.3.1-esm/index.mjs'; +import filledarrayBy from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-filled-by@esm/index.mjs'; // Create a pseudorandom number generator: var rand = discreteUniform( 0, 100 ); From ee8884865157137ed31900a069214c897509ad23 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 16 Feb 2026 19:29:01 +0000 Subject: [PATCH 097/117] Transform error messages --- lib/main.js | 38 +++++++++++++++++++------------------- package.json | 2 +- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/lib/main.js b/lib/main.js index d2128f5..32b6545 100644 --- a/lib/main.js +++ b/lib/main.js @@ -35,7 +35,7 @@ var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-supp var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); var iterLength = require( '@stdlib/iter-length' ); var defaults = require( '@stdlib/array-defaults' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -266,18 +266,18 @@ function filledarrayBy() { if ( isString( dtype ) ) { // Invoking this function with arguments `f( dtype, clbk[, thisArg] )` is not allowed (otherwise, we'd need to also allow `f( clbk[, thisArg] )`)... if ( nargs > 1 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format('00h05') ); } ctor = ctors( dtype ); if ( ctor === null ) { - throw new TypeError( format( 'invalid argument. Must provide a recognized data type. Value: `%s`.', dtype ) ); + throw new TypeError( format( '00h2Y', dtype ) ); } // Return an empty array having the specified dtype: return new ctor( 0 ); } // For all other supported invocations, we need at least two arguments... if ( nargs < 2 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format('00h05') ); } // At this point, we need to do some argument juggling... nargs -= 1; // henceforth, the number of available arguments is `nargs+1` @@ -292,7 +292,7 @@ function filledarrayBy() { // Check if we were provided only a callback and a "this" context.. if ( nargs === 0 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format('00h05') ); } } else { // "this" context is left undefined... @@ -305,12 +305,12 @@ function filledarrayBy() { nargs -= 1; clbk = arguments[ nargs ]; if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '00h2b', clbk ) ); } } // If we were only provided 2 arguments and the last argument was not a function, we've been provided an insufficient number of arguments... else { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format('00h05') ); } // Now that we've processed the callback arguments, let's continue working backward to see if we've been provided a `dtype` argument... nargs -= 1; @@ -322,7 +322,7 @@ function filledarrayBy() { } ctor = ctors( dtype ); if ( ctor === null ) { - throw new TypeError( format( 'invalid argument. Must provide a recognized data type. Value: `%s`.', dtype ) ); + throw new TypeError( format( '00h2Y', dtype ) ); } // At this point, we've resolved the output array data type, and now we can actually create the output array... if ( dtype === 'generic' ) { @@ -337,26 +337,26 @@ function filledarrayBy() { return filledArray( len, clbk, thisArg ); } if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format('00h04') ); } if ( isObject( arg ) ) { if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2Z', arg ) ); } if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } arg = arg[ ITERATOR_SYMBOL ](); if ( !isFunction( arg.next ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } return filledArrayIterator( arg, clbk, thisArg ); } - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } else if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format('00h04') ); } - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } if ( nargs === 0 ) { // length || array-like || ArrayBuffer || iterable arg = arguments[ 0 ]; @@ -368,18 +368,18 @@ function filledarrayBy() { arr = new ctor( arg ); } else if ( isObject( arg ) ) { if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2Z', arg ) ); } if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } arg = arg[ ITERATOR_SYMBOL ](); if ( !isFunction( arg.next ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } arr = new ctor( iterLength( arg ) ); } else { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } } else if ( nargs === 1 ) { arr = new ctor( arguments[0], arguments[1] ); // (ArrayBuffer, byteOffset) diff --git a/package.json b/package.json index 0edfb95..ecbe58e 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "@stdlib/assert-is-string": "^0.2.3", "@stdlib/blas-ext-base-gfill-by": "^0.2.3", "@stdlib/iter-length": "^0.2.3", - "@stdlib/string-format": "^0.2.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.3", "@stdlib/symbol-iterator": "^0.2.3", "@stdlib/types": "^0.4.3", "@stdlib/error-tools-fmtprodmsg": "^0.2.3" From c281e4b9fb7beca8288b29773080408eabf3ac72 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 16 Feb 2026 19:30:15 +0000 Subject: [PATCH 098/117] Remove files --- index.d.ts | 322 ---- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5169 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index cb63cd1..0000000 --- a/index.d.ts +++ /dev/null @@ -1,322 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, RealOrComplexTypedArray, BooleanArray, DataType } from '@stdlib/types/array'; -import { IterableIterator } from '@stdlib/types/iter'; - -/** -* Array or typed array. -*/ -type ArrayOrTypedArray = Array | RealOrComplexTypedArray | BooleanArray; - -/** -* Nullary callback function. -* -* @returns fill value -*/ -type Nullary = () => any; - -/** -* Unary callback function. -* -* @param i - current array index -* @returns fill value -*/ -type Unary = ( i: number ) => any; - -/** -* Callback function. -* -* @param i - current array index -* @returns fill value -*/ -type Callback = Nullary | Unary; - -/** -* Creates a filled array according to a provided callback function and having a specified data type. -* -* @param dtype - data type -* @returns filled array -* -* @example -* var arr = filledarrayBy(); -* // returns -* -* @example -* var arr = filledarrayBy( 'float32' ); -* // returns -*/ -declare function filledarrayBy( dtype?: DataType ): ArrayOrTypedArray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Creates a filled array according to a provided callback function and having a specified `length`. -* -* @param length - array length -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* -* var arr = filledarrayBy( 5, constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( length: number, clbk: Callback, thisArg?: any ): ArrayOrTypedArray; - -/** -* Creates a filled array according to a provided callback function and having a specified `length`. -* -* @param length - array length -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* -* var arr = filledarrayBy( 5, 'float64', constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( length: number, dtype: DataType, clbk: Callback, thisArg?: any ): ArrayOrTypedArray; - -/** -* Creates a filled array from another `array` according to a provided callback function. -* -* @param array - typed array or array-like object -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* -* 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; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Creates a filled array from another `array` according to a provided callback function. -* -* @param array - typed array or array-like object -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* -* 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; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Creates a filled array from an iterable according to a callback function. -* -* @param iterable - iterable -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var iterConstant = require( '@stdlib/iter-constant' ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarrayBy( it, constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( iterable: IterableIterator, clbk: Callback, thisArg?: any ): ArrayOrTypedArray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Creates a filled array from an iterable according to a callback function. -* -* @param iterable - iterable -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var iterConstant = require( '@stdlib/iter-constant' ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarrayBy( it, 'float64', constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( iterable: IterableIterator, dtype: DataType, clbk: 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. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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 | BooleanArray; - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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 | BooleanArray; - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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 | BooleanArray; - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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 | BooleanArray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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 | BooleanArray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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 | BooleanArray; // eslint-disable-line @typescript-eslint/unified-signatures - - -// EXPORTS // - -export = filledarrayBy; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 92c5f77..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.3-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.3-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@v0.0.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.3-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.3-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.3-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-ctors@v0.3.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill-by@v0.2.2-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled-by@v0.2.3-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.2.3-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.3-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@v0.2.3-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.4.1-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";var v=f(),g=j.get("dtypes.default");function c(){var f,j,c,b,y,x,u,E;if(0===(j=arguments.length))return new(y=d(g))(0);if(r(c=arguments[0])){if(j>1)throw new TypeError(w("00h05"));if(null===(y=d(c)))throw new TypeError(w("00h2Y",c));return new y(0)}if(j<2)throw new TypeError(w("00h05"));if(h(arguments[j-=1]))if(h(arguments[j-1])){if(f=arguments[j],b=arguments[j-=1],0===j)throw new TypeError(w("00h05"))}else b=arguments[j];else{if(!(j>=2))throw new TypeError(w("00h05"));if(f=arguments[j],!h(b=arguments[j-=1]))throw new TypeError(w("00h2b",b))}if((j-=1)>=0&&r(arguments[j])?(c=arguments[j],j-=1):c=g,null===(y=d(c)))throw new TypeError(w("00h2Y",c));if("generic"===c){if(E=arguments[0],0===j){if(e(E)?u=E:i(E)&&(u=E.length),void 0!==u)return m(u,b,f);if(n(E))throw new Error(w("00h04"));if(o(E)){if(!1===v)throw new TypeError(w("00h2Z",E));if(!h(E[p]))throw new TypeError(w("00h2a",E));if(E=E[p](),!h(E.next))throw new TypeError(w("00h2a",E));return function(r,e,t){var s,i;for(s=[],i=-1;!r.next().done;)i+=1,s.push(e.call(t,i));return s}(E,b,f)}throw new TypeError(w("00h2a",E))}if(n(E))throw new Error(w("00h04"));throw new TypeError(w("00h2a",E))}if(0===j)if(i(E=arguments[0]))x=new y(E.length);else if(n(E))x=new y(E);else if(e(E))x=new y(E);else{if(!o(E))throw new TypeError(w("00h2a",E));if(!1===v)throw new TypeError(w("00h2Z",E));if(!h(E[p]))throw new TypeError(w("00h2a",E));if(E=E[p](),!h(E.next))throw new TypeError(w("00h2a",E));x=new y(a(E))}else x=1===j?new y(arguments[0],arguments[1]):new y(arguments[0],arguments[1],arguments[2]);return x.length>0&&(t(c)||s(c)?function(r,e,t){var s;for(s=0;s\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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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( format('00h05') );\n\t\t}\n\t\tctor = ctors( dtype );\n\t\tif ( ctor === null ) {\n\t\t\tthrow new TypeError( format( '00h2Y', 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( format('00h05') );\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( format('00h05') );\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( '00h2b', clbk ) );\n\t\t}\n\t}\n\t// If we 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( format('00h05') );\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( '00h2Y', 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( format('00h04') );\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( '00h2Z', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00h2a', 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( '00h2a', 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( '00h2a', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format('00h04') );\n\t\t}\n\t\tthrow new TypeError( format( '00h2a', 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( '00h2Z', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00h2a', 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( '00h2a', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00h2a', 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\nexport default filledarrayBy;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","DEFAULT_DTYPE","defaults","get","filledarrayBy","thisArg","nargs","dtype","clbk","ctor","arr","len","arg","arguments","length","ctors","isString","TypeError","format","isFunction","isNonNegativeInteger","isCollection","filledArray","isArrayBuffer","Error","isObject","ITERATOR_SYMBOL","next","it","i","done","push","call","filledArrayIterator","iterLength","isComplexDataType","isBooleanDataType","set","filledAccessors","gfillBy","value","aidx"],"mappings":";;sjDA0CA,IAAIA,EAAsBC,IACtBC,EAAgBC,EAASC,IAAK,kBA2MlC,SAASC,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAKJ,GAAe,KAHfN,EAAQO,UAAUC,QAKjB,OAAO,IADPL,EAAOM,EAAOd,IACG,GAIlB,GAAKe,EADLT,EAAQM,UAAW,IACM,CAExB,GAAKP,EAAQ,EACZ,MAAM,IAAIW,UAAWC,EAAO,UAG7B,GAAc,QADdT,EAAOM,EAAOR,IAEb,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,OAAO,IAAIE,EAAM,EACjB,CAED,GAAKH,EAAQ,EACZ,MAAM,IAAIW,UAAWC,EAAO,UAM7B,GAAKC,EAAYN,UAHjBP,GAAS,IAKR,GAAKa,EAAYN,UAAWP,EAAM,KAMjC,GALAD,EAAUQ,UAAWP,GAErBE,EAAOK,UADPP,GAAS,GAIM,IAAVA,EACJ,MAAM,IAAIW,UAAWC,EAAO,eAI7BV,EAAOK,UAAWP,OAIf,MAAKA,GAAS,GAUlB,MAAM,IAAIW,UAAWC,EAAO,UAN5B,GAHAb,EAAUQ,UAAWP,IAGfa,EADNX,EAAOK,UADPP,GAAS,IAGR,MAAM,IAAIW,UAAWC,EAAQ,QAASV,GAMvC,CAUD,IARAF,GAAS,IACK,GAAKU,EAAUH,UAAWP,KACvCC,EAAQM,UAAWP,GACnBA,GAAS,GAETC,EAAQN,EAGK,QADdQ,EAAOM,EAAOR,IAEb,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,GAAe,YAAVA,EAAsB,CAE1B,GADAK,EAAMC,UAAW,GACF,IAAVP,EAAc,CAMlB,GALKc,EAAsBR,GAC1BD,EAAMC,EACKS,EAAcT,KACzBD,EAAMC,EAAIE,aAEE,IAARH,EACJ,OAAOW,EAAaX,EAAKH,EAAMH,GAEhC,GAAKkB,EAAeX,GACnB,MAAM,IAAIY,MAAON,EAAO,UAEzB,GAAKO,EAAUb,GAAQ,CACtB,IAA6B,IAAxBb,EACJ,MAAM,IAAIkB,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAYP,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLP,EAAYP,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvC,OAvSJ,SAA8BgB,EAAIpB,EAAMH,GACvC,IAAIK,EACAmB,EAKJ,IAFAnB,EAAM,GACNmB,GAAK,GAEAD,EAAGD,OACAG,MAGPD,GAAK,EACLnB,EAAIqB,KAAMvB,EAAKwB,KAAM3B,EAASwB,IAE/B,OAAOnB,CACR,CAuRWuB,CAAqBrB,EAAKJ,EAAMH,EACvC,CACD,MAAM,IAAIY,UAAWC,EAAQ,QAASN,GACzC,CAAS,GAAKW,EAAeX,GAC1B,MAAM,IAAIY,MAAON,EAAO,UAEzB,MAAM,IAAID,UAAWC,EAAQ,QAASN,GACtC,CACD,GAAe,IAAVN,EAEJ,GAAKe,EADLT,EAAMC,UAAW,IAEhBH,EAAM,IAAID,EAAMG,EAAIE,aACd,GAAKS,EAAeX,GAC1BF,EAAM,IAAID,EAAMG,QACV,GAAKQ,EAAsBR,GACjCF,EAAM,IAAID,EAAMG,OACV,KAAKa,EAAUb,GAarB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAZtC,IAA6B,IAAxBb,EACJ,MAAM,IAAIkB,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAYP,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLP,EAAYP,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvCF,EAAM,IAAID,EAAMyB,EAAYtB,GAG5B,MAEDF,EADqB,IAAVJ,EACL,IAAIG,EAAMI,UAAU,GAAIA,UAAU,IAElC,IAAIJ,EAAMI,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKH,EAAII,OAAS,IACZqB,EAAmB5B,IAAW6B,EAAmB7B,GAjTxD,SAA0BG,EAAKF,EAAMH,GACpC,IAAIwB,EACJ,IAAMA,EAAI,EAAGA,EAAInB,EAAII,OAAQe,IAC5BnB,EAAI2B,IAAK7B,EAAKwB,KAAM3B,EAASwB,GAAKA,EAGpC,CA4SGS,CAAiB5B,EAAKF,EAAMH,GAE5BkC,EAAS7B,EAAII,OAAQJ,EAAK,GAe5B,SAAmB8B,EAAOC,GACzB,OAAOjC,EAAKwB,KAAM3B,EAASoC,EAC3B,KAdM/B,CAeR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 8f6a4e4..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 366e4f61c235630701f1353223f9bd011346585c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 16 Feb 2026 19:30:43 +0000 Subject: [PATCH 099/117] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 101 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 199 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 236 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 49 +- SECURITY.md | 5 - benchmark/benchmark.js | 342 -- benchmark/benchmark.length.bool.js | 98 - benchmark/benchmark.length.complex128.js | 99 - benchmark/benchmark.length.complex64.js | 99 - benchmark/benchmark.length.float32.js | 98 - benchmark/benchmark.length.float64.js | 98 - benchmark/benchmark.length.generic.js | 98 - benchmark/benchmark.length.int16.js | 98 - benchmark/benchmark.length.int32.js | 98 - benchmark/benchmark.length.int8.js | 98 - benchmark/benchmark.length.uint16.js | 98 - benchmark/benchmark.length.uint32.js | 98 - benchmark/benchmark.length.uint8.js | 98 - benchmark/benchmark.length.uint8c.js | 98 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 36 - dist/index.js.map | 7 - docs/repl.txt | 157 - docs/types/test.ts | 606 --- examples/index.js | 37 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 192 - lib/main.js | 416 -- package.json | 96 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 4397 ---------------- 56 files changed, 4870 insertions(+), 11304 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.length.bool.js delete mode 100644 benchmark/benchmark.length.complex128.js delete mode 100644 benchmark/benchmark.length.complex64.js delete mode 100644 benchmark/benchmark.length.float32.js delete mode 100644 benchmark/benchmark.length.float64.js delete mode 100644 benchmark/benchmark.length.generic.js delete mode 100644 benchmark/benchmark.length.int16.js delete mode 100644 benchmark/benchmark.length.int32.js delete mode 100644 benchmark/benchmark.length.int8.js delete mode 100644 benchmark/benchmark.length.uint16.js delete mode 100644 benchmark/benchmark.length.uint32.js delete mode 100644 benchmark/benchmark.length.uint8.js delete mode 100644 benchmark/benchmark.length.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 2d6aaee..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/contributing/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index f988046..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index b2c1f9c..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '42 6 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 83d50c4..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,821 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send notification to Zulip if job fails: - - name: 'Send notification to Zulip in case of failure' - # Pin action to full length commit SHA - uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 - if: failure() - with: - api-key: ${{ secrets.ZULIP_API_KEY }} - email: 'github-actions-bot@stdlib.zulipchat.com' - organization-url: 'https://stdlib.zulipchat.com' - to: 'workflows-standalone' - type: 'stream' - topic: ${{ github.event.repository.name }} - content: | - :cross_mark: **${{ github.workflow }}** workflow failed - - **Repository:** [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) - **Run:** [View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -278,7 +269,7 @@ for ( i = 0; i < dt.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -347,13 +338,13 @@ Copyright © 2016-2026. 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/dtypes]: https://github.com/stdlib-js/array-dtypes/tree/esm -[@stdlib/array/filled]: https://github.com/stdlib-js/array-filled +[@stdlib/array/filled]: https://github.com/stdlib-js/array-filled/tree/esm -[@stdlib/array/typed]: https://github.com/stdlib-js/array-typed +[@stdlib/array/typed]: https://github.com/stdlib-js/array-typed/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 6fba606..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,342 +0,0 @@ -/** -* @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 isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); -var isArray = require( '@stdlib/assert-is-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var Complex64 = require( '@stdlib/complex-float32-ctor' ); -var Complex128 = require( '@stdlib/complex-float64-ctor' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var filledarrayBy = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 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( format( '%s:dtype=float64', pkg ), function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'float64', 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( format( '%s:dtype=float32', pkg ), function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'float32', 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( format( '%s:dtype=bool', pkg ), 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( format( '%s:dtype=complex128', pkg ), function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( new Complex128( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'complex128', 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( format( '%s:dtype=complex64', pkg ), function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( new Complex64( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'complex64', 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( format( '%s:dtype=int32', pkg ), function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int32', 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( format( '%s:dtype=uint32', pkg ), function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint32', 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( format( '%s:dtype=int16', pkg ), function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int16', 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( format( '%s:dtype=uint16', pkg ), function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint16', 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( format( '%s:dtype=int8', pkg ), function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int8', 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( format( '%s:dtype=uint8', pkg ), function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint8', 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( format( '%s:dtype=uint8c', pkg ), function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint8c', 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( format( '%s:dtype=generic', pkg ), function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'generic', clbk ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.length.bool.js b/benchmark/benchmark.length.bool.js deleted file mode 100644 index 52b3237..0000000 --- a/benchmark/benchmark.length.bool.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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 format = require( '@stdlib/string-format' ); -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( format( '%s:dtype=bool,len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.complex128.js b/benchmark/benchmark.length.complex128.js deleted file mode 100644 index 63c0843..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,99 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 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 Complex128 = require( '@stdlib/complex-float64-ctor' ); -var format = require( '@stdlib/string-format' ); -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( new Complex128( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'complex128', 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( format( '%s:dtype=complex128,len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.complex64.js b/benchmark/benchmark.length.complex64.js deleted file mode 100644 index 186f811..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,99 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 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 Complex64 = require( '@stdlib/complex-float32-ctor' ); -var format = require( '@stdlib/string-format' ); -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( new Complex64( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'complex64', 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( format( '%s:dtype=complex64,len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.float32.js b/benchmark/benchmark.length.float32.js deleted file mode 100644 index 5ba3130..0000000 --- a/benchmark/benchmark.length.float32.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/string-format' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'float32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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( format( '%s:dtype=float32,len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.float64.js b/benchmark/benchmark.length.float64.js deleted file mode 100644 index 4a2be6c..0000000 --- a/benchmark/benchmark.length.float64.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/string-format' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'float64', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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( format( '%s:dtype=float64,len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.generic.js b/benchmark/benchmark.length.generic.js deleted file mode 100644 index 6522748..0000000 --- a/benchmark/benchmark.length.generic.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isArray = require( '@stdlib/assert-is-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/string-format' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'generic', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isArray( 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( format( '%s:dtype=generic,len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int16.js b/benchmark/benchmark.length.int16.js deleted file mode 100644 index 9ac94e9..0000000 --- a/benchmark/benchmark.length.int16.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/string-format' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int16', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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( format( '%s:dtype=int16,len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int32.js b/benchmark/benchmark.length.int32.js deleted file mode 100644 index a5ce4d0..0000000 --- a/benchmark/benchmark.length.int32.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/string-format' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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( format( '%s:dtype=int32,len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int8.js b/benchmark/benchmark.length.int8.js deleted file mode 100644 index 6104616..0000000 --- a/benchmark/benchmark.length.int8.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/string-format' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int8', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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( format( '%s:dtype=int8,len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint16.js b/benchmark/benchmark.length.uint16.js deleted file mode 100644 index 3108633..0000000 --- a/benchmark/benchmark.length.uint16.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/string-format' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint16', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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( format( '%s:dtype=uint16,len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint32.js b/benchmark/benchmark.length.uint32.js deleted file mode 100644 index 602e232..0000000 --- a/benchmark/benchmark.length.uint32.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/string-format' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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( format( '%s:dtype=uint32,len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint8.js b/benchmark/benchmark.length.uint8.js deleted file mode 100644 index 8664da3..0000000 --- a/benchmark/benchmark.length.uint8.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/string-format' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint8', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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( format( '%s:dtype=uint8,len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint8c.js b/benchmark/benchmark.length.uint8c.js deleted file mode 100644 index 76645b9..0000000 --- a/benchmark/benchmark.length.uint8c.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/string-format' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint8c', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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( format( '%s:dtype=uint8c,len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index c138144..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by" -%% click B href "https://github.com/stdlib-js/array-filled-by/tree/main" -%% click C href "https://github.com/stdlib-js/array-filled-by/tree/production" -%% click D href "https://github.com/stdlib-js/array-filled-by/tree/esm" -%% click E href "https://github.com/stdlib-js/array-filled-by/tree/deno" -%% click F href "https://github.com/stdlib-js/array-filled-by/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by -[production-url]: https://github.com/stdlib-js/array-filled-by/tree/production -[deno-url]: https://github.com/stdlib-js/array-filled-by/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-filled-by/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-filled-by/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-filled-by/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-filled-by/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-filled-by/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 188fc9b..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import filledarrayBy from '../docs/types/index'; -export = filledarrayBy; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 65ae3db..0000000 --- a/dist/index.js +++ /dev/null @@ -1,36 +0,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 deleted file mode 100644 index b348e92..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "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 we 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,YACjDC,EAAuB,QAAS,uCAAwC,EAAE,YAC1EC,EAAoB,QAAS,+DAAgE,EAC7FC,EAAoB,QAAS,gDAAiD,EAC9EC,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,EAAQ,UAAU,OAGbA,IAAU,EACd,OAAAE,EAAOrB,EAAOS,CAAc,EACrB,IAAIY,EAAM,CAAE,EAIpB,GADAD,EAAQ,UAAW,CAAE,EAChB5B,EAAU4B,CAAM,EAAI,CAExB,GAAKD,EAAQ,EACZ,MAAM,IAAI,UAAW,2FAA4F,EAGlH,GADAE,EAAOrB,EAAOoB,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWd,EAAQ,sEAAuEa,CAAM,CAAE,EAG7G,OAAO,IAAIC,EAAM,CAAE,CACpB,CAEA,GAAKF,EAAQ,EACZ,MAAM,IAAI,UAAW,2FAA4F,EAMlH,GAHAA,GAAS,EAGJpB,EAAY,UAAWoB,CAAM,CAAE,EAEnC,GAAKpB,EAAY,UAAWoB,EAAM,CAAE,CAAE,GAMrC,GALAN,EAAU,UAAWM,CAAM,EAC3BA,GAAS,EACTP,EAAO,UAAWO,CAAM,EAGnBA,IAAU,EACd,MAAM,IAAI,UAAW,2FAA4F,OAIlHP,EAAO,UAAWO,CAAM,UAIhBA,GAAS,GAIlB,GAHAN,EAAU,UAAWM,CAAM,EAC3BA,GAAS,EACTP,EAAO,UAAWO,CAAM,EACnB,CAACpB,EAAYa,CAAK,EACtB,MAAM,IAAI,UAAWL,EAAQ,uEAAwEK,CAAK,CAAE,MAK7G,OAAM,IAAI,UAAW,2FAA4F,EAWlH,GARAO,GAAS,EACJA,GAAS,GAAK3B,EAAU,UAAW2B,CAAM,CAAE,GAC/CC,EAAQ,UAAWD,CAAM,EACzBA,GAAS,GAETC,EAAQX,EAETY,EAAOrB,EAAOoB,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWd,EAAQ,sEAAuEa,CAAM,CAAE,EAG7G,GAAKA,IAAU,UAAY,CAE1B,GADAG,EAAM,UAAW,CAAE,EACdJ,IAAU,EAAI,CAMlB,GALK1B,EAAsB8B,CAAI,EAC9BD,EAAMC,EACK3B,EAAc2B,CAAI,IAC7BD,EAAMC,EAAI,QAEND,IAAQ,OACZ,OAAOpB,EAAaoB,EAAKV,EAAMC,CAAQ,EAExC,GAAKhB,EAAe0B,CAAI,EACvB,MAAM,IAAI,MAAO,mFAAoF,EAEtG,GAAKzB,EAAUyB,CAAI,EAAI,CACtB,GAAKf,IAAwB,GAC5B,MAAM,IAAI,UAAWD,EAAQ,sIAAuIgB,CAAI,CAAE,EAE3K,GAAK,CAACxB,EAAYwB,EAAKnB,CAAgB,CAAE,EACxC,MAAM,IAAI,UAAWG,EAAQ,wGAAyGgB,CAAI,CAAE,EAG7I,GADAA,EAAMA,EAAKnB,CAAgB,EAAE,EACxB,CAACL,EAAYwB,EAAI,IAAK,EAC1B,MAAM,IAAI,UAAWhB,EAAQ,wGAAyGgB,CAAI,CAAE,EAE7I,OAAOb,EAAqBa,EAAKX,EAAMC,CAAQ,CAChD,CACA,MAAM,IAAI,UAAWN,EAAQ,wGAAyGgB,CAAI,CAAE,CAC7I,SAAY1B,EAAe0B,CAAI,EAC9B,MAAM,IAAI,MAAO,mFAAoF,EAEtG,MAAM,IAAI,UAAWhB,EAAQ,wGAAyGgB,CAAI,CAAE,CAC7I,CACA,GAAKJ,IAAU,EAEd,GADAI,EAAM,UAAW,CAAE,EACd3B,EAAc2B,CAAI,EACtBT,EAAM,IAAIO,EAAME,EAAI,MAAO,UAChB1B,EAAe0B,CAAI,EAC9BT,EAAM,IAAIO,EAAME,CAAI,UACT9B,EAAsB8B,CAAI,EACrCT,EAAM,IAAIO,EAAME,CAAI,UACTzB,EAAUyB,CAAI,EAAI,CAC7B,GAAKf,IAAwB,GAC5B,MAAM,IAAI,UAAWD,EAAQ,sIAAuIgB,CAAI,CAAE,EAE3K,GAAK,CAACxB,EAAYwB,EAAKnB,CAAgB,CAAE,EACxC,MAAM,IAAI,UAAWG,EAAQ,wGAAyGgB,CAAI,CAAE,EAG7I,GADAA,EAAMA,EAAKnB,CAAgB,EAAE,EACxB,CAACL,EAAYwB,EAAI,IAAK,EAC1B,MAAM,IAAI,UAAWhB,EAAQ,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,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 deleted file mode 100644 index 06f3146..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,157 +0,0 @@ - -{{alias}}( [dtype] ) - Creates a filled array. - - Parameters - ---------- - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr = {{alias}}() - - > arr = {{alias}}( 'float32' ) - - - -{{alias}}( length[, dtype], clbk[, thisArg] ) - Returns a filled array according to a provided callback function and having - a specified length. - - Parameters - ---------- - length: integer - Array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > function clbk() { return 1.0; }; - > var arr = {{alias}}( 5, clbk ) - [ 1.0, 1.0, 1.0, 1.0, 1.0 ] - > arr = {{alias}}( 5, 'int32', clbk ) - [ 1, 1, 1, 1, 1 ] - - -{{alias}}( array[, dtype], clbk[, thisArg] ) - Creates a filled array from another array (or array-like object) according - to a provided callback function. - - Parameters - ---------- - array: ArrayLikeObject - Array from which to generate another array. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias}}( [ 0.5, 0.5, 0.5 ], {{alias:@stdlib/utils/constant-function}}( 2.0 ) ) - [ 2.0, 2.0, 2.0 ] - > var arr2 = {{alias}}( arr1, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( iterable[, dtype], clbk[, thisArg] ) - Creates a filled array from an iterable according to a provided callback - function. - - Parameters - ---------- - iterable: Iterable - Iterable from which to generate an array. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias:@stdlib/iter/constant}}( 3.0, {'iter': 3} ); - > var arr2 = {{alias}}( arr1, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( buffer[, byteOffset[, length]][, dtype], clbk[, thisArg] ) - Returns a filled typed array view of an ArrayBuffer according to a provided - callback function. - - The 'generic' array data type is *not* supported. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( buf, 0, 4, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0, 1.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index bb876ed..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,606 +0,0 @@ -/* -* @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. -*/ - -/// - -import { IterableIterator } from '@stdlib/types/iter'; -import filledarrayBy = require( './index' ); - - -/** -* Returns an iterator protocol-compliant object. -* -* @returns iterator protocol-compliant object -*/ -function iterator(): IterableIterator { - const obj: IterableIterator = { - [Symbol.iterator]: iterator, - 'next': next - }; - return obj; -} - -/** -* Implements the iterator protocol `next` method. -* -* @returns iterator protocol-compliant object -*/ -function next(): any { - return { - 'value': 1.0, - 'done': false - }; -} - -/** -* Callback function. -* -* @param i - current array index -* @returns return value -*/ -function clbk( i: number ): number { - return i; -} - - -// TESTS // - -// The function returns an array or typed array... -{ - filledarrayBy(); // $ExpectType ArrayOrTypedArray - filledarrayBy( 'float32' ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( 10, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( 10, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( 10, 'int32', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( 10, 'int32', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const x = new Float64Array( 10 ); - filledarrayBy( x, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( x, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( x, 'uint8', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( x, 'uint8', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const y = [ 2.0, 2.0, 2.0 ]; - filledarrayBy( y, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( y, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( y, 'float64', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( y, 'float64', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const it = iterator(); - filledarrayBy( it, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( it, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( it, 'uint8c', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( it, 'uint8c', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const buf = new ArrayBuffer( 32 ); - filledarrayBy( buf, clbk ); // $ExpectType RealOrComplexTypedArray | BooleanArray - filledarrayBy( buf, clbk, {} ); // $ExpectType RealOrComplexTypedArray | BooleanArray - - filledarrayBy( buf, 'uint32', clbk ); // $ExpectType RealOrComplexTypedArray | BooleanArray - filledarrayBy( buf, 'uint32', clbk, {} ); // $ExpectType RealOrComplexTypedArray | BooleanArray - - filledarrayBy( buf, 8, clbk ); // $ExpectType RealOrComplexTypedArray | BooleanArray - filledarrayBy( buf, 8, clbk, {} ); // $ExpectType RealOrComplexTypedArray | BooleanArray - - filledarrayBy( buf, 8, 'uint16', clbk ); // $ExpectType RealOrComplexTypedArray | BooleanArray - filledarrayBy( buf, 8, 'uint16', clbk, {} ); // $ExpectType RealOrComplexTypedArray | BooleanArray - - filledarrayBy( buf, 8, 2, clbk ); // $ExpectType RealOrComplexTypedArray | BooleanArray - filledarrayBy( buf, 8, 2, clbk, {} ); // $ExpectType RealOrComplexTypedArray | BooleanArray - - filledarrayBy( buf, 8, 2, 'int16', clbk ); // $ExpectType RealOrComplexTypedArray | BooleanArray - filledarrayBy( buf, 8, 2, 'int16', clbk, {} ); // $ExpectType RealOrComplexTypedArray | BooleanArray -} - -// The compiler throws an error if a callback function argument is not a function... -{ - filledarrayBy( 'float64', '5' ); // $ExpectError - filledarrayBy( 'float64', 1.0 ); // $ExpectError - filledarrayBy( 'float64', false ); // $ExpectError - filledarrayBy( 'float64', true ); // $ExpectError - filledarrayBy( 'float64', null ); // $ExpectError - filledarrayBy( 'float64', undefined ); // $ExpectError - filledarrayBy( 'float64', [] ); // $ExpectError - filledarrayBy( 'float64', {} ); // $ExpectError - - filledarrayBy( 'float64', '5', {} ); // $ExpectError - filledarrayBy( 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( 'float64', false, {} ); // $ExpectError - filledarrayBy( 'float64', true, {} ); // $ExpectError - filledarrayBy( 'float64', null, {} ); // $ExpectError - filledarrayBy( 'float64', undefined, {} ); // $ExpectError - filledarrayBy( 'float64', [], {} ); // $ExpectError - filledarrayBy( 'float64', {}, {} ); // $ExpectError - - filledarrayBy( 10, '5' ); // $ExpectError - filledarrayBy( 10, 1.0 ); // $ExpectError - filledarrayBy( 10, false ); // $ExpectError - filledarrayBy( 10, true ); // $ExpectError - filledarrayBy( 10, null ); // $ExpectError - filledarrayBy( 10, undefined ); // $ExpectError - filledarrayBy( 10, [] ); // $ExpectError - filledarrayBy( 10, {} ); // $ExpectError - - filledarrayBy( 10, '5', {} ); // $ExpectError - filledarrayBy( 10, 1.0, {} ); // $ExpectError - filledarrayBy( 10, false, {} ); // $ExpectError - filledarrayBy( 10, true, {} ); // $ExpectError - filledarrayBy( 10, null, {} ); // $ExpectError - filledarrayBy( 10, undefined, {} ); // $ExpectError - filledarrayBy( 10, [], {} ); // $ExpectError - filledarrayBy( 10, {}, {} ); // $ExpectError - - filledarrayBy( 10, 'float64', '5' ); // $ExpectError - filledarrayBy( 10, 'float64', 1.0 ); // $ExpectError - filledarrayBy( 10, 'float64', false ); // $ExpectError - filledarrayBy( 10, 'float64', true ); // $ExpectError - filledarrayBy( 10, 'float64', null ); // $ExpectError - filledarrayBy( 10, 'float64', undefined ); // $ExpectError - filledarrayBy( 10, 'float64', [] ); // $ExpectError - filledarrayBy( 10, 'float64', {} ); // $ExpectError - - filledarrayBy( 10, 'float64', '5', {} ); // $ExpectError - filledarrayBy( 10, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( 10, 'float64', false, {} ); // $ExpectError - filledarrayBy( 10, 'float64', true, {} ); // $ExpectError - filledarrayBy( 10, 'float64', null, {} ); // $ExpectError - filledarrayBy( 10, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( 10, 'float64', [], {} ); // $ExpectError - filledarrayBy( 10, 'float64', {}, {} ); // $ExpectError - - const x = new Float64Array( 10 ); - filledarrayBy( x, '5' ); // $ExpectError - filledarrayBy( x, 1.0 ); // $ExpectError - filledarrayBy( x, false ); // $ExpectError - filledarrayBy( x, true ); // $ExpectError - filledarrayBy( x, null ); // $ExpectError - filledarrayBy( x, undefined ); // $ExpectError - filledarrayBy( x, [] ); // $ExpectError - filledarrayBy( x, {} ); // $ExpectError - - filledarrayBy( x, '5', {} ); // $ExpectError - filledarrayBy( x, 1.0, {} ); // $ExpectError - filledarrayBy( x, false, {} ); // $ExpectError - filledarrayBy( x, true, {} ); // $ExpectError - filledarrayBy( x, null, {} ); // $ExpectError - filledarrayBy( x, undefined, {} ); // $ExpectError - filledarrayBy( x, [], {} ); // $ExpectError - filledarrayBy( x, {}, {} ); // $ExpectError - - filledarrayBy( x, 'float64', '5' ); // $ExpectError - filledarrayBy( x, 'float64', 1.0 ); // $ExpectError - filledarrayBy( x, 'float64', false ); // $ExpectError - filledarrayBy( x, 'float64', true ); // $ExpectError - filledarrayBy( x, 'float64', null ); // $ExpectError - filledarrayBy( x, 'float64', undefined ); // $ExpectError - filledarrayBy( x, 'float64', [] ); // $ExpectError - filledarrayBy( x, 'float64', {} ); // $ExpectError - - filledarrayBy( x, 'float64', '5', {} ); // $ExpectError - filledarrayBy( x, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( x, 'float64', false, {} ); // $ExpectError - filledarrayBy( x, 'float64', true, {} ); // $ExpectError - filledarrayBy( x, 'float64', null, {} ); // $ExpectError - filledarrayBy( x, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( x, 'float64', [], {} ); // $ExpectError - filledarrayBy( x, 'float64', {}, {} ); // $ExpectError - - const y = [ 2.0, 2.0, 2.0 ]; - filledarrayBy( y, '5' ); // $ExpectError - filledarrayBy( y, 1.0 ); // $ExpectError - filledarrayBy( y, false ); // $ExpectError - filledarrayBy( y, true ); // $ExpectError - filledarrayBy( y, null ); // $ExpectError - filledarrayBy( y, undefined ); // $ExpectError - filledarrayBy( y, [] ); // $ExpectError - filledarrayBy( y, {} ); // $ExpectError - - filledarrayBy( y, '5', {} ); // $ExpectError - filledarrayBy( y, 1.0, {} ); // $ExpectError - filledarrayBy( y, false, {} ); // $ExpectError - filledarrayBy( y, true, {} ); // $ExpectError - filledarrayBy( y, null, {} ); // $ExpectError - filledarrayBy( y, undefined, {} ); // $ExpectError - filledarrayBy( y, [], {} ); // $ExpectError - filledarrayBy( y, {}, {} ); // $ExpectError - - filledarrayBy( y, 'float64', '5' ); // $ExpectError - filledarrayBy( y, 'float64', 1.0 ); // $ExpectError - filledarrayBy( y, 'float64', false ); // $ExpectError - filledarrayBy( y, 'float64', true ); // $ExpectError - filledarrayBy( y, 'float64', null ); // $ExpectError - filledarrayBy( y, 'float64', undefined ); // $ExpectError - filledarrayBy( y, 'float64', [] ); // $ExpectError - filledarrayBy( y, 'float64', {} ); // $ExpectError - - filledarrayBy( y, 'float64', '5', {} ); // $ExpectError - filledarrayBy( y, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( y, 'float64', false, {} ); // $ExpectError - filledarrayBy( y, 'float64', true, {} ); // $ExpectError - filledarrayBy( y, 'float64', null, {} ); // $ExpectError - filledarrayBy( y, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( y, 'float64', [], {} ); // $ExpectError - filledarrayBy( y, 'float64', {}, {} ); // $ExpectError - - const it = iterator(); - filledarrayBy( it, '5' ); // $ExpectError - filledarrayBy( it, 1.0 ); // $ExpectError - filledarrayBy( it, false ); // $ExpectError - filledarrayBy( it, true ); // $ExpectError - filledarrayBy( it, null ); // $ExpectError - filledarrayBy( it, undefined ); // $ExpectError - filledarrayBy( it, [] ); // $ExpectError - filledarrayBy( it, {} ); // $ExpectError - - filledarrayBy( it, '5', {} ); // $ExpectError - filledarrayBy( it, 1.0, {} ); // $ExpectError - filledarrayBy( it, false, {} ); // $ExpectError - filledarrayBy( it, true, {} ); // $ExpectError - filledarrayBy( it, null, {} ); // $ExpectError - filledarrayBy( it, undefined, {} ); // $ExpectError - filledarrayBy( it, [], {} ); // $ExpectError - filledarrayBy( it, {}, {} ); // $ExpectError - - filledarrayBy( it, 'float64', '5' ); // $ExpectError - filledarrayBy( it, 'float64', 1.0 ); // $ExpectError - filledarrayBy( it, 'float64', false ); // $ExpectError - filledarrayBy( it, 'float64', true ); // $ExpectError - filledarrayBy( it, 'float64', null ); // $ExpectError - filledarrayBy( it, 'float64', undefined ); // $ExpectError - filledarrayBy( it, 'float64', [] ); // $ExpectError - filledarrayBy( it, 'float64', {} ); // $ExpectError - - filledarrayBy( it, 'float64', '5', {} ); // $ExpectError - filledarrayBy( it, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( it, 'float64', false, {} ); // $ExpectError - filledarrayBy( it, 'float64', true, {} ); // $ExpectError - filledarrayBy( it, 'float64', null, {} ); // $ExpectError - filledarrayBy( it, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( it, 'float64', [], {} ); // $ExpectError - filledarrayBy( it, 'float64', {}, {} ); // $ExpectError - - const buf = new ArrayBuffer( 32 ); - filledarrayBy( buf, '5' ); // $ExpectError - filledarrayBy( buf, 1.0 ); // $ExpectError - filledarrayBy( buf, false ); // $ExpectError - filledarrayBy( buf, true ); // $ExpectError - filledarrayBy( buf, null ); // $ExpectError - filledarrayBy( buf, undefined ); // $ExpectError - filledarrayBy( buf, [] ); // $ExpectError - filledarrayBy( buf, {} ); // $ExpectError - - filledarrayBy( buf, '5', {} ); // $ExpectError - filledarrayBy( buf, 1.0, {} ); // $ExpectError - filledarrayBy( buf, false, {} ); // $ExpectError - filledarrayBy( buf, true, {} ); // $ExpectError - filledarrayBy( buf, null, {} ); // $ExpectError - filledarrayBy( buf, undefined, {} ); // $ExpectError - filledarrayBy( buf, [], {} ); // $ExpectError - filledarrayBy( buf, {}, {} ); // $ExpectError - - filledarrayBy( buf, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 'float64', false ); // $ExpectError - filledarrayBy( buf, 'float64', true ); // $ExpectError - filledarrayBy( buf, 'float64', null ); // $ExpectError - filledarrayBy( buf, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 'float64', {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5' ); // $ExpectError - filledarrayBy( buf, 8, 1.0 ); // $ExpectError - filledarrayBy( buf, 8, false ); // $ExpectError - filledarrayBy( buf, 8, true ); // $ExpectError - filledarrayBy( buf, 8, null ); // $ExpectError - filledarrayBy( buf, 8, undefined ); // $ExpectError - filledarrayBy( buf, 8, [] ); // $ExpectError - filledarrayBy( buf, 8, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, false, {} ); // $ExpectError - filledarrayBy( buf, 8, true, {} ); // $ExpectError - filledarrayBy( buf, 8, null, {} ); // $ExpectError - filledarrayBy( buf, 8, undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, [], {} ); // $ExpectError - filledarrayBy( buf, 8, {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 8, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 'float64', false ); // $ExpectError - filledarrayBy( buf, 8, 'float64', true ); // $ExpectError - filledarrayBy( buf, 8, 'float64', null ); // $ExpectError - filledarrayBy( buf, 8, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 8, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 8, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 8, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, '5' ); // $ExpectError - filledarrayBy( buf, 8, 2, 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 2, false ); // $ExpectError - filledarrayBy( buf, 8, 2, true ); // $ExpectError - filledarrayBy( buf, 8, 2, null ); // $ExpectError - filledarrayBy( buf, 8, 2, undefined ); // $ExpectError - filledarrayBy( buf, 8, 2, [] ); // $ExpectError - filledarrayBy( buf, 8, 2, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, false, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, true, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, null, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, [], {} ); // $ExpectError - filledarrayBy( buf, 8, 2, {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', false ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', true ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', null ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', {}, {} ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid length, typed array, array-like object, `ArrayBuffer`, or iterable argument... -{ - filledarrayBy( false, clbk ); // $ExpectError - filledarrayBy( true, clbk ); // $ExpectError - filledarrayBy( null, clbk ); // $ExpectError - filledarrayBy( {}, clbk ); // $ExpectError - - filledarrayBy( false, clbk, {} ); // $ExpectError - filledarrayBy( true, clbk, {} ); // $ExpectError - filledarrayBy( null, clbk, {} ); // $ExpectError - filledarrayBy( {}, clbk, {} ); // $ExpectError - - filledarrayBy( false, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 'float64', clbk ); // $ExpectError - - filledarrayBy( false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, clbk ); // $ExpectError - filledarrayBy( 1.0, 8, clbk ); // $ExpectError - filledarrayBy( false, 8, clbk ); // $ExpectError - filledarrayBy( true, 8, clbk ); // $ExpectError - filledarrayBy( null, 8, clbk ); // $ExpectError - filledarrayBy( undefined, 8, clbk ); // $ExpectError - filledarrayBy( [], 8, clbk ); // $ExpectError - filledarrayBy( {}, 8, clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, clbk ); // $ExpectError - - filledarrayBy( '5', 8, clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, clbk, {} ); // $ExpectError - filledarrayBy( false, 8, clbk, {} ); // $ExpectError - filledarrayBy( true, 8, clbk, {} ); // $ExpectError - filledarrayBy( null, 8, clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, clbk, {} ); // $ExpectError - filledarrayBy( [], 8, clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 'float64', clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( false, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( [], 8, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 'float64', clbk ); // $ExpectError - - filledarrayBy( '5', 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 2, clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 2, clbk ); // $ExpectError - filledarrayBy( false, 8, 2, clbk ); // $ExpectError - filledarrayBy( true, 8, 2, clbk ); // $ExpectError - filledarrayBy( null, 8, 2, clbk ); // $ExpectError - filledarrayBy( undefined, 8, 2, clbk ); // $ExpectError - filledarrayBy( [], 8, 2, clbk ); // $ExpectError - filledarrayBy( {}, 8, 2, clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, clbk ); // $ExpectError - - filledarrayBy( '5', 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( false, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( [], 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, 'float64', clbk ); // $ExpectError - - filledarrayBy( '5', 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a byte offset argument which is not a number... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, false, clbk ); // $ExpectError - filledarrayBy( buf, true, clbk ); // $ExpectError - filledarrayBy( buf, null, clbk ); // $ExpectError - filledarrayBy( buf, [], clbk ); // $ExpectError - filledarrayBy( buf, {}, clbk ); // $ExpectError - - filledarrayBy( buf, false, clbk, {} ); // $ExpectError - filledarrayBy( buf, true, clbk, {} ); // $ExpectError - filledarrayBy( buf, null, clbk, {} ); // $ExpectError - filledarrayBy( buf, [], clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, clbk, {} ); // $ExpectError - - filledarrayBy( buf, '5', 'float64', clbk ); // $ExpectError - filledarrayBy( buf, false, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, true, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, null, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, [], 'float64', clbk ); // $ExpectError - filledarrayBy( buf, {}, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, '5', 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( buf, false, 2, clbk ); // $ExpectError - filledarrayBy( buf, true, 2, clbk ); // $ExpectError - filledarrayBy( buf, null, 2, clbk ); // $ExpectError - filledarrayBy( buf, [], 2, clbk ); // $ExpectError - filledarrayBy( buf, {}, 2, clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, clbk ); // $ExpectError - - filledarrayBy( buf, false, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, clbk, {} ); // $ExpectError - - filledarrayBy( buf, '5', 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, false, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, true, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, null, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, undefined, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, [], 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, {}, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, '5', 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, false, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, undefined, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a view length argument which is not a number... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, 8, false, clbk ); // $ExpectError - filledarrayBy( buf, 8, true, clbk ); // $ExpectError - filledarrayBy( buf, 8, null, clbk ); // $ExpectError - filledarrayBy( buf, 8, [], clbk ); // $ExpectError - filledarrayBy( buf, 8, {}, clbk ); // $ExpectError - - filledarrayBy( buf, 8, false, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, true, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, null, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, [], clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, {}, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, clbk, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5', 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, false, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, true, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, null, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, [], 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, {}, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, 8, '5', 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, [], 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, {}, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided too many arguments... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, 8, 2, 'float64', 1, clbk, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 997a381..0000000 --- a/examples/index.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ).factory; -var dtypes = require( '@stdlib/array-typed-real-dtypes' ); -var filledarrayBy = require( './../lib' ); - -// Create a pseudorandom number generator: -var rand = discreteUniform( 0, 100 ); - -// Get a list of array data types: -var dt = dtypes(); - -// Generate filled arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = filledarrayBy( 10, dt[ i ], rand ); - console.log( arr ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 764e40e..cb63cd1 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, RealOrComplexTypedArray, BooleanArray, DataType } from '@stdlib/types/array'; import { IterableIterator } from '@stdlib/types/iter'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..6f157fa --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.3-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.3-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@v0.0.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.3-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.3-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.3-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-ctors@v0.3.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill-by@v0.2.3-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled-by@v0.2.3-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.2.3-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.3-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@v0.2.3-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.4.1-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";var v=f(),g=j.get("dtypes.default");function c(){var f,j,c,b,y,x,u,E;if(0===(j=arguments.length))return new(y=d(g))(0);if(r(c=arguments[0])){if(j>1)throw new TypeError(w("00h05"));if(null===(y=d(c)))throw new TypeError(w("00h2Y",c));return new y(0)}if(j<2)throw new TypeError(w("00h05"));if(h(arguments[j-=1]))if(h(arguments[j-1])){if(f=arguments[j],b=arguments[j-=1],0===j)throw new TypeError(w("00h05"))}else b=arguments[j];else{if(!(j>=2))throw new TypeError(w("00h05"));if(f=arguments[j],!h(b=arguments[j-=1]))throw new TypeError(w("00h2b",b))}if((j-=1)>=0&&r(arguments[j])?(c=arguments[j],j-=1):c=g,null===(y=d(c)))throw new TypeError(w("00h2Y",c));if("generic"===c){if(E=arguments[0],0===j){if(e(E)?u=E:i(E)&&(u=E.length),void 0!==u)return m(u,b,f);if(n(E))throw new Error(w("00h04"));if(o(E)){if(!1===v)throw new TypeError(w("00h2Z",E));if(!h(E[p]))throw new TypeError(w("00h2a",E));if(E=E[p](),!h(E.next))throw new TypeError(w("00h2a",E));return function(r,e,t){var s,i;for(s=[],i=-1;!r.next().done;)i+=1,s.push(e.call(t,i));return s}(E,b,f)}throw new TypeError(w("00h2a",E))}if(n(E))throw new Error(w("00h04"));throw new TypeError(w("00h2a",E))}if(0===j)if(i(E=arguments[0]))x=new y(E.length);else if(n(E))x=new y(E);else if(e(E))x=new y(E);else{if(!o(E))throw new TypeError(w("00h2a",E));if(!1===v)throw new TypeError(w("00h2Z",E));if(!h(E[p]))throw new TypeError(w("00h2a",E));if(E=E[p](),!h(E.next))throw new TypeError(w("00h2a",E));x=new y(a(E))}else x=1===j?new y(arguments[0],arguments[1]):new y(arguments[0],arguments[1],arguments[2]);return x.length>0&&(t(c)||s(c)?function(r,e,t){var s;for(s=0;s\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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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( format('00h05') );\n\t\t}\n\t\tctor = ctors( dtype );\n\t\tif ( ctor === null ) {\n\t\t\tthrow new TypeError( format( '00h2Y', 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( format('00h05') );\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( format('00h05') );\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( '00h2b', clbk ) );\n\t\t}\n\t}\n\t// If we 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( format('00h05') );\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( '00h2Y', 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( format('00h04') );\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( '00h2Z', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00h2a', 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( '00h2a', 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( '00h2a', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format('00h04') );\n\t\t}\n\t\tthrow new TypeError( format( '00h2a', 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( '00h2Z', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00h2a', 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( '00h2a', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00h2a', 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\nexport default filledarrayBy;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","DEFAULT_DTYPE","defaults","get","filledarrayBy","thisArg","nargs","dtype","clbk","ctor","arr","len","arg","arguments","length","ctors","isString","TypeError","format","isFunction","isNonNegativeInteger","isCollection","filledArray","isArrayBuffer","Error","isObject","ITERATOR_SYMBOL","next","it","i","done","push","call","filledArrayIterator","iterLength","isComplexDataType","isBooleanDataType","set","filledAccessors","gfillBy","value","aidx"],"mappings":";;sjDA0CA,IAAIA,EAAsBC,IACtBC,EAAgBC,EAASC,IAAK,kBA2MlC,SAASC,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAKJ,GAAe,KAHfN,EAAQO,UAAUC,QAKjB,OAAO,IADPL,EAAOM,EAAOd,IACG,GAIlB,GAAKe,EADLT,EAAQM,UAAW,IACM,CAExB,GAAKP,EAAQ,EACZ,MAAM,IAAIW,UAAWC,EAAO,UAG7B,GAAc,QADdT,EAAOM,EAAOR,IAEb,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,OAAO,IAAIE,EAAM,EACjB,CAED,GAAKH,EAAQ,EACZ,MAAM,IAAIW,UAAWC,EAAO,UAM7B,GAAKC,EAAYN,UAHjBP,GAAS,IAKR,GAAKa,EAAYN,UAAWP,EAAM,KAMjC,GALAD,EAAUQ,UAAWP,GAErBE,EAAOK,UADPP,GAAS,GAIM,IAAVA,EACJ,MAAM,IAAIW,UAAWC,EAAO,eAI7BV,EAAOK,UAAWP,OAIf,MAAKA,GAAS,GAUlB,MAAM,IAAIW,UAAWC,EAAO,UAN5B,GAHAb,EAAUQ,UAAWP,IAGfa,EADNX,EAAOK,UADPP,GAAS,IAGR,MAAM,IAAIW,UAAWC,EAAQ,QAASV,GAMvC,CAUD,IARAF,GAAS,IACK,GAAKU,EAAUH,UAAWP,KACvCC,EAAQM,UAAWP,GACnBA,GAAS,GAETC,EAAQN,EAGK,QADdQ,EAAOM,EAAOR,IAEb,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,GAAe,YAAVA,EAAsB,CAE1B,GADAK,EAAMC,UAAW,GACF,IAAVP,EAAc,CAMlB,GALKc,EAAsBR,GAC1BD,EAAMC,EACKS,EAAcT,KACzBD,EAAMC,EAAIE,aAEE,IAARH,EACJ,OAAOW,EAAaX,EAAKH,EAAMH,GAEhC,GAAKkB,EAAeX,GACnB,MAAM,IAAIY,MAAON,EAAO,UAEzB,GAAKO,EAAUb,GAAQ,CACtB,IAA6B,IAAxBb,EACJ,MAAM,IAAIkB,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAYP,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLP,EAAYP,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvC,OAvSJ,SAA8BgB,EAAIpB,EAAMH,GACvC,IAAIK,EACAmB,EAKJ,IAFAnB,EAAM,GACNmB,GAAK,GAEAD,EAAGD,OACAG,MAGPD,GAAK,EACLnB,EAAIqB,KAAMvB,EAAKwB,KAAM3B,EAASwB,IAE/B,OAAOnB,CACR,CAuRWuB,CAAqBrB,EAAKJ,EAAMH,EACvC,CACD,MAAM,IAAIY,UAAWC,EAAQ,QAASN,GACzC,CAAS,GAAKW,EAAeX,GAC1B,MAAM,IAAIY,MAAON,EAAO,UAEzB,MAAM,IAAID,UAAWC,EAAQ,QAASN,GACtC,CACD,GAAe,IAAVN,EAEJ,GAAKe,EADLT,EAAMC,UAAW,IAEhBH,EAAM,IAAID,EAAMG,EAAIE,aACd,GAAKS,EAAeX,GAC1BF,EAAM,IAAID,EAAMG,QACV,GAAKQ,EAAsBR,GACjCF,EAAM,IAAID,EAAMG,OACV,KAAKa,EAAUb,GAarB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAZtC,IAA6B,IAAxBb,EACJ,MAAM,IAAIkB,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAYP,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLP,EAAYP,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvCF,EAAM,IAAID,EAAMyB,EAAYtB,GAG5B,MAEDF,EADqB,IAAVJ,EACL,IAAIG,EAAMI,UAAU,GAAIA,UAAU,IAElC,IAAIJ,EAAMI,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKH,EAAII,OAAS,IACZqB,EAAmB5B,IAAW6B,EAAmB7B,GAjTxD,SAA0BG,EAAKF,EAAMH,GACpC,IAAIwB,EACJ,IAAMA,EAAI,EAAGA,EAAInB,EAAII,OAAQe,IAC5BnB,EAAI2B,IAAK7B,EAAKwB,KAAM3B,EAASwB,GAAKA,EAGpC,CA4SGS,CAAiB5B,EAAKF,EAAMH,GAE5BkC,EAAS7B,EAAII,OAAQJ,EAAK,GAe5B,SAAmB8B,EAAOC,GACzB,OAAOjC,EAAKwB,KAAM3B,EAASoC,EAC3B,KAdM/B,CAeR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d115cf0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,192 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -/** -* Create a filled array according to a provided callback function. -* -* @module @stdlib/array-filled-by -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* var arr = filledarrayBy(); -* // returns -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'generic', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( [ 0.5, 0.5 ], clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1; -* } -* -* var arr = filledarrayBy( [ 5, -3 ], 'int32', clbk ); -* // returns [ 1, 1 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk1() { -* return 10; -* } -* -* function clbk2() { -* return 1.0; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, clbk2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk1() { -* return 1.0; -* } -* -* function clbk2() { -* return 2; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, 'uint32', clbk2 ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 'float32', clbk ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, clbk ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, 'int32', clbk ); -* // returns [ 1, 1 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 32b6545..0000000 --- a/lib/main.js +++ /dev/null @@ -1,416 +0,0 @@ -/** -* @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 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' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var ctors = require( '@stdlib/array-ctors' ); -var gfillBy = require( '@stdlib/blas-ext-base-gfill-by' ); -var filledArray = require( '@stdlib/array-base-filled-by' ); -var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var iterLength = require( '@stdlib/iter-length' ); -var defaults = require( '@stdlib/array-defaults' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport(); -var DEFAULT_DTYPE = defaults.get( 'dtypes.default' ); - - -// FUNCTIONS // - -/** -* Creates a filled "generic" array from an iterator. -* -* @private -* @param {Iterable} it - iterator -* @param {Callback} clbk - callback function -* @param {*} thisArg - callback function execution context -* @returns {Array} filled array -*/ -function filledArrayIterator( it, clbk, thisArg ) { - var arr; - var i; - var v; - - arr = []; - i = -1; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - i += 1; - arr.push( clbk.call( thisArg, i ) ); - } - return arr; -} - -/** -* Fills an array exposing accessors for getting and setting array elements. -* -* @private -* @param {Collection} arr - input array -* @param {Callback} clbk - callback function -* @param {*} thisArg - callback function execution context -* @returns {Collection} input array -*/ -function filledAccessors( arr, clbk, thisArg ) { - var i; - for ( i = 0; i < arr.length; i++ ) { - arr.set( clbk.call( thisArg, i ), i ); - } - return arr; -} - - -// MAIN // - -/** -* Creates a filled array according to a provided callback function. -* -* @param {(NonNegativeInteger|TypedArray|ArrayLikeObject|ArrayBuffer|Iterable)} [arg] - a length, typed array, array-like object, buffer, or iterable -* @param {NonNegativeInteger} [byteOffset=0] - byte offset -* @param {NonNegativeInteger} [length] - view length -* @param {string} [dtype="float64"] - data type -* @param {Callback} [clbk] - callback to invoke -* @param {*} [thisArg] - callback execution context -* @throws {TypeError} must provide a recognized data type -* @throws {TypeError} must provide a length, typed array, array-like object, buffer, or iterable -* @throws {TypeError} callback argument must be a function. -* @throws {Error} creating a generic array from an `ArrayBuffer` is not supported -* @returns {(TypedArray|Array)} array or typed array -* -* @example -* var arr = filledarrayBy(); -* // returns -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'generic', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( [ 0.5, 0.5 ], clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1; -* } -* -* var arr = filledarrayBy( [ 5, -3 ], 'int32', clbk ); -* // returns [ 1, 1 ] -* -* @example -* function clbk1() { -* return 10; -* } -* -* function clbk2() { -* return 1.0; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, clbk2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk1() { -* return 1.0; -* } -* -* function clbk2() { -* return 2; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, 'uint32', clbk2 ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 'float32', clbk ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, clbk ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, 'int32', clbk ); -* // returns [ 1, 1 ] -*/ -function filledarrayBy() { - var thisArg; - var nargs; - var dtype; - var clbk; - var ctor; - var arr; - var len; - var arg; - - nargs = arguments.length; - - // If we weren't provided any arguments, return an empty array... - if ( nargs === 0 ) { - ctor = ctors( DEFAULT_DTYPE ); - return new ctor( 0 ); - } - // Check if we were provided a dtype as the first argument... - dtype = arguments[ 0 ]; - if ( isString( dtype ) ) { - // Invoking this function with arguments `f( dtype, clbk[, thisArg] )` is not allowed (otherwise, we'd need to also allow `f( clbk[, thisArg] )`)... - if ( nargs > 1 ) { - throw new TypeError( format('00h05') ); - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '00h2Y', dtype ) ); - } - // Return an empty array having the specified dtype: - return new ctor( 0 ); - } - // For all other supported invocations, we need at least two arguments... - if ( nargs < 2 ) { - throw new TypeError( format('00h05') ); - } - // At this point, we need to do some argument juggling... - nargs -= 1; // henceforth, the number of available arguments is `nargs+1` - - // Determine whether the last argument is a callback or "this" context... - if ( isFunction( arguments[ nargs ] ) ) { - // 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... - if ( isFunction( arguments[ nargs-1 ] ) ) { - thisArg = arguments[ nargs ]; - nargs -= 1; - clbk = arguments[ nargs ]; - - // Check if we were provided only a callback and a "this" context.. - if ( nargs === 0 ) { - throw new TypeError( format('00h05') ); - } - } else { - // "this" context is left undefined... - clbk = arguments[ nargs ]; - } - } - // 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... - else if ( nargs >= 2 ) { - thisArg = arguments[ nargs ]; - nargs -= 1; - clbk = arguments[ nargs ]; - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '00h2b', clbk ) ); - } - } - // If we were only provided 2 arguments and the last argument was not a function, we've been provided an insufficient number of arguments... - else { - throw new TypeError( format('00h05') ); - } - // Now that we've processed the callback arguments, let's continue working backward to see if we've been provided a `dtype` argument... - nargs -= 1; - if ( nargs >= 0 && isString( arguments[ nargs ] ) ) { - dtype = arguments[ nargs ]; - nargs -= 1; - } else { - dtype = DEFAULT_DTYPE; - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '00h2Y', dtype ) ); - } - // At this point, we've resolved the output array data type, and now we can actually create the output array... - if ( dtype === 'generic' ) { - arg = arguments[ 0 ]; - if ( nargs === 0 ) { - if ( isNonNegativeInteger( arg ) ) { - len = arg; - } else if ( isCollection( arg ) ) { - len = arg.length; - } - if ( len !== void 0 ) { - return filledArray( len, clbk, thisArg ); - } - if ( isArrayBuffer( arg ) ) { - throw new Error( format('00h04') ); - } - if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( '00h2Z', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00h2a', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00h2a', arg ) ); - } - return filledArrayIterator( arg, clbk, thisArg ); - } - throw new TypeError( format( '00h2a', arg ) ); - } else if ( isArrayBuffer( arg ) ) { - throw new Error( format('00h04') ); - } - throw new TypeError( format( '00h2a', arg ) ); - } - if ( nargs === 0 ) { // length || array-like || ArrayBuffer || iterable - arg = arguments[ 0 ]; - if ( isCollection( arg ) ) { - arr = new ctor( arg.length ); - } else if ( isArrayBuffer( arg ) ) { - arr = new ctor( arg ); - } else if ( isNonNegativeInteger( arg ) ) { - arr = new ctor( arg ); - } else if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( '00h2Z', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00h2a', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00h2a', arg ) ); - } - arr = new ctor( iterLength( arg ) ); - } else { - throw new TypeError( format( '00h2a', arg ) ); - } - } else if ( nargs === 1 ) { - arr = new ctor( arguments[0], arguments[1] ); // (ArrayBuffer, byteOffset) - } else { - arr = new ctor( arguments[0], arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset, length) - } - if ( arr.length > 0 ) { - if ( isComplexDataType( dtype ) || isBooleanDataType( dtype ) ) { - filledAccessors( arr, clbk, thisArg ); - } else { - gfillBy( arr.length, arr, 1, callback ); - } - } - return arr; - - /** - * Callback which wraps a provided callback and is invoked for each array element. - * - * @private - * @param {*} value - element value - * @param {NonNegativeInteger} aidx - array index - * @param {NonNegativeInteger} sidx - strided index - * @param {Collection} array - input array/collection - * @returns {*} callback return value - */ - function callback( value, aidx ) { - return clbk.call( thisArg, aidx ); - } -} - - -// EXPORTS // - -module.exports = filledarrayBy; diff --git a/package.json b/package.json index ecbe58e..026d062 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.3.1", "description": "Create a filled array according to a provided callback function.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,75 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-assert-is-boolean-data-type": "^0.0.2", - "@stdlib/array-base-assert-is-complex-floating-point-data-type": "^0.2.2", - "@stdlib/array-base-filled-by": "^0.2.3", - "@stdlib/array-ctors": "^0.3.1", - "@stdlib/array-defaults": "^0.4.1", - "@stdlib/assert-has-iterator-symbol-support": "^0.2.3", - "@stdlib/assert-is-arraybuffer": "^0.2.3", - "@stdlib/assert-is-collection": "^0.2.3", - "@stdlib/assert-is-function": "^0.2.3", - "@stdlib/assert-is-nonnegative-integer": "^0.2.3", - "@stdlib/assert-is-object": "^0.2.3", - "@stdlib/assert-is-string": "^0.2.3", - "@stdlib/blas-ext-base-gfill-by": "^0.2.3", - "@stdlib/iter-length": "^0.2.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3", - "@stdlib/symbol-iterator": "^0.2.3", - "@stdlib/types": "^0.4.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3" - }, - "devDependencies": { - "@stdlib/array-bool": "^0.1.2", - "@stdlib/array-buffer": "^0.2.3", - "@stdlib/array-complex128": "^0.3.2", - "@stdlib/array-complex64": "^0.3.2", - "@stdlib/array-float32": "^0.2.3", - "@stdlib/array-float64": "^0.2.3", - "@stdlib/array-int16": "^0.2.3", - "@stdlib/array-int32": "^0.2.3", - "@stdlib/array-int8": "^0.2.3", - "@stdlib/array-typed-real-dtypes": "^0.2.3", - "@stdlib/array-uint16": "^0.2.3", - "@stdlib/array-uint32": "^0.2.3", - "@stdlib/array-uint8": "^0.2.3", - "@stdlib/array-uint8c": "^0.2.3", - "@stdlib/assert-instance-of": "^0.3.1", - "@stdlib/assert-is-array": "^0.2.3", - "@stdlib/assert-is-typed-array": "^0.2.3", - "@stdlib/assert-is-typed-array-like": "^0.2.3", - "@stdlib/complex-float32-ctor": "^0.1.1", - "@stdlib/complex-float64-ctor": "^0.1.2", - "@stdlib/iter-constant": "^0.2.3", - "@stdlib/math-base-special-pow": "^0.3.1", - "@stdlib/random-base-discrete-uniform": "^0.2.2", - "@stdlib/strided-base-reinterpret-boolean": "^0.0.3", - "@stdlib/strided-base-reinterpret-complex128": "^0.2.3", - "@stdlib/strided-base-reinterpret-complex64": "^0.2.2", - "@stdlib/utils-constant-function": "^0.2.3", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.3" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..dabf69c --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index ca0cf25..0000000 --- a/test/test.js +++ /dev/null @@ -1,4397 +0,0 @@ -/** -* @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. -*/ - -/* eslint-disable max-len */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -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' ); -var iterConstant = require( '@stdlib/iter-constant' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var filledarrayBy = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': !hasIteratorSymbolSupport() -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof filledarrayBy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if only provided callback arguments', function test( t ) { - t.throws( clbk1, TypeError, 'throws an error' ); - t.throws( clbk2, TypeError, 'throws an error' ); - t.throws( clbk3, TypeError, 'throws an error' ); - t.end(); - - function clbk1() { - filledarrayBy( constantFunction( 1.0 ) ); - } - - function clbk2() { - filledarrayBy( constantFunction( 1.0 ), {} ); - } - - function clbk3() { - filledarrayBy( constantFunction( 1.0 ), constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (only argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (typed array; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (array-like object)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (array-like object; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 8 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 8 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, 1, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (iterator)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( iterConstant( 1.0 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (iterator; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( iterConstant( 1.0 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if only provided data type and callback arguments', function test( t ) { - t.throws( clbk1, TypeError, 'throws an error' ); - t.throws( clbk2, TypeError, 'throws an error' ); - t.throws( clbk3, TypeError, 'throws an error' ); - t.end(); - - function clbk1() { - filledarrayBy( 'float64', constantFunction( 1.0 ) ); - } - - function clbk2() { - filledarrayBy( 'float64', constantFunction( 1.0 ), {} ); - } - - function clbk3() { - filledarrayBy( 'float64', constantFunction( 1.0 ), constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (array-like object)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (array-like object; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, 1, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, 1, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (no iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (no iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (non-function iterator symbol property)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (non-function iterator symbol property; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (`next` property is not a function)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ) ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (`next` property is not a function; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ), {} ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (no iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (no iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (non-function iterator symbol property)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (non-function iterator symbol property; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (`next` property is not a function)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ) ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (`next` property is not a function; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ), {} ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 1, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 1, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function returns a filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - arr = filledarrayBy(); - - t.strictEqual( instanceOf( arr, Float64Array ), 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=float64)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - arr = filledarrayBy( 'float64' ); - - t.strictEqual( instanceOf( arr, Float64Array ), 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=float32)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( 0 ); - arr = filledarrayBy( 'float32' ); - - t.strictEqual( instanceOf( arr, Float32Array ), 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=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; - - expected = new Complex128Array( 0 ); - arr = filledarrayBy( 'complex128' ); - - t.strictEqual( instanceOf( arr, Complex128Array ), 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=complex64)', function test( t ) { - var expected; - var arr; - - expected = new Complex64Array( 0 ); - arr = filledarrayBy( 'complex64' ); - - t.strictEqual( instanceOf( arr, Complex64Array ), 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=int32)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( 0 ); - arr = filledarrayBy( 'int32' ); - - t.strictEqual( instanceOf( arr, Int32Array ), 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=uint32)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( 0 ); - arr = filledarrayBy( 'uint32' ); - - t.strictEqual( instanceOf( arr, Uint32Array ), 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=int16)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( 0 ); - arr = filledarrayBy( 'int16' ); - - t.strictEqual( instanceOf( arr, Int16Array ), 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=uint16)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( 0 ); - arr = filledarrayBy( 'uint16' ); - - t.strictEqual( instanceOf( arr, Uint16Array ), 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=int8)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( 0 ); - arr = filledarrayBy( 'int8' ); - - t.strictEqual( instanceOf( arr, Int8Array ), 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=uint8)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( 0 ); - arr = filledarrayBy( 'uint8' ); - - t.strictEqual( instanceOf( arr, Uint8Array ), 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=uint8c)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( 0 ); - arr = filledarrayBy( 'uint8c' ); - - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), 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=generic)', function test( t ) { - var expected; - var arr; - - expected = []; - arr = filledarrayBy( 'generic' ); - - t.strictEqual( instanceOf( arr, Array ), 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 (default, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, length=0)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array(); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 0, clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, clbk, ctx ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (default, length; thisArg=function)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, clbk, context ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this(); // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } - - function context() { - ctx.count += 1; - } -}); - -tape( 'the function returns a filled array (dtype=float64, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, 'float64', clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, length; thisArg=function)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, 'float64', clbk, context ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this(); // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } - - function context() { - ctx.count += 1; - } -}); - -tape( 'the function returns a filled array (dtype=float32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, 'float32', clbk ); - - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - 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; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = filledarrayBy( 5, 'complex128', clbk ); - - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = filledarrayBy( 5, 'complex64', clbk ); - - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int32Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int32', clbk ); - - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint32Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint32', clbk ); - - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int16Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int16', clbk ); - - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint16', clbk ); - - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int8Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int8', clbk ); - - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint8', clbk ); - - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint8c', clbk ); - - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = [ 1, 1, 1, 1, 1 ]; - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'generic', clbk ); - - t.strictEqual( instanceOf( arr, Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - 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; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = [ 1.0, 2.0 ]; - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = [ 1.0, 2.0 ]; - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int32', clbk ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, typed array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, typed array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - 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; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = new Float64Array( [ 1.0, 2.0 ] ); - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = new Float64Array( [ 1.0, 2.0 ] ); - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (default, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - 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; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer, byteoffset; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer, byteoffset; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - 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; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 48 ); - out = filledarrayBy( buf, 16, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 24 ); - out = filledarrayBy( buf, 8, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int32', clbk ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint8c', clbk ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - 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; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 64 ); - out = filledarrayBy( buf, 16, 2, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset, length)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 1, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 1, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled array (default, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, iterator; thisArg)', opts, function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - ctx = { - 'count': 0 - }; - indices = []; - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, iterator; thisArg)', opts, function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - ctx = { - 'count': 0 - }; - indices = []; - out = filledarrayBy( arr, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - 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; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = iterConstant( new Complex128( 3.0, 3.0 ), { - 'iter': 2 - }); - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = iterConstant( new Complex64( 3.0, 3.0 ), { - 'iter': 2 - }); - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); From da8ee2954a1b019dea60795d4a5739644b09da38 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 16 Mar 2026 02:06:30 +0000 Subject: [PATCH 100/117] Transform error messages --- lib/main.js | 38 +++++++++++++++++++------------------- package.json | 2 +- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/lib/main.js b/lib/main.js index d2128f5..32b6545 100644 --- a/lib/main.js +++ b/lib/main.js @@ -35,7 +35,7 @@ var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-supp var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); var iterLength = require( '@stdlib/iter-length' ); var defaults = require( '@stdlib/array-defaults' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -266,18 +266,18 @@ function filledarrayBy() { if ( isString( dtype ) ) { // Invoking this function with arguments `f( dtype, clbk[, thisArg] )` is not allowed (otherwise, we'd need to also allow `f( clbk[, thisArg] )`)... if ( nargs > 1 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format('00h05') ); } ctor = ctors( dtype ); if ( ctor === null ) { - throw new TypeError( format( 'invalid argument. Must provide a recognized data type. Value: `%s`.', dtype ) ); + throw new TypeError( format( '00h2Y', dtype ) ); } // Return an empty array having the specified dtype: return new ctor( 0 ); } // For all other supported invocations, we need at least two arguments... if ( nargs < 2 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format('00h05') ); } // At this point, we need to do some argument juggling... nargs -= 1; // henceforth, the number of available arguments is `nargs+1` @@ -292,7 +292,7 @@ function filledarrayBy() { // Check if we were provided only a callback and a "this" context.. if ( nargs === 0 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format('00h05') ); } } else { // "this" context is left undefined... @@ -305,12 +305,12 @@ function filledarrayBy() { nargs -= 1; clbk = arguments[ nargs ]; if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '00h2b', clbk ) ); } } // If we were only provided 2 arguments and the last argument was not a function, we've been provided an insufficient number of arguments... else { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format('00h05') ); } // Now that we've processed the callback arguments, let's continue working backward to see if we've been provided a `dtype` argument... nargs -= 1; @@ -322,7 +322,7 @@ function filledarrayBy() { } ctor = ctors( dtype ); if ( ctor === null ) { - throw new TypeError( format( 'invalid argument. Must provide a recognized data type. Value: `%s`.', dtype ) ); + throw new TypeError( format( '00h2Y', dtype ) ); } // At this point, we've resolved the output array data type, and now we can actually create the output array... if ( dtype === 'generic' ) { @@ -337,26 +337,26 @@ function filledarrayBy() { return filledArray( len, clbk, thisArg ); } if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format('00h04') ); } if ( isObject( arg ) ) { if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2Z', arg ) ); } if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } arg = arg[ ITERATOR_SYMBOL ](); if ( !isFunction( arg.next ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } return filledArrayIterator( arg, clbk, thisArg ); } - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } else if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format('00h04') ); } - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } if ( nargs === 0 ) { // length || array-like || ArrayBuffer || iterable arg = arguments[ 0 ]; @@ -368,18 +368,18 @@ function filledarrayBy() { arr = new ctor( arg ); } else if ( isObject( arg ) ) { if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2Z', arg ) ); } if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } arg = arg[ ITERATOR_SYMBOL ](); if ( !isFunction( arg.next ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } arr = new ctor( iterLength( arg ) ); } else { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } } else if ( nargs === 1 ) { arr = new ctor( arguments[0], arguments[1] ); // (ArrayBuffer, byteOffset) diff --git a/package.json b/package.json index 0edfb95..ecbe58e 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "@stdlib/assert-is-string": "^0.2.3", "@stdlib/blas-ext-base-gfill-by": "^0.2.3", "@stdlib/iter-length": "^0.2.3", - "@stdlib/string-format": "^0.2.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.3", "@stdlib/symbol-iterator": "^0.2.3", "@stdlib/types": "^0.4.3", "@stdlib/error-tools-fmtprodmsg": "^0.2.3" From 72dda4fdffbff1a5fb59209b600f4bf0e6ab552f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 16 Mar 2026 03:47:07 +0000 Subject: [PATCH 101/117] Remove files --- index.d.ts | 322 ---- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5169 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index cb63cd1..0000000 --- a/index.d.ts +++ /dev/null @@ -1,322 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, RealOrComplexTypedArray, BooleanArray, DataType } from '@stdlib/types/array'; -import { IterableIterator } from '@stdlib/types/iter'; - -/** -* Array or typed array. -*/ -type ArrayOrTypedArray = Array | RealOrComplexTypedArray | BooleanArray; - -/** -* Nullary callback function. -* -* @returns fill value -*/ -type Nullary = () => any; - -/** -* Unary callback function. -* -* @param i - current array index -* @returns fill value -*/ -type Unary = ( i: number ) => any; - -/** -* Callback function. -* -* @param i - current array index -* @returns fill value -*/ -type Callback = Nullary | Unary; - -/** -* Creates a filled array according to a provided callback function and having a specified data type. -* -* @param dtype - data type -* @returns filled array -* -* @example -* var arr = filledarrayBy(); -* // returns -* -* @example -* var arr = filledarrayBy( 'float32' ); -* // returns -*/ -declare function filledarrayBy( dtype?: DataType ): ArrayOrTypedArray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Creates a filled array according to a provided callback function and having a specified `length`. -* -* @param length - array length -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* -* var arr = filledarrayBy( 5, constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( length: number, clbk: Callback, thisArg?: any ): ArrayOrTypedArray; - -/** -* Creates a filled array according to a provided callback function and having a specified `length`. -* -* @param length - array length -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* -* var arr = filledarrayBy( 5, 'float64', constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( length: number, dtype: DataType, clbk: Callback, thisArg?: any ): ArrayOrTypedArray; - -/** -* Creates a filled array from another `array` according to a provided callback function. -* -* @param array - typed array or array-like object -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* -* 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; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Creates a filled array from another `array` according to a provided callback function. -* -* @param array - typed array or array-like object -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* -* 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; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Creates a filled array from an iterable according to a callback function. -* -* @param iterable - iterable -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var iterConstant = require( '@stdlib/iter-constant' ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarrayBy( it, constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( iterable: IterableIterator, clbk: Callback, thisArg?: any ): ArrayOrTypedArray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Creates a filled array from an iterable according to a callback function. -* -* @param iterable - iterable -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var iterConstant = require( '@stdlib/iter-constant' ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarrayBy( it, 'float64', constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( iterable: IterableIterator, dtype: DataType, clbk: 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. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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 | BooleanArray; - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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 | BooleanArray; - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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 | BooleanArray; - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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 | BooleanArray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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 | BooleanArray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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 | BooleanArray; // eslint-disable-line @typescript-eslint/unified-signatures - - -// EXPORTS // - -export = filledarrayBy; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 6f157fa..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.3-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.3-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@v0.0.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.3-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.3-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.3-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-ctors@v0.3.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill-by@v0.2.3-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled-by@v0.2.3-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.2.3-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.3-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@v0.2.3-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.4.1-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";var v=f(),g=j.get("dtypes.default");function c(){var f,j,c,b,y,x,u,E;if(0===(j=arguments.length))return new(y=d(g))(0);if(r(c=arguments[0])){if(j>1)throw new TypeError(w("00h05"));if(null===(y=d(c)))throw new TypeError(w("00h2Y",c));return new y(0)}if(j<2)throw new TypeError(w("00h05"));if(h(arguments[j-=1]))if(h(arguments[j-1])){if(f=arguments[j],b=arguments[j-=1],0===j)throw new TypeError(w("00h05"))}else b=arguments[j];else{if(!(j>=2))throw new TypeError(w("00h05"));if(f=arguments[j],!h(b=arguments[j-=1]))throw new TypeError(w("00h2b",b))}if((j-=1)>=0&&r(arguments[j])?(c=arguments[j],j-=1):c=g,null===(y=d(c)))throw new TypeError(w("00h2Y",c));if("generic"===c){if(E=arguments[0],0===j){if(e(E)?u=E:i(E)&&(u=E.length),void 0!==u)return m(u,b,f);if(n(E))throw new Error(w("00h04"));if(o(E)){if(!1===v)throw new TypeError(w("00h2Z",E));if(!h(E[p]))throw new TypeError(w("00h2a",E));if(E=E[p](),!h(E.next))throw new TypeError(w("00h2a",E));return function(r,e,t){var s,i;for(s=[],i=-1;!r.next().done;)i+=1,s.push(e.call(t,i));return s}(E,b,f)}throw new TypeError(w("00h2a",E))}if(n(E))throw new Error(w("00h04"));throw new TypeError(w("00h2a",E))}if(0===j)if(i(E=arguments[0]))x=new y(E.length);else if(n(E))x=new y(E);else if(e(E))x=new y(E);else{if(!o(E))throw new TypeError(w("00h2a",E));if(!1===v)throw new TypeError(w("00h2Z",E));if(!h(E[p]))throw new TypeError(w("00h2a",E));if(E=E[p](),!h(E.next))throw new TypeError(w("00h2a",E));x=new y(a(E))}else x=1===j?new y(arguments[0],arguments[1]):new y(arguments[0],arguments[1],arguments[2]);return x.length>0&&(t(c)||s(c)?function(r,e,t){var s;for(s=0;s\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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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( format('00h05') );\n\t\t}\n\t\tctor = ctors( dtype );\n\t\tif ( ctor === null ) {\n\t\t\tthrow new TypeError( format( '00h2Y', 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( format('00h05') );\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( format('00h05') );\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( '00h2b', clbk ) );\n\t\t}\n\t}\n\t// If we 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( format('00h05') );\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( '00h2Y', 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( format('00h04') );\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( '00h2Z', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00h2a', 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( '00h2a', 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( '00h2a', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format('00h04') );\n\t\t}\n\t\tthrow new TypeError( format( '00h2a', 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( '00h2Z', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00h2a', 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( '00h2a', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00h2a', 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\nexport default filledarrayBy;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","DEFAULT_DTYPE","defaults","get","filledarrayBy","thisArg","nargs","dtype","clbk","ctor","arr","len","arg","arguments","length","ctors","isString","TypeError","format","isFunction","isNonNegativeInteger","isCollection","filledArray","isArrayBuffer","Error","isObject","ITERATOR_SYMBOL","next","it","i","done","push","call","filledArrayIterator","iterLength","isComplexDataType","isBooleanDataType","set","filledAccessors","gfillBy","value","aidx"],"mappings":";;sjDA0CA,IAAIA,EAAsBC,IACtBC,EAAgBC,EAASC,IAAK,kBA2MlC,SAASC,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAKJ,GAAe,KAHfN,EAAQO,UAAUC,QAKjB,OAAO,IADPL,EAAOM,EAAOd,IACG,GAIlB,GAAKe,EADLT,EAAQM,UAAW,IACM,CAExB,GAAKP,EAAQ,EACZ,MAAM,IAAIW,UAAWC,EAAO,UAG7B,GAAc,QADdT,EAAOM,EAAOR,IAEb,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,OAAO,IAAIE,EAAM,EACjB,CAED,GAAKH,EAAQ,EACZ,MAAM,IAAIW,UAAWC,EAAO,UAM7B,GAAKC,EAAYN,UAHjBP,GAAS,IAKR,GAAKa,EAAYN,UAAWP,EAAM,KAMjC,GALAD,EAAUQ,UAAWP,GAErBE,EAAOK,UADPP,GAAS,GAIM,IAAVA,EACJ,MAAM,IAAIW,UAAWC,EAAO,eAI7BV,EAAOK,UAAWP,OAIf,MAAKA,GAAS,GAUlB,MAAM,IAAIW,UAAWC,EAAO,UAN5B,GAHAb,EAAUQ,UAAWP,IAGfa,EADNX,EAAOK,UADPP,GAAS,IAGR,MAAM,IAAIW,UAAWC,EAAQ,QAASV,GAMvC,CAUD,IARAF,GAAS,IACK,GAAKU,EAAUH,UAAWP,KACvCC,EAAQM,UAAWP,GACnBA,GAAS,GAETC,EAAQN,EAGK,QADdQ,EAAOM,EAAOR,IAEb,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,GAAe,YAAVA,EAAsB,CAE1B,GADAK,EAAMC,UAAW,GACF,IAAVP,EAAc,CAMlB,GALKc,EAAsBR,GAC1BD,EAAMC,EACKS,EAAcT,KACzBD,EAAMC,EAAIE,aAEE,IAARH,EACJ,OAAOW,EAAaX,EAAKH,EAAMH,GAEhC,GAAKkB,EAAeX,GACnB,MAAM,IAAIY,MAAON,EAAO,UAEzB,GAAKO,EAAUb,GAAQ,CACtB,IAA6B,IAAxBb,EACJ,MAAM,IAAIkB,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAYP,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLP,EAAYP,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvC,OAvSJ,SAA8BgB,EAAIpB,EAAMH,GACvC,IAAIK,EACAmB,EAKJ,IAFAnB,EAAM,GACNmB,GAAK,GAEAD,EAAGD,OACAG,MAGPD,GAAK,EACLnB,EAAIqB,KAAMvB,EAAKwB,KAAM3B,EAASwB,IAE/B,OAAOnB,CACR,CAuRWuB,CAAqBrB,EAAKJ,EAAMH,EACvC,CACD,MAAM,IAAIY,UAAWC,EAAQ,QAASN,GACzC,CAAS,GAAKW,EAAeX,GAC1B,MAAM,IAAIY,MAAON,EAAO,UAEzB,MAAM,IAAID,UAAWC,EAAQ,QAASN,GACtC,CACD,GAAe,IAAVN,EAEJ,GAAKe,EADLT,EAAMC,UAAW,IAEhBH,EAAM,IAAID,EAAMG,EAAIE,aACd,GAAKS,EAAeX,GAC1BF,EAAM,IAAID,EAAMG,QACV,GAAKQ,EAAsBR,GACjCF,EAAM,IAAID,EAAMG,OACV,KAAKa,EAAUb,GAarB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAZtC,IAA6B,IAAxBb,EACJ,MAAM,IAAIkB,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAYP,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLP,EAAYP,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvCF,EAAM,IAAID,EAAMyB,EAAYtB,GAG5B,MAEDF,EADqB,IAAVJ,EACL,IAAIG,EAAMI,UAAU,GAAIA,UAAU,IAElC,IAAIJ,EAAMI,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKH,EAAII,OAAS,IACZqB,EAAmB5B,IAAW6B,EAAmB7B,GAjTxD,SAA0BG,EAAKF,EAAMH,GACpC,IAAIwB,EACJ,IAAMA,EAAI,EAAGA,EAAInB,EAAII,OAAQe,IAC5BnB,EAAI2B,IAAK7B,EAAKwB,KAAM3B,EAASwB,GAAKA,EAGpC,CA4SGS,CAAiB5B,EAAKF,EAAMH,GAE5BkC,EAAS7B,EAAII,OAAQJ,EAAK,GAe5B,SAAmB8B,EAAOC,GACzB,OAAOjC,EAAKwB,KAAM3B,EAASoC,EAC3B,KAdM/B,CAeR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index dabf69c..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 5c21c3e4c723394f77055b7b8a1a4dd302179485 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 16 Mar 2026 03:47:32 +0000 Subject: [PATCH 102/117] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 101 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 199 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 236 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 49 +- SECURITY.md | 5 - benchmark/benchmark.js | 342 -- benchmark/benchmark.length.bool.js | 98 - benchmark/benchmark.length.complex128.js | 99 - benchmark/benchmark.length.complex64.js | 99 - benchmark/benchmark.length.float32.js | 98 - benchmark/benchmark.length.float64.js | 98 - benchmark/benchmark.length.generic.js | 98 - benchmark/benchmark.length.int16.js | 98 - benchmark/benchmark.length.int32.js | 98 - benchmark/benchmark.length.int8.js | 98 - benchmark/benchmark.length.uint16.js | 98 - benchmark/benchmark.length.uint32.js | 98 - benchmark/benchmark.length.uint8.js | 98 - benchmark/benchmark.length.uint8c.js | 98 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 36 - dist/index.js.map | 7 - docs/repl.txt | 157 - docs/types/test.ts | 606 --- examples/index.js | 37 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 192 - lib/main.js | 416 -- package.json | 96 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 4397 ---------------- 57 files changed, 4870 insertions(+), 11305 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.length.bool.js delete mode 100644 benchmark/benchmark.length.complex128.js delete mode 100644 benchmark/benchmark.length.complex64.js delete mode 100644 benchmark/benchmark.length.float32.js delete mode 100644 benchmark/benchmark.length.float64.js delete mode 100644 benchmark/benchmark.length.generic.js delete mode 100644 benchmark/benchmark.length.int16.js delete mode 100644 benchmark/benchmark.length.int32.js delete mode 100644 benchmark/benchmark.length.int8.js delete mode 100644 benchmark/benchmark.length.uint16.js delete mode 100644 benchmark/benchmark.length.uint32.js delete mode 100644 benchmark/benchmark.length.uint8.js delete mode 100644 benchmark/benchmark.length.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 0ecb104..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2026-03-16T01:40:10.545Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 2d6aaee..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/contributing/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index f988046..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index b2c1f9c..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '42 6 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 83d50c4..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,821 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send notification to Zulip if job fails: - - name: 'Send notification to Zulip in case of failure' - # Pin action to full length commit SHA - uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 - if: failure() - with: - api-key: ${{ secrets.ZULIP_API_KEY }} - email: 'github-actions-bot@stdlib.zulipchat.com' - organization-url: 'https://stdlib.zulipchat.com' - to: 'workflows-standalone' - type: 'stream' - topic: ${{ github.event.repository.name }} - content: | - :cross_mark: **${{ github.workflow }}** workflow failed - - **Repository:** [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) - **Run:** [View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -278,7 +269,7 @@ for ( i = 0; i < dt.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -347,13 +338,13 @@ Copyright © 2016-2026. 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/dtypes]: https://github.com/stdlib-js/array-dtypes/tree/esm -[@stdlib/array/filled]: https://github.com/stdlib-js/array-filled +[@stdlib/array/filled]: https://github.com/stdlib-js/array-filled/tree/esm -[@stdlib/array/typed]: https://github.com/stdlib-js/array-typed +[@stdlib/array/typed]: https://github.com/stdlib-js/array-typed/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 6fba606..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,342 +0,0 @@ -/** -* @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 isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); -var isArray = require( '@stdlib/assert-is-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var Complex64 = require( '@stdlib/complex-float32-ctor' ); -var Complex128 = require( '@stdlib/complex-float64-ctor' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var filledarrayBy = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 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( format( '%s:dtype=float64', pkg ), function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'float64', 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( format( '%s:dtype=float32', pkg ), function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'float32', 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( format( '%s:dtype=bool', pkg ), 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( format( '%s:dtype=complex128', pkg ), function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( new Complex128( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'complex128', 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( format( '%s:dtype=complex64', pkg ), function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( new Complex64( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'complex64', 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( format( '%s:dtype=int32', pkg ), function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int32', 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( format( '%s:dtype=uint32', pkg ), function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint32', 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( format( '%s:dtype=int16', pkg ), function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int16', 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( format( '%s:dtype=uint16', pkg ), function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint16', 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( format( '%s:dtype=int8', pkg ), function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int8', 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( format( '%s:dtype=uint8', pkg ), function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint8', 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( format( '%s:dtype=uint8c', pkg ), function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint8c', 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( format( '%s:dtype=generic', pkg ), function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'generic', clbk ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.length.bool.js b/benchmark/benchmark.length.bool.js deleted file mode 100644 index 52b3237..0000000 --- a/benchmark/benchmark.length.bool.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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 format = require( '@stdlib/string-format' ); -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( format( '%s:dtype=bool,len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.complex128.js b/benchmark/benchmark.length.complex128.js deleted file mode 100644 index 63c0843..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,99 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 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 Complex128 = require( '@stdlib/complex-float64-ctor' ); -var format = require( '@stdlib/string-format' ); -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( new Complex128( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'complex128', 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( format( '%s:dtype=complex128,len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.complex64.js b/benchmark/benchmark.length.complex64.js deleted file mode 100644 index 186f811..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,99 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 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 Complex64 = require( '@stdlib/complex-float32-ctor' ); -var format = require( '@stdlib/string-format' ); -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( new Complex64( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'complex64', 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( format( '%s:dtype=complex64,len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.float32.js b/benchmark/benchmark.length.float32.js deleted file mode 100644 index 5ba3130..0000000 --- a/benchmark/benchmark.length.float32.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/string-format' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'float32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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( format( '%s:dtype=float32,len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.float64.js b/benchmark/benchmark.length.float64.js deleted file mode 100644 index 4a2be6c..0000000 --- a/benchmark/benchmark.length.float64.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/string-format' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'float64', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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( format( '%s:dtype=float64,len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.generic.js b/benchmark/benchmark.length.generic.js deleted file mode 100644 index 6522748..0000000 --- a/benchmark/benchmark.length.generic.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isArray = require( '@stdlib/assert-is-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/string-format' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'generic', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isArray( 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( format( '%s:dtype=generic,len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int16.js b/benchmark/benchmark.length.int16.js deleted file mode 100644 index 9ac94e9..0000000 --- a/benchmark/benchmark.length.int16.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/string-format' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int16', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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( format( '%s:dtype=int16,len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int32.js b/benchmark/benchmark.length.int32.js deleted file mode 100644 index a5ce4d0..0000000 --- a/benchmark/benchmark.length.int32.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/string-format' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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( format( '%s:dtype=int32,len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int8.js b/benchmark/benchmark.length.int8.js deleted file mode 100644 index 6104616..0000000 --- a/benchmark/benchmark.length.int8.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/string-format' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int8', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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( format( '%s:dtype=int8,len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint16.js b/benchmark/benchmark.length.uint16.js deleted file mode 100644 index 3108633..0000000 --- a/benchmark/benchmark.length.uint16.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/string-format' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint16', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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( format( '%s:dtype=uint16,len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint32.js b/benchmark/benchmark.length.uint32.js deleted file mode 100644 index 602e232..0000000 --- a/benchmark/benchmark.length.uint32.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/string-format' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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( format( '%s:dtype=uint32,len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint8.js b/benchmark/benchmark.length.uint8.js deleted file mode 100644 index 8664da3..0000000 --- a/benchmark/benchmark.length.uint8.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/string-format' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint8', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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( format( '%s:dtype=uint8,len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint8c.js b/benchmark/benchmark.length.uint8c.js deleted file mode 100644 index 76645b9..0000000 --- a/benchmark/benchmark.length.uint8c.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/string-format' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint8c', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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( format( '%s:dtype=uint8c,len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index c138144..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by" -%% click B href "https://github.com/stdlib-js/array-filled-by/tree/main" -%% click C href "https://github.com/stdlib-js/array-filled-by/tree/production" -%% click D href "https://github.com/stdlib-js/array-filled-by/tree/esm" -%% click E href "https://github.com/stdlib-js/array-filled-by/tree/deno" -%% click F href "https://github.com/stdlib-js/array-filled-by/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by -[production-url]: https://github.com/stdlib-js/array-filled-by/tree/production -[deno-url]: https://github.com/stdlib-js/array-filled-by/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-filled-by/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-filled-by/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-filled-by/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-filled-by/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-filled-by/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 188fc9b..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import filledarrayBy from '../docs/types/index'; -export = filledarrayBy; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 65ae3db..0000000 --- a/dist/index.js +++ /dev/null @@ -1,36 +0,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 deleted file mode 100644 index b348e92..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "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 we 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,YACjDC,EAAuB,QAAS,uCAAwC,EAAE,YAC1EC,EAAoB,QAAS,+DAAgE,EAC7FC,EAAoB,QAAS,gDAAiD,EAC9EC,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,EAAQ,UAAU,OAGbA,IAAU,EACd,OAAAE,EAAOrB,EAAOS,CAAc,EACrB,IAAIY,EAAM,CAAE,EAIpB,GADAD,EAAQ,UAAW,CAAE,EAChB5B,EAAU4B,CAAM,EAAI,CAExB,GAAKD,EAAQ,EACZ,MAAM,IAAI,UAAW,2FAA4F,EAGlH,GADAE,EAAOrB,EAAOoB,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWd,EAAQ,sEAAuEa,CAAM,CAAE,EAG7G,OAAO,IAAIC,EAAM,CAAE,CACpB,CAEA,GAAKF,EAAQ,EACZ,MAAM,IAAI,UAAW,2FAA4F,EAMlH,GAHAA,GAAS,EAGJpB,EAAY,UAAWoB,CAAM,CAAE,EAEnC,GAAKpB,EAAY,UAAWoB,EAAM,CAAE,CAAE,GAMrC,GALAN,EAAU,UAAWM,CAAM,EAC3BA,GAAS,EACTP,EAAO,UAAWO,CAAM,EAGnBA,IAAU,EACd,MAAM,IAAI,UAAW,2FAA4F,OAIlHP,EAAO,UAAWO,CAAM,UAIhBA,GAAS,GAIlB,GAHAN,EAAU,UAAWM,CAAM,EAC3BA,GAAS,EACTP,EAAO,UAAWO,CAAM,EACnB,CAACpB,EAAYa,CAAK,EACtB,MAAM,IAAI,UAAWL,EAAQ,uEAAwEK,CAAK,CAAE,MAK7G,OAAM,IAAI,UAAW,2FAA4F,EAWlH,GARAO,GAAS,EACJA,GAAS,GAAK3B,EAAU,UAAW2B,CAAM,CAAE,GAC/CC,EAAQ,UAAWD,CAAM,EACzBA,GAAS,GAETC,EAAQX,EAETY,EAAOrB,EAAOoB,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWd,EAAQ,sEAAuEa,CAAM,CAAE,EAG7G,GAAKA,IAAU,UAAY,CAE1B,GADAG,EAAM,UAAW,CAAE,EACdJ,IAAU,EAAI,CAMlB,GALK1B,EAAsB8B,CAAI,EAC9BD,EAAMC,EACK3B,EAAc2B,CAAI,IAC7BD,EAAMC,EAAI,QAEND,IAAQ,OACZ,OAAOpB,EAAaoB,EAAKV,EAAMC,CAAQ,EAExC,GAAKhB,EAAe0B,CAAI,EACvB,MAAM,IAAI,MAAO,mFAAoF,EAEtG,GAAKzB,EAAUyB,CAAI,EAAI,CACtB,GAAKf,IAAwB,GAC5B,MAAM,IAAI,UAAWD,EAAQ,sIAAuIgB,CAAI,CAAE,EAE3K,GAAK,CAACxB,EAAYwB,EAAKnB,CAAgB,CAAE,EACxC,MAAM,IAAI,UAAWG,EAAQ,wGAAyGgB,CAAI,CAAE,EAG7I,GADAA,EAAMA,EAAKnB,CAAgB,EAAE,EACxB,CAACL,EAAYwB,EAAI,IAAK,EAC1B,MAAM,IAAI,UAAWhB,EAAQ,wGAAyGgB,CAAI,CAAE,EAE7I,OAAOb,EAAqBa,EAAKX,EAAMC,CAAQ,CAChD,CACA,MAAM,IAAI,UAAWN,EAAQ,wGAAyGgB,CAAI,CAAE,CAC7I,SAAY1B,EAAe0B,CAAI,EAC9B,MAAM,IAAI,MAAO,mFAAoF,EAEtG,MAAM,IAAI,UAAWhB,EAAQ,wGAAyGgB,CAAI,CAAE,CAC7I,CACA,GAAKJ,IAAU,EAEd,GADAI,EAAM,UAAW,CAAE,EACd3B,EAAc2B,CAAI,EACtBT,EAAM,IAAIO,EAAME,EAAI,MAAO,UAChB1B,EAAe0B,CAAI,EAC9BT,EAAM,IAAIO,EAAME,CAAI,UACT9B,EAAsB8B,CAAI,EACrCT,EAAM,IAAIO,EAAME,CAAI,UACTzB,EAAUyB,CAAI,EAAI,CAC7B,GAAKf,IAAwB,GAC5B,MAAM,IAAI,UAAWD,EAAQ,sIAAuIgB,CAAI,CAAE,EAE3K,GAAK,CAACxB,EAAYwB,EAAKnB,CAAgB,CAAE,EACxC,MAAM,IAAI,UAAWG,EAAQ,wGAAyGgB,CAAI,CAAE,EAG7I,GADAA,EAAMA,EAAKnB,CAAgB,EAAE,EACxB,CAACL,EAAYwB,EAAI,IAAK,EAC1B,MAAM,IAAI,UAAWhB,EAAQ,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,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 deleted file mode 100644 index 06f3146..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,157 +0,0 @@ - -{{alias}}( [dtype] ) - Creates a filled array. - - Parameters - ---------- - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr = {{alias}}() - - > arr = {{alias}}( 'float32' ) - - - -{{alias}}( length[, dtype], clbk[, thisArg] ) - Returns a filled array according to a provided callback function and having - a specified length. - - Parameters - ---------- - length: integer - Array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > function clbk() { return 1.0; }; - > var arr = {{alias}}( 5, clbk ) - [ 1.0, 1.0, 1.0, 1.0, 1.0 ] - > arr = {{alias}}( 5, 'int32', clbk ) - [ 1, 1, 1, 1, 1 ] - - -{{alias}}( array[, dtype], clbk[, thisArg] ) - Creates a filled array from another array (or array-like object) according - to a provided callback function. - - Parameters - ---------- - array: ArrayLikeObject - Array from which to generate another array. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias}}( [ 0.5, 0.5, 0.5 ], {{alias:@stdlib/utils/constant-function}}( 2.0 ) ) - [ 2.0, 2.0, 2.0 ] - > var arr2 = {{alias}}( arr1, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( iterable[, dtype], clbk[, thisArg] ) - Creates a filled array from an iterable according to a provided callback - function. - - Parameters - ---------- - iterable: Iterable - Iterable from which to generate an array. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias:@stdlib/iter/constant}}( 3.0, {'iter': 3} ); - > var arr2 = {{alias}}( arr1, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( buffer[, byteOffset[, length]][, dtype], clbk[, thisArg] ) - Returns a filled typed array view of an ArrayBuffer according to a provided - callback function. - - The 'generic' array data type is *not* supported. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( buf, 0, 4, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0, 1.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index bb876ed..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,606 +0,0 @@ -/* -* @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. -*/ - -/// - -import { IterableIterator } from '@stdlib/types/iter'; -import filledarrayBy = require( './index' ); - - -/** -* Returns an iterator protocol-compliant object. -* -* @returns iterator protocol-compliant object -*/ -function iterator(): IterableIterator { - const obj: IterableIterator = { - [Symbol.iterator]: iterator, - 'next': next - }; - return obj; -} - -/** -* Implements the iterator protocol `next` method. -* -* @returns iterator protocol-compliant object -*/ -function next(): any { - return { - 'value': 1.0, - 'done': false - }; -} - -/** -* Callback function. -* -* @param i - current array index -* @returns return value -*/ -function clbk( i: number ): number { - return i; -} - - -// TESTS // - -// The function returns an array or typed array... -{ - filledarrayBy(); // $ExpectType ArrayOrTypedArray - filledarrayBy( 'float32' ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( 10, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( 10, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( 10, 'int32', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( 10, 'int32', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const x = new Float64Array( 10 ); - filledarrayBy( x, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( x, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( x, 'uint8', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( x, 'uint8', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const y = [ 2.0, 2.0, 2.0 ]; - filledarrayBy( y, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( y, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( y, 'float64', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( y, 'float64', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const it = iterator(); - filledarrayBy( it, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( it, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( it, 'uint8c', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( it, 'uint8c', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const buf = new ArrayBuffer( 32 ); - filledarrayBy( buf, clbk ); // $ExpectType RealOrComplexTypedArray | BooleanArray - filledarrayBy( buf, clbk, {} ); // $ExpectType RealOrComplexTypedArray | BooleanArray - - filledarrayBy( buf, 'uint32', clbk ); // $ExpectType RealOrComplexTypedArray | BooleanArray - filledarrayBy( buf, 'uint32', clbk, {} ); // $ExpectType RealOrComplexTypedArray | BooleanArray - - filledarrayBy( buf, 8, clbk ); // $ExpectType RealOrComplexTypedArray | BooleanArray - filledarrayBy( buf, 8, clbk, {} ); // $ExpectType RealOrComplexTypedArray | BooleanArray - - filledarrayBy( buf, 8, 'uint16', clbk ); // $ExpectType RealOrComplexTypedArray | BooleanArray - filledarrayBy( buf, 8, 'uint16', clbk, {} ); // $ExpectType RealOrComplexTypedArray | BooleanArray - - filledarrayBy( buf, 8, 2, clbk ); // $ExpectType RealOrComplexTypedArray | BooleanArray - filledarrayBy( buf, 8, 2, clbk, {} ); // $ExpectType RealOrComplexTypedArray | BooleanArray - - filledarrayBy( buf, 8, 2, 'int16', clbk ); // $ExpectType RealOrComplexTypedArray | BooleanArray - filledarrayBy( buf, 8, 2, 'int16', clbk, {} ); // $ExpectType RealOrComplexTypedArray | BooleanArray -} - -// The compiler throws an error if a callback function argument is not a function... -{ - filledarrayBy( 'float64', '5' ); // $ExpectError - filledarrayBy( 'float64', 1.0 ); // $ExpectError - filledarrayBy( 'float64', false ); // $ExpectError - filledarrayBy( 'float64', true ); // $ExpectError - filledarrayBy( 'float64', null ); // $ExpectError - filledarrayBy( 'float64', undefined ); // $ExpectError - filledarrayBy( 'float64', [] ); // $ExpectError - filledarrayBy( 'float64', {} ); // $ExpectError - - filledarrayBy( 'float64', '5', {} ); // $ExpectError - filledarrayBy( 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( 'float64', false, {} ); // $ExpectError - filledarrayBy( 'float64', true, {} ); // $ExpectError - filledarrayBy( 'float64', null, {} ); // $ExpectError - filledarrayBy( 'float64', undefined, {} ); // $ExpectError - filledarrayBy( 'float64', [], {} ); // $ExpectError - filledarrayBy( 'float64', {}, {} ); // $ExpectError - - filledarrayBy( 10, '5' ); // $ExpectError - filledarrayBy( 10, 1.0 ); // $ExpectError - filledarrayBy( 10, false ); // $ExpectError - filledarrayBy( 10, true ); // $ExpectError - filledarrayBy( 10, null ); // $ExpectError - filledarrayBy( 10, undefined ); // $ExpectError - filledarrayBy( 10, [] ); // $ExpectError - filledarrayBy( 10, {} ); // $ExpectError - - filledarrayBy( 10, '5', {} ); // $ExpectError - filledarrayBy( 10, 1.0, {} ); // $ExpectError - filledarrayBy( 10, false, {} ); // $ExpectError - filledarrayBy( 10, true, {} ); // $ExpectError - filledarrayBy( 10, null, {} ); // $ExpectError - filledarrayBy( 10, undefined, {} ); // $ExpectError - filledarrayBy( 10, [], {} ); // $ExpectError - filledarrayBy( 10, {}, {} ); // $ExpectError - - filledarrayBy( 10, 'float64', '5' ); // $ExpectError - filledarrayBy( 10, 'float64', 1.0 ); // $ExpectError - filledarrayBy( 10, 'float64', false ); // $ExpectError - filledarrayBy( 10, 'float64', true ); // $ExpectError - filledarrayBy( 10, 'float64', null ); // $ExpectError - filledarrayBy( 10, 'float64', undefined ); // $ExpectError - filledarrayBy( 10, 'float64', [] ); // $ExpectError - filledarrayBy( 10, 'float64', {} ); // $ExpectError - - filledarrayBy( 10, 'float64', '5', {} ); // $ExpectError - filledarrayBy( 10, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( 10, 'float64', false, {} ); // $ExpectError - filledarrayBy( 10, 'float64', true, {} ); // $ExpectError - filledarrayBy( 10, 'float64', null, {} ); // $ExpectError - filledarrayBy( 10, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( 10, 'float64', [], {} ); // $ExpectError - filledarrayBy( 10, 'float64', {}, {} ); // $ExpectError - - const x = new Float64Array( 10 ); - filledarrayBy( x, '5' ); // $ExpectError - filledarrayBy( x, 1.0 ); // $ExpectError - filledarrayBy( x, false ); // $ExpectError - filledarrayBy( x, true ); // $ExpectError - filledarrayBy( x, null ); // $ExpectError - filledarrayBy( x, undefined ); // $ExpectError - filledarrayBy( x, [] ); // $ExpectError - filledarrayBy( x, {} ); // $ExpectError - - filledarrayBy( x, '5', {} ); // $ExpectError - filledarrayBy( x, 1.0, {} ); // $ExpectError - filledarrayBy( x, false, {} ); // $ExpectError - filledarrayBy( x, true, {} ); // $ExpectError - filledarrayBy( x, null, {} ); // $ExpectError - filledarrayBy( x, undefined, {} ); // $ExpectError - filledarrayBy( x, [], {} ); // $ExpectError - filledarrayBy( x, {}, {} ); // $ExpectError - - filledarrayBy( x, 'float64', '5' ); // $ExpectError - filledarrayBy( x, 'float64', 1.0 ); // $ExpectError - filledarrayBy( x, 'float64', false ); // $ExpectError - filledarrayBy( x, 'float64', true ); // $ExpectError - filledarrayBy( x, 'float64', null ); // $ExpectError - filledarrayBy( x, 'float64', undefined ); // $ExpectError - filledarrayBy( x, 'float64', [] ); // $ExpectError - filledarrayBy( x, 'float64', {} ); // $ExpectError - - filledarrayBy( x, 'float64', '5', {} ); // $ExpectError - filledarrayBy( x, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( x, 'float64', false, {} ); // $ExpectError - filledarrayBy( x, 'float64', true, {} ); // $ExpectError - filledarrayBy( x, 'float64', null, {} ); // $ExpectError - filledarrayBy( x, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( x, 'float64', [], {} ); // $ExpectError - filledarrayBy( x, 'float64', {}, {} ); // $ExpectError - - const y = [ 2.0, 2.0, 2.0 ]; - filledarrayBy( y, '5' ); // $ExpectError - filledarrayBy( y, 1.0 ); // $ExpectError - filledarrayBy( y, false ); // $ExpectError - filledarrayBy( y, true ); // $ExpectError - filledarrayBy( y, null ); // $ExpectError - filledarrayBy( y, undefined ); // $ExpectError - filledarrayBy( y, [] ); // $ExpectError - filledarrayBy( y, {} ); // $ExpectError - - filledarrayBy( y, '5', {} ); // $ExpectError - filledarrayBy( y, 1.0, {} ); // $ExpectError - filledarrayBy( y, false, {} ); // $ExpectError - filledarrayBy( y, true, {} ); // $ExpectError - filledarrayBy( y, null, {} ); // $ExpectError - filledarrayBy( y, undefined, {} ); // $ExpectError - filledarrayBy( y, [], {} ); // $ExpectError - filledarrayBy( y, {}, {} ); // $ExpectError - - filledarrayBy( y, 'float64', '5' ); // $ExpectError - filledarrayBy( y, 'float64', 1.0 ); // $ExpectError - filledarrayBy( y, 'float64', false ); // $ExpectError - filledarrayBy( y, 'float64', true ); // $ExpectError - filledarrayBy( y, 'float64', null ); // $ExpectError - filledarrayBy( y, 'float64', undefined ); // $ExpectError - filledarrayBy( y, 'float64', [] ); // $ExpectError - filledarrayBy( y, 'float64', {} ); // $ExpectError - - filledarrayBy( y, 'float64', '5', {} ); // $ExpectError - filledarrayBy( y, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( y, 'float64', false, {} ); // $ExpectError - filledarrayBy( y, 'float64', true, {} ); // $ExpectError - filledarrayBy( y, 'float64', null, {} ); // $ExpectError - filledarrayBy( y, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( y, 'float64', [], {} ); // $ExpectError - filledarrayBy( y, 'float64', {}, {} ); // $ExpectError - - const it = iterator(); - filledarrayBy( it, '5' ); // $ExpectError - filledarrayBy( it, 1.0 ); // $ExpectError - filledarrayBy( it, false ); // $ExpectError - filledarrayBy( it, true ); // $ExpectError - filledarrayBy( it, null ); // $ExpectError - filledarrayBy( it, undefined ); // $ExpectError - filledarrayBy( it, [] ); // $ExpectError - filledarrayBy( it, {} ); // $ExpectError - - filledarrayBy( it, '5', {} ); // $ExpectError - filledarrayBy( it, 1.0, {} ); // $ExpectError - filledarrayBy( it, false, {} ); // $ExpectError - filledarrayBy( it, true, {} ); // $ExpectError - filledarrayBy( it, null, {} ); // $ExpectError - filledarrayBy( it, undefined, {} ); // $ExpectError - filledarrayBy( it, [], {} ); // $ExpectError - filledarrayBy( it, {}, {} ); // $ExpectError - - filledarrayBy( it, 'float64', '5' ); // $ExpectError - filledarrayBy( it, 'float64', 1.0 ); // $ExpectError - filledarrayBy( it, 'float64', false ); // $ExpectError - filledarrayBy( it, 'float64', true ); // $ExpectError - filledarrayBy( it, 'float64', null ); // $ExpectError - filledarrayBy( it, 'float64', undefined ); // $ExpectError - filledarrayBy( it, 'float64', [] ); // $ExpectError - filledarrayBy( it, 'float64', {} ); // $ExpectError - - filledarrayBy( it, 'float64', '5', {} ); // $ExpectError - filledarrayBy( it, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( it, 'float64', false, {} ); // $ExpectError - filledarrayBy( it, 'float64', true, {} ); // $ExpectError - filledarrayBy( it, 'float64', null, {} ); // $ExpectError - filledarrayBy( it, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( it, 'float64', [], {} ); // $ExpectError - filledarrayBy( it, 'float64', {}, {} ); // $ExpectError - - const buf = new ArrayBuffer( 32 ); - filledarrayBy( buf, '5' ); // $ExpectError - filledarrayBy( buf, 1.0 ); // $ExpectError - filledarrayBy( buf, false ); // $ExpectError - filledarrayBy( buf, true ); // $ExpectError - filledarrayBy( buf, null ); // $ExpectError - filledarrayBy( buf, undefined ); // $ExpectError - filledarrayBy( buf, [] ); // $ExpectError - filledarrayBy( buf, {} ); // $ExpectError - - filledarrayBy( buf, '5', {} ); // $ExpectError - filledarrayBy( buf, 1.0, {} ); // $ExpectError - filledarrayBy( buf, false, {} ); // $ExpectError - filledarrayBy( buf, true, {} ); // $ExpectError - filledarrayBy( buf, null, {} ); // $ExpectError - filledarrayBy( buf, undefined, {} ); // $ExpectError - filledarrayBy( buf, [], {} ); // $ExpectError - filledarrayBy( buf, {}, {} ); // $ExpectError - - filledarrayBy( buf, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 'float64', false ); // $ExpectError - filledarrayBy( buf, 'float64', true ); // $ExpectError - filledarrayBy( buf, 'float64', null ); // $ExpectError - filledarrayBy( buf, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 'float64', {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5' ); // $ExpectError - filledarrayBy( buf, 8, 1.0 ); // $ExpectError - filledarrayBy( buf, 8, false ); // $ExpectError - filledarrayBy( buf, 8, true ); // $ExpectError - filledarrayBy( buf, 8, null ); // $ExpectError - filledarrayBy( buf, 8, undefined ); // $ExpectError - filledarrayBy( buf, 8, [] ); // $ExpectError - filledarrayBy( buf, 8, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, false, {} ); // $ExpectError - filledarrayBy( buf, 8, true, {} ); // $ExpectError - filledarrayBy( buf, 8, null, {} ); // $ExpectError - filledarrayBy( buf, 8, undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, [], {} ); // $ExpectError - filledarrayBy( buf, 8, {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 8, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 'float64', false ); // $ExpectError - filledarrayBy( buf, 8, 'float64', true ); // $ExpectError - filledarrayBy( buf, 8, 'float64', null ); // $ExpectError - filledarrayBy( buf, 8, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 8, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 8, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 8, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, '5' ); // $ExpectError - filledarrayBy( buf, 8, 2, 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 2, false ); // $ExpectError - filledarrayBy( buf, 8, 2, true ); // $ExpectError - filledarrayBy( buf, 8, 2, null ); // $ExpectError - filledarrayBy( buf, 8, 2, undefined ); // $ExpectError - filledarrayBy( buf, 8, 2, [] ); // $ExpectError - filledarrayBy( buf, 8, 2, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, false, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, true, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, null, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, [], {} ); // $ExpectError - filledarrayBy( buf, 8, 2, {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', false ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', true ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', null ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', {}, {} ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid length, typed array, array-like object, `ArrayBuffer`, or iterable argument... -{ - filledarrayBy( false, clbk ); // $ExpectError - filledarrayBy( true, clbk ); // $ExpectError - filledarrayBy( null, clbk ); // $ExpectError - filledarrayBy( {}, clbk ); // $ExpectError - - filledarrayBy( false, clbk, {} ); // $ExpectError - filledarrayBy( true, clbk, {} ); // $ExpectError - filledarrayBy( null, clbk, {} ); // $ExpectError - filledarrayBy( {}, clbk, {} ); // $ExpectError - - filledarrayBy( false, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 'float64', clbk ); // $ExpectError - - filledarrayBy( false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, clbk ); // $ExpectError - filledarrayBy( 1.0, 8, clbk ); // $ExpectError - filledarrayBy( false, 8, clbk ); // $ExpectError - filledarrayBy( true, 8, clbk ); // $ExpectError - filledarrayBy( null, 8, clbk ); // $ExpectError - filledarrayBy( undefined, 8, clbk ); // $ExpectError - filledarrayBy( [], 8, clbk ); // $ExpectError - filledarrayBy( {}, 8, clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, clbk ); // $ExpectError - - filledarrayBy( '5', 8, clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, clbk, {} ); // $ExpectError - filledarrayBy( false, 8, clbk, {} ); // $ExpectError - filledarrayBy( true, 8, clbk, {} ); // $ExpectError - filledarrayBy( null, 8, clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, clbk, {} ); // $ExpectError - filledarrayBy( [], 8, clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 'float64', clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( false, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( [], 8, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 'float64', clbk ); // $ExpectError - - filledarrayBy( '5', 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 2, clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 2, clbk ); // $ExpectError - filledarrayBy( false, 8, 2, clbk ); // $ExpectError - filledarrayBy( true, 8, 2, clbk ); // $ExpectError - filledarrayBy( null, 8, 2, clbk ); // $ExpectError - filledarrayBy( undefined, 8, 2, clbk ); // $ExpectError - filledarrayBy( [], 8, 2, clbk ); // $ExpectError - filledarrayBy( {}, 8, 2, clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, clbk ); // $ExpectError - - filledarrayBy( '5', 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( false, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( [], 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, 'float64', clbk ); // $ExpectError - - filledarrayBy( '5', 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a byte offset argument which is not a number... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, false, clbk ); // $ExpectError - filledarrayBy( buf, true, clbk ); // $ExpectError - filledarrayBy( buf, null, clbk ); // $ExpectError - filledarrayBy( buf, [], clbk ); // $ExpectError - filledarrayBy( buf, {}, clbk ); // $ExpectError - - filledarrayBy( buf, false, clbk, {} ); // $ExpectError - filledarrayBy( buf, true, clbk, {} ); // $ExpectError - filledarrayBy( buf, null, clbk, {} ); // $ExpectError - filledarrayBy( buf, [], clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, clbk, {} ); // $ExpectError - - filledarrayBy( buf, '5', 'float64', clbk ); // $ExpectError - filledarrayBy( buf, false, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, true, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, null, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, [], 'float64', clbk ); // $ExpectError - filledarrayBy( buf, {}, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, '5', 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( buf, false, 2, clbk ); // $ExpectError - filledarrayBy( buf, true, 2, clbk ); // $ExpectError - filledarrayBy( buf, null, 2, clbk ); // $ExpectError - filledarrayBy( buf, [], 2, clbk ); // $ExpectError - filledarrayBy( buf, {}, 2, clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, clbk ); // $ExpectError - - filledarrayBy( buf, false, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, clbk, {} ); // $ExpectError - - filledarrayBy( buf, '5', 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, false, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, true, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, null, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, undefined, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, [], 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, {}, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, '5', 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, false, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, undefined, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a view length argument which is not a number... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, 8, false, clbk ); // $ExpectError - filledarrayBy( buf, 8, true, clbk ); // $ExpectError - filledarrayBy( buf, 8, null, clbk ); // $ExpectError - filledarrayBy( buf, 8, [], clbk ); // $ExpectError - filledarrayBy( buf, 8, {}, clbk ); // $ExpectError - - filledarrayBy( buf, 8, false, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, true, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, null, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, [], clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, {}, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, clbk, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5', 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, false, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, true, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, null, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, [], 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, {}, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, 8, '5', 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, [], 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, {}, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided too many arguments... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, 8, 2, 'float64', 1, clbk, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 997a381..0000000 --- a/examples/index.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ).factory; -var dtypes = require( '@stdlib/array-typed-real-dtypes' ); -var filledarrayBy = require( './../lib' ); - -// Create a pseudorandom number generator: -var rand = discreteUniform( 0, 100 ); - -// Get a list of array data types: -var dt = dtypes(); - -// Generate filled arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = filledarrayBy( 10, dt[ i ], rand ); - console.log( arr ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 764e40e..cb63cd1 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, RealOrComplexTypedArray, BooleanArray, DataType } from '@stdlib/types/array'; import { IterableIterator } from '@stdlib/types/iter'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..6f157fa --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.3-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.3-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@v0.0.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.3-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.3-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.3-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-ctors@v0.3.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill-by@v0.2.3-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled-by@v0.2.3-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.2.3-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.3-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@v0.2.3-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.4.1-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";var v=f(),g=j.get("dtypes.default");function c(){var f,j,c,b,y,x,u,E;if(0===(j=arguments.length))return new(y=d(g))(0);if(r(c=arguments[0])){if(j>1)throw new TypeError(w("00h05"));if(null===(y=d(c)))throw new TypeError(w("00h2Y",c));return new y(0)}if(j<2)throw new TypeError(w("00h05"));if(h(arguments[j-=1]))if(h(arguments[j-1])){if(f=arguments[j],b=arguments[j-=1],0===j)throw new TypeError(w("00h05"))}else b=arguments[j];else{if(!(j>=2))throw new TypeError(w("00h05"));if(f=arguments[j],!h(b=arguments[j-=1]))throw new TypeError(w("00h2b",b))}if((j-=1)>=0&&r(arguments[j])?(c=arguments[j],j-=1):c=g,null===(y=d(c)))throw new TypeError(w("00h2Y",c));if("generic"===c){if(E=arguments[0],0===j){if(e(E)?u=E:i(E)&&(u=E.length),void 0!==u)return m(u,b,f);if(n(E))throw new Error(w("00h04"));if(o(E)){if(!1===v)throw new TypeError(w("00h2Z",E));if(!h(E[p]))throw new TypeError(w("00h2a",E));if(E=E[p](),!h(E.next))throw new TypeError(w("00h2a",E));return function(r,e,t){var s,i;for(s=[],i=-1;!r.next().done;)i+=1,s.push(e.call(t,i));return s}(E,b,f)}throw new TypeError(w("00h2a",E))}if(n(E))throw new Error(w("00h04"));throw new TypeError(w("00h2a",E))}if(0===j)if(i(E=arguments[0]))x=new y(E.length);else if(n(E))x=new y(E);else if(e(E))x=new y(E);else{if(!o(E))throw new TypeError(w("00h2a",E));if(!1===v)throw new TypeError(w("00h2Z",E));if(!h(E[p]))throw new TypeError(w("00h2a",E));if(E=E[p](),!h(E.next))throw new TypeError(w("00h2a",E));x=new y(a(E))}else x=1===j?new y(arguments[0],arguments[1]):new y(arguments[0],arguments[1],arguments[2]);return x.length>0&&(t(c)||s(c)?function(r,e,t){var s;for(s=0;s\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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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( format('00h05') );\n\t\t}\n\t\tctor = ctors( dtype );\n\t\tif ( ctor === null ) {\n\t\t\tthrow new TypeError( format( '00h2Y', 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( format('00h05') );\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( format('00h05') );\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( '00h2b', clbk ) );\n\t\t}\n\t}\n\t// If we 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( format('00h05') );\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( '00h2Y', 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( format('00h04') );\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( '00h2Z', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00h2a', 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( '00h2a', 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( '00h2a', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format('00h04') );\n\t\t}\n\t\tthrow new TypeError( format( '00h2a', 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( '00h2Z', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00h2a', 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( '00h2a', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00h2a', 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\nexport default filledarrayBy;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","DEFAULT_DTYPE","defaults","get","filledarrayBy","thisArg","nargs","dtype","clbk","ctor","arr","len","arg","arguments","length","ctors","isString","TypeError","format","isFunction","isNonNegativeInteger","isCollection","filledArray","isArrayBuffer","Error","isObject","ITERATOR_SYMBOL","next","it","i","done","push","call","filledArrayIterator","iterLength","isComplexDataType","isBooleanDataType","set","filledAccessors","gfillBy","value","aidx"],"mappings":";;sjDA0CA,IAAIA,EAAsBC,IACtBC,EAAgBC,EAASC,IAAK,kBA2MlC,SAASC,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAKJ,GAAe,KAHfN,EAAQO,UAAUC,QAKjB,OAAO,IADPL,EAAOM,EAAOd,IACG,GAIlB,GAAKe,EADLT,EAAQM,UAAW,IACM,CAExB,GAAKP,EAAQ,EACZ,MAAM,IAAIW,UAAWC,EAAO,UAG7B,GAAc,QADdT,EAAOM,EAAOR,IAEb,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,OAAO,IAAIE,EAAM,EACjB,CAED,GAAKH,EAAQ,EACZ,MAAM,IAAIW,UAAWC,EAAO,UAM7B,GAAKC,EAAYN,UAHjBP,GAAS,IAKR,GAAKa,EAAYN,UAAWP,EAAM,KAMjC,GALAD,EAAUQ,UAAWP,GAErBE,EAAOK,UADPP,GAAS,GAIM,IAAVA,EACJ,MAAM,IAAIW,UAAWC,EAAO,eAI7BV,EAAOK,UAAWP,OAIf,MAAKA,GAAS,GAUlB,MAAM,IAAIW,UAAWC,EAAO,UAN5B,GAHAb,EAAUQ,UAAWP,IAGfa,EADNX,EAAOK,UADPP,GAAS,IAGR,MAAM,IAAIW,UAAWC,EAAQ,QAASV,GAMvC,CAUD,IARAF,GAAS,IACK,GAAKU,EAAUH,UAAWP,KACvCC,EAAQM,UAAWP,GACnBA,GAAS,GAETC,EAAQN,EAGK,QADdQ,EAAOM,EAAOR,IAEb,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,GAAe,YAAVA,EAAsB,CAE1B,GADAK,EAAMC,UAAW,GACF,IAAVP,EAAc,CAMlB,GALKc,EAAsBR,GAC1BD,EAAMC,EACKS,EAAcT,KACzBD,EAAMC,EAAIE,aAEE,IAARH,EACJ,OAAOW,EAAaX,EAAKH,EAAMH,GAEhC,GAAKkB,EAAeX,GACnB,MAAM,IAAIY,MAAON,EAAO,UAEzB,GAAKO,EAAUb,GAAQ,CACtB,IAA6B,IAAxBb,EACJ,MAAM,IAAIkB,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAYP,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLP,EAAYP,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvC,OAvSJ,SAA8BgB,EAAIpB,EAAMH,GACvC,IAAIK,EACAmB,EAKJ,IAFAnB,EAAM,GACNmB,GAAK,GAEAD,EAAGD,OACAG,MAGPD,GAAK,EACLnB,EAAIqB,KAAMvB,EAAKwB,KAAM3B,EAASwB,IAE/B,OAAOnB,CACR,CAuRWuB,CAAqBrB,EAAKJ,EAAMH,EACvC,CACD,MAAM,IAAIY,UAAWC,EAAQ,QAASN,GACzC,CAAS,GAAKW,EAAeX,GAC1B,MAAM,IAAIY,MAAON,EAAO,UAEzB,MAAM,IAAID,UAAWC,EAAQ,QAASN,GACtC,CACD,GAAe,IAAVN,EAEJ,GAAKe,EADLT,EAAMC,UAAW,IAEhBH,EAAM,IAAID,EAAMG,EAAIE,aACd,GAAKS,EAAeX,GAC1BF,EAAM,IAAID,EAAMG,QACV,GAAKQ,EAAsBR,GACjCF,EAAM,IAAID,EAAMG,OACV,KAAKa,EAAUb,GAarB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAZtC,IAA6B,IAAxBb,EACJ,MAAM,IAAIkB,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAYP,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLP,EAAYP,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvCF,EAAM,IAAID,EAAMyB,EAAYtB,GAG5B,MAEDF,EADqB,IAAVJ,EACL,IAAIG,EAAMI,UAAU,GAAIA,UAAU,IAElC,IAAIJ,EAAMI,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKH,EAAII,OAAS,IACZqB,EAAmB5B,IAAW6B,EAAmB7B,GAjTxD,SAA0BG,EAAKF,EAAMH,GACpC,IAAIwB,EACJ,IAAMA,EAAI,EAAGA,EAAInB,EAAII,OAAQe,IAC5BnB,EAAI2B,IAAK7B,EAAKwB,KAAM3B,EAASwB,GAAKA,EAGpC,CA4SGS,CAAiB5B,EAAKF,EAAMH,GAE5BkC,EAAS7B,EAAII,OAAQJ,EAAK,GAe5B,SAAmB8B,EAAOC,GACzB,OAAOjC,EAAKwB,KAAM3B,EAASoC,EAC3B,KAdM/B,CAeR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d115cf0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,192 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -/** -* Create a filled array according to a provided callback function. -* -* @module @stdlib/array-filled-by -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* var arr = filledarrayBy(); -* // returns -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'generic', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( [ 0.5, 0.5 ], clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1; -* } -* -* var arr = filledarrayBy( [ 5, -3 ], 'int32', clbk ); -* // returns [ 1, 1 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk1() { -* return 10; -* } -* -* function clbk2() { -* return 1.0; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, clbk2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk1() { -* return 1.0; -* } -* -* function clbk2() { -* return 2; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, 'uint32', clbk2 ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 'float32', clbk ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, clbk ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, 'int32', clbk ); -* // returns [ 1, 1 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 32b6545..0000000 --- a/lib/main.js +++ /dev/null @@ -1,416 +0,0 @@ -/** -* @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 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' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var ctors = require( '@stdlib/array-ctors' ); -var gfillBy = require( '@stdlib/blas-ext-base-gfill-by' ); -var filledArray = require( '@stdlib/array-base-filled-by' ); -var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var iterLength = require( '@stdlib/iter-length' ); -var defaults = require( '@stdlib/array-defaults' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport(); -var DEFAULT_DTYPE = defaults.get( 'dtypes.default' ); - - -// FUNCTIONS // - -/** -* Creates a filled "generic" array from an iterator. -* -* @private -* @param {Iterable} it - iterator -* @param {Callback} clbk - callback function -* @param {*} thisArg - callback function execution context -* @returns {Array} filled array -*/ -function filledArrayIterator( it, clbk, thisArg ) { - var arr; - var i; - var v; - - arr = []; - i = -1; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - i += 1; - arr.push( clbk.call( thisArg, i ) ); - } - return arr; -} - -/** -* Fills an array exposing accessors for getting and setting array elements. -* -* @private -* @param {Collection} arr - input array -* @param {Callback} clbk - callback function -* @param {*} thisArg - callback function execution context -* @returns {Collection} input array -*/ -function filledAccessors( arr, clbk, thisArg ) { - var i; - for ( i = 0; i < arr.length; i++ ) { - arr.set( clbk.call( thisArg, i ), i ); - } - return arr; -} - - -// MAIN // - -/** -* Creates a filled array according to a provided callback function. -* -* @param {(NonNegativeInteger|TypedArray|ArrayLikeObject|ArrayBuffer|Iterable)} [arg] - a length, typed array, array-like object, buffer, or iterable -* @param {NonNegativeInteger} [byteOffset=0] - byte offset -* @param {NonNegativeInteger} [length] - view length -* @param {string} [dtype="float64"] - data type -* @param {Callback} [clbk] - callback to invoke -* @param {*} [thisArg] - callback execution context -* @throws {TypeError} must provide a recognized data type -* @throws {TypeError} must provide a length, typed array, array-like object, buffer, or iterable -* @throws {TypeError} callback argument must be a function. -* @throws {Error} creating a generic array from an `ArrayBuffer` is not supported -* @returns {(TypedArray|Array)} array or typed array -* -* @example -* var arr = filledarrayBy(); -* // returns -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'generic', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( [ 0.5, 0.5 ], clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1; -* } -* -* var arr = filledarrayBy( [ 5, -3 ], 'int32', clbk ); -* // returns [ 1, 1 ] -* -* @example -* function clbk1() { -* return 10; -* } -* -* function clbk2() { -* return 1.0; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, clbk2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk1() { -* return 1.0; -* } -* -* function clbk2() { -* return 2; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, 'uint32', clbk2 ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 'float32', clbk ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, clbk ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, 'int32', clbk ); -* // returns [ 1, 1 ] -*/ -function filledarrayBy() { - var thisArg; - var nargs; - var dtype; - var clbk; - var ctor; - var arr; - var len; - var arg; - - nargs = arguments.length; - - // If we weren't provided any arguments, return an empty array... - if ( nargs === 0 ) { - ctor = ctors( DEFAULT_DTYPE ); - return new ctor( 0 ); - } - // Check if we were provided a dtype as the first argument... - dtype = arguments[ 0 ]; - if ( isString( dtype ) ) { - // Invoking this function with arguments `f( dtype, clbk[, thisArg] )` is not allowed (otherwise, we'd need to also allow `f( clbk[, thisArg] )`)... - if ( nargs > 1 ) { - throw new TypeError( format('00h05') ); - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '00h2Y', dtype ) ); - } - // Return an empty array having the specified dtype: - return new ctor( 0 ); - } - // For all other supported invocations, we need at least two arguments... - if ( nargs < 2 ) { - throw new TypeError( format('00h05') ); - } - // At this point, we need to do some argument juggling... - nargs -= 1; // henceforth, the number of available arguments is `nargs+1` - - // Determine whether the last argument is a callback or "this" context... - if ( isFunction( arguments[ nargs ] ) ) { - // 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... - if ( isFunction( arguments[ nargs-1 ] ) ) { - thisArg = arguments[ nargs ]; - nargs -= 1; - clbk = arguments[ nargs ]; - - // Check if we were provided only a callback and a "this" context.. - if ( nargs === 0 ) { - throw new TypeError( format('00h05') ); - } - } else { - // "this" context is left undefined... - clbk = arguments[ nargs ]; - } - } - // 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... - else if ( nargs >= 2 ) { - thisArg = arguments[ nargs ]; - nargs -= 1; - clbk = arguments[ nargs ]; - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '00h2b', clbk ) ); - } - } - // If we were only provided 2 arguments and the last argument was not a function, we've been provided an insufficient number of arguments... - else { - throw new TypeError( format('00h05') ); - } - // Now that we've processed the callback arguments, let's continue working backward to see if we've been provided a `dtype` argument... - nargs -= 1; - if ( nargs >= 0 && isString( arguments[ nargs ] ) ) { - dtype = arguments[ nargs ]; - nargs -= 1; - } else { - dtype = DEFAULT_DTYPE; - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '00h2Y', dtype ) ); - } - // At this point, we've resolved the output array data type, and now we can actually create the output array... - if ( dtype === 'generic' ) { - arg = arguments[ 0 ]; - if ( nargs === 0 ) { - if ( isNonNegativeInteger( arg ) ) { - len = arg; - } else if ( isCollection( arg ) ) { - len = arg.length; - } - if ( len !== void 0 ) { - return filledArray( len, clbk, thisArg ); - } - if ( isArrayBuffer( arg ) ) { - throw new Error( format('00h04') ); - } - if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( '00h2Z', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00h2a', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00h2a', arg ) ); - } - return filledArrayIterator( arg, clbk, thisArg ); - } - throw new TypeError( format( '00h2a', arg ) ); - } else if ( isArrayBuffer( arg ) ) { - throw new Error( format('00h04') ); - } - throw new TypeError( format( '00h2a', arg ) ); - } - if ( nargs === 0 ) { // length || array-like || ArrayBuffer || iterable - arg = arguments[ 0 ]; - if ( isCollection( arg ) ) { - arr = new ctor( arg.length ); - } else if ( isArrayBuffer( arg ) ) { - arr = new ctor( arg ); - } else if ( isNonNegativeInteger( arg ) ) { - arr = new ctor( arg ); - } else if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( '00h2Z', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00h2a', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00h2a', arg ) ); - } - arr = new ctor( iterLength( arg ) ); - } else { - throw new TypeError( format( '00h2a', arg ) ); - } - } else if ( nargs === 1 ) { - arr = new ctor( arguments[0], arguments[1] ); // (ArrayBuffer, byteOffset) - } else { - arr = new ctor( arguments[0], arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset, length) - } - if ( arr.length > 0 ) { - if ( isComplexDataType( dtype ) || isBooleanDataType( dtype ) ) { - filledAccessors( arr, clbk, thisArg ); - } else { - gfillBy( arr.length, arr, 1, callback ); - } - } - return arr; - - /** - * Callback which wraps a provided callback and is invoked for each array element. - * - * @private - * @param {*} value - element value - * @param {NonNegativeInteger} aidx - array index - * @param {NonNegativeInteger} sidx - strided index - * @param {Collection} array - input array/collection - * @returns {*} callback return value - */ - function callback( value, aidx ) { - return clbk.call( thisArg, aidx ); - } -} - - -// EXPORTS // - -module.exports = filledarrayBy; diff --git a/package.json b/package.json index ecbe58e..026d062 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.3.1", "description": "Create a filled array according to a provided callback function.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,75 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-assert-is-boolean-data-type": "^0.0.2", - "@stdlib/array-base-assert-is-complex-floating-point-data-type": "^0.2.2", - "@stdlib/array-base-filled-by": "^0.2.3", - "@stdlib/array-ctors": "^0.3.1", - "@stdlib/array-defaults": "^0.4.1", - "@stdlib/assert-has-iterator-symbol-support": "^0.2.3", - "@stdlib/assert-is-arraybuffer": "^0.2.3", - "@stdlib/assert-is-collection": "^0.2.3", - "@stdlib/assert-is-function": "^0.2.3", - "@stdlib/assert-is-nonnegative-integer": "^0.2.3", - "@stdlib/assert-is-object": "^0.2.3", - "@stdlib/assert-is-string": "^0.2.3", - "@stdlib/blas-ext-base-gfill-by": "^0.2.3", - "@stdlib/iter-length": "^0.2.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3", - "@stdlib/symbol-iterator": "^0.2.3", - "@stdlib/types": "^0.4.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3" - }, - "devDependencies": { - "@stdlib/array-bool": "^0.1.2", - "@stdlib/array-buffer": "^0.2.3", - "@stdlib/array-complex128": "^0.3.2", - "@stdlib/array-complex64": "^0.3.2", - "@stdlib/array-float32": "^0.2.3", - "@stdlib/array-float64": "^0.2.3", - "@stdlib/array-int16": "^0.2.3", - "@stdlib/array-int32": "^0.2.3", - "@stdlib/array-int8": "^0.2.3", - "@stdlib/array-typed-real-dtypes": "^0.2.3", - "@stdlib/array-uint16": "^0.2.3", - "@stdlib/array-uint32": "^0.2.3", - "@stdlib/array-uint8": "^0.2.3", - "@stdlib/array-uint8c": "^0.2.3", - "@stdlib/assert-instance-of": "^0.3.1", - "@stdlib/assert-is-array": "^0.2.3", - "@stdlib/assert-is-typed-array": "^0.2.3", - "@stdlib/assert-is-typed-array-like": "^0.2.3", - "@stdlib/complex-float32-ctor": "^0.1.1", - "@stdlib/complex-float64-ctor": "^0.1.2", - "@stdlib/iter-constant": "^0.2.3", - "@stdlib/math-base-special-pow": "^0.3.1", - "@stdlib/random-base-discrete-uniform": "^0.2.2", - "@stdlib/strided-base-reinterpret-boolean": "^0.0.3", - "@stdlib/strided-base-reinterpret-complex128": "^0.2.3", - "@stdlib/strided-base-reinterpret-complex64": "^0.2.2", - "@stdlib/utils-constant-function": "^0.2.3", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.3" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..dabf69c --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index ca0cf25..0000000 --- a/test/test.js +++ /dev/null @@ -1,4397 +0,0 @@ -/** -* @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. -*/ - -/* eslint-disable max-len */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -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' ); -var iterConstant = require( '@stdlib/iter-constant' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var filledarrayBy = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': !hasIteratorSymbolSupport() -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof filledarrayBy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if only provided callback arguments', function test( t ) { - t.throws( clbk1, TypeError, 'throws an error' ); - t.throws( clbk2, TypeError, 'throws an error' ); - t.throws( clbk3, TypeError, 'throws an error' ); - t.end(); - - function clbk1() { - filledarrayBy( constantFunction( 1.0 ) ); - } - - function clbk2() { - filledarrayBy( constantFunction( 1.0 ), {} ); - } - - function clbk3() { - filledarrayBy( constantFunction( 1.0 ), constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (only argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (typed array; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (array-like object)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (array-like object; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 8 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 8 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, 1, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (iterator)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( iterConstant( 1.0 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (iterator; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( iterConstant( 1.0 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if only provided data type and callback arguments', function test( t ) { - t.throws( clbk1, TypeError, 'throws an error' ); - t.throws( clbk2, TypeError, 'throws an error' ); - t.throws( clbk3, TypeError, 'throws an error' ); - t.end(); - - function clbk1() { - filledarrayBy( 'float64', constantFunction( 1.0 ) ); - } - - function clbk2() { - filledarrayBy( 'float64', constantFunction( 1.0 ), {} ); - } - - function clbk3() { - filledarrayBy( 'float64', constantFunction( 1.0 ), constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (array-like object)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (array-like object; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, 1, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, 1, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (no iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (no iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (non-function iterator symbol property)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (non-function iterator symbol property; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (`next` property is not a function)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ) ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (`next` property is not a function; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ), {} ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (no iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (no iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (non-function iterator symbol property)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (non-function iterator symbol property; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (`next` property is not a function)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ) ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (`next` property is not a function; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ), {} ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 1, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 1, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function returns a filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - arr = filledarrayBy(); - - t.strictEqual( instanceOf( arr, Float64Array ), 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=float64)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - arr = filledarrayBy( 'float64' ); - - t.strictEqual( instanceOf( arr, Float64Array ), 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=float32)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( 0 ); - arr = filledarrayBy( 'float32' ); - - t.strictEqual( instanceOf( arr, Float32Array ), 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=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; - - expected = new Complex128Array( 0 ); - arr = filledarrayBy( 'complex128' ); - - t.strictEqual( instanceOf( arr, Complex128Array ), 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=complex64)', function test( t ) { - var expected; - var arr; - - expected = new Complex64Array( 0 ); - arr = filledarrayBy( 'complex64' ); - - t.strictEqual( instanceOf( arr, Complex64Array ), 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=int32)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( 0 ); - arr = filledarrayBy( 'int32' ); - - t.strictEqual( instanceOf( arr, Int32Array ), 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=uint32)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( 0 ); - arr = filledarrayBy( 'uint32' ); - - t.strictEqual( instanceOf( arr, Uint32Array ), 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=int16)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( 0 ); - arr = filledarrayBy( 'int16' ); - - t.strictEqual( instanceOf( arr, Int16Array ), 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=uint16)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( 0 ); - arr = filledarrayBy( 'uint16' ); - - t.strictEqual( instanceOf( arr, Uint16Array ), 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=int8)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( 0 ); - arr = filledarrayBy( 'int8' ); - - t.strictEqual( instanceOf( arr, Int8Array ), 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=uint8)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( 0 ); - arr = filledarrayBy( 'uint8' ); - - t.strictEqual( instanceOf( arr, Uint8Array ), 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=uint8c)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( 0 ); - arr = filledarrayBy( 'uint8c' ); - - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), 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=generic)', function test( t ) { - var expected; - var arr; - - expected = []; - arr = filledarrayBy( 'generic' ); - - t.strictEqual( instanceOf( arr, Array ), 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 (default, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, length=0)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array(); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 0, clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, clbk, ctx ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (default, length; thisArg=function)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, clbk, context ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this(); // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } - - function context() { - ctx.count += 1; - } -}); - -tape( 'the function returns a filled array (dtype=float64, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, 'float64', clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, length; thisArg=function)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, 'float64', clbk, context ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this(); // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } - - function context() { - ctx.count += 1; - } -}); - -tape( 'the function returns a filled array (dtype=float32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, 'float32', clbk ); - - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - 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; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = filledarrayBy( 5, 'complex128', clbk ); - - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = filledarrayBy( 5, 'complex64', clbk ); - - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int32Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int32', clbk ); - - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint32Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint32', clbk ); - - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int16Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int16', clbk ); - - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint16', clbk ); - - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int8Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int8', clbk ); - - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint8', clbk ); - - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint8c', clbk ); - - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = [ 1, 1, 1, 1, 1 ]; - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'generic', clbk ); - - t.strictEqual( instanceOf( arr, Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - 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; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = [ 1.0, 2.0 ]; - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = [ 1.0, 2.0 ]; - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int32', clbk ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, typed array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, typed array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - 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; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = new Float64Array( [ 1.0, 2.0 ] ); - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = new Float64Array( [ 1.0, 2.0 ] ); - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (default, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - 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; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer, byteoffset; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer, byteoffset; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - 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; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 48 ); - out = filledarrayBy( buf, 16, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 24 ); - out = filledarrayBy( buf, 8, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int32', clbk ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint8c', clbk ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - 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; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 64 ); - out = filledarrayBy( buf, 16, 2, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset, length)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 1, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 1, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled array (default, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, iterator; thisArg)', opts, function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - ctx = { - 'count': 0 - }; - indices = []; - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, iterator; thisArg)', opts, function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - ctx = { - 'count': 0 - }; - indices = []; - out = filledarrayBy( arr, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - 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; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = iterConstant( new Complex128( 3.0, 3.0 ), { - 'iter': 2 - }); - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = iterConstant( new Complex64( 3.0, 3.0 ), { - 'iter': 2 - }); - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); From 38ce48c3b2fa3cf6ffbef209a42f44b6c055e12d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 6 Apr 2026 03:49:32 +0000 Subject: [PATCH 103/117] Transform error messages --- lib/main.js | 38 +++++++++++++++++++------------------- package.json | 2 +- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/lib/main.js b/lib/main.js index d2128f5..32b6545 100644 --- a/lib/main.js +++ b/lib/main.js @@ -35,7 +35,7 @@ var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-supp var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); var iterLength = require( '@stdlib/iter-length' ); var defaults = require( '@stdlib/array-defaults' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -266,18 +266,18 @@ function filledarrayBy() { if ( isString( dtype ) ) { // Invoking this function with arguments `f( dtype, clbk[, thisArg] )` is not allowed (otherwise, we'd need to also allow `f( clbk[, thisArg] )`)... if ( nargs > 1 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format('00h05') ); } ctor = ctors( dtype ); if ( ctor === null ) { - throw new TypeError( format( 'invalid argument. Must provide a recognized data type. Value: `%s`.', dtype ) ); + throw new TypeError( format( '00h2Y', dtype ) ); } // Return an empty array having the specified dtype: return new ctor( 0 ); } // For all other supported invocations, we need at least two arguments... if ( nargs < 2 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format('00h05') ); } // At this point, we need to do some argument juggling... nargs -= 1; // henceforth, the number of available arguments is `nargs+1` @@ -292,7 +292,7 @@ function filledarrayBy() { // Check if we were provided only a callback and a "this" context.. if ( nargs === 0 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format('00h05') ); } } else { // "this" context is left undefined... @@ -305,12 +305,12 @@ function filledarrayBy() { nargs -= 1; clbk = arguments[ nargs ]; if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '00h2b', clbk ) ); } } // If we were only provided 2 arguments and the last argument was not a function, we've been provided an insufficient number of arguments... else { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format('00h05') ); } // Now that we've processed the callback arguments, let's continue working backward to see if we've been provided a `dtype` argument... nargs -= 1; @@ -322,7 +322,7 @@ function filledarrayBy() { } ctor = ctors( dtype ); if ( ctor === null ) { - throw new TypeError( format( 'invalid argument. Must provide a recognized data type. Value: `%s`.', dtype ) ); + throw new TypeError( format( '00h2Y', dtype ) ); } // At this point, we've resolved the output array data type, and now we can actually create the output array... if ( dtype === 'generic' ) { @@ -337,26 +337,26 @@ function filledarrayBy() { return filledArray( len, clbk, thisArg ); } if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format('00h04') ); } if ( isObject( arg ) ) { if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2Z', arg ) ); } if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } arg = arg[ ITERATOR_SYMBOL ](); if ( !isFunction( arg.next ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } return filledArrayIterator( arg, clbk, thisArg ); } - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } else if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format('00h04') ); } - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } if ( nargs === 0 ) { // length || array-like || ArrayBuffer || iterable arg = arguments[ 0 ]; @@ -368,18 +368,18 @@ function filledarrayBy() { arr = new ctor( arg ); } else if ( isObject( arg ) ) { if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2Z', arg ) ); } if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } arg = arg[ ITERATOR_SYMBOL ](); if ( !isFunction( arg.next ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } arr = new ctor( iterLength( arg ) ); } else { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } } else if ( nargs === 1 ) { arr = new ctor( arguments[0], arguments[1] ); // (ArrayBuffer, byteOffset) diff --git a/package.json b/package.json index 0edfb95..ecbe58e 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "@stdlib/assert-is-string": "^0.2.3", "@stdlib/blas-ext-base-gfill-by": "^0.2.3", "@stdlib/iter-length": "^0.2.3", - "@stdlib/string-format": "^0.2.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.3", "@stdlib/symbol-iterator": "^0.2.3", "@stdlib/types": "^0.4.3", "@stdlib/error-tools-fmtprodmsg": "^0.2.3" From 5bcdfe7d3c95e4a3695add001370b2cdcecd658b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 6 Apr 2026 04:03:35 +0000 Subject: [PATCH 104/117] Remove files --- index.d.ts | 322 ---- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5169 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index cb63cd1..0000000 --- a/index.d.ts +++ /dev/null @@ -1,322 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, RealOrComplexTypedArray, BooleanArray, DataType } from '@stdlib/types/array'; -import { IterableIterator } from '@stdlib/types/iter'; - -/** -* Array or typed array. -*/ -type ArrayOrTypedArray = Array | RealOrComplexTypedArray | BooleanArray; - -/** -* Nullary callback function. -* -* @returns fill value -*/ -type Nullary = () => any; - -/** -* Unary callback function. -* -* @param i - current array index -* @returns fill value -*/ -type Unary = ( i: number ) => any; - -/** -* Callback function. -* -* @param i - current array index -* @returns fill value -*/ -type Callback = Nullary | Unary; - -/** -* Creates a filled array according to a provided callback function and having a specified data type. -* -* @param dtype - data type -* @returns filled array -* -* @example -* var arr = filledarrayBy(); -* // returns -* -* @example -* var arr = filledarrayBy( 'float32' ); -* // returns -*/ -declare function filledarrayBy( dtype?: DataType ): ArrayOrTypedArray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Creates a filled array according to a provided callback function and having a specified `length`. -* -* @param length - array length -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* -* var arr = filledarrayBy( 5, constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( length: number, clbk: Callback, thisArg?: any ): ArrayOrTypedArray; - -/** -* Creates a filled array according to a provided callback function and having a specified `length`. -* -* @param length - array length -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* -* var arr = filledarrayBy( 5, 'float64', constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( length: number, dtype: DataType, clbk: Callback, thisArg?: any ): ArrayOrTypedArray; - -/** -* Creates a filled array from another `array` according to a provided callback function. -* -* @param array - typed array or array-like object -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* -* 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; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Creates a filled array from another `array` according to a provided callback function. -* -* @param array - typed array or array-like object -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* -* 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; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Creates a filled array from an iterable according to a callback function. -* -* @param iterable - iterable -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var iterConstant = require( '@stdlib/iter-constant' ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarrayBy( it, constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( iterable: IterableIterator, clbk: Callback, thisArg?: any ): ArrayOrTypedArray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Creates a filled array from an iterable according to a callback function. -* -* @param iterable - iterable -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var iterConstant = require( '@stdlib/iter-constant' ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarrayBy( it, 'float64', constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( iterable: IterableIterator, dtype: DataType, clbk: 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. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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 | BooleanArray; - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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 | BooleanArray; - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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 | BooleanArray; - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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 | BooleanArray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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 | BooleanArray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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 | BooleanArray; // eslint-disable-line @typescript-eslint/unified-signatures - - -// EXPORTS // - -export = filledarrayBy; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 6f157fa..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.3-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.3-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@v0.0.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.3-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.3-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.3-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-ctors@v0.3.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill-by@v0.2.3-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled-by@v0.2.3-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.2.3-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.3-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@v0.2.3-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.4.1-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";var v=f(),g=j.get("dtypes.default");function c(){var f,j,c,b,y,x,u,E;if(0===(j=arguments.length))return new(y=d(g))(0);if(r(c=arguments[0])){if(j>1)throw new TypeError(w("00h05"));if(null===(y=d(c)))throw new TypeError(w("00h2Y",c));return new y(0)}if(j<2)throw new TypeError(w("00h05"));if(h(arguments[j-=1]))if(h(arguments[j-1])){if(f=arguments[j],b=arguments[j-=1],0===j)throw new TypeError(w("00h05"))}else b=arguments[j];else{if(!(j>=2))throw new TypeError(w("00h05"));if(f=arguments[j],!h(b=arguments[j-=1]))throw new TypeError(w("00h2b",b))}if((j-=1)>=0&&r(arguments[j])?(c=arguments[j],j-=1):c=g,null===(y=d(c)))throw new TypeError(w("00h2Y",c));if("generic"===c){if(E=arguments[0],0===j){if(e(E)?u=E:i(E)&&(u=E.length),void 0!==u)return m(u,b,f);if(n(E))throw new Error(w("00h04"));if(o(E)){if(!1===v)throw new TypeError(w("00h2Z",E));if(!h(E[p]))throw new TypeError(w("00h2a",E));if(E=E[p](),!h(E.next))throw new TypeError(w("00h2a",E));return function(r,e,t){var s,i;for(s=[],i=-1;!r.next().done;)i+=1,s.push(e.call(t,i));return s}(E,b,f)}throw new TypeError(w("00h2a",E))}if(n(E))throw new Error(w("00h04"));throw new TypeError(w("00h2a",E))}if(0===j)if(i(E=arguments[0]))x=new y(E.length);else if(n(E))x=new y(E);else if(e(E))x=new y(E);else{if(!o(E))throw new TypeError(w("00h2a",E));if(!1===v)throw new TypeError(w("00h2Z",E));if(!h(E[p]))throw new TypeError(w("00h2a",E));if(E=E[p](),!h(E.next))throw new TypeError(w("00h2a",E));x=new y(a(E))}else x=1===j?new y(arguments[0],arguments[1]):new y(arguments[0],arguments[1],arguments[2]);return x.length>0&&(t(c)||s(c)?function(r,e,t){var s;for(s=0;s\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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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( format('00h05') );\n\t\t}\n\t\tctor = ctors( dtype );\n\t\tif ( ctor === null ) {\n\t\t\tthrow new TypeError( format( '00h2Y', 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( format('00h05') );\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( format('00h05') );\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( '00h2b', clbk ) );\n\t\t}\n\t}\n\t// If we 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( format('00h05') );\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( '00h2Y', 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( format('00h04') );\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( '00h2Z', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00h2a', 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( '00h2a', 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( '00h2a', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format('00h04') );\n\t\t}\n\t\tthrow new TypeError( format( '00h2a', 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( '00h2Z', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00h2a', 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( '00h2a', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00h2a', 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\nexport default filledarrayBy;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","DEFAULT_DTYPE","defaults","get","filledarrayBy","thisArg","nargs","dtype","clbk","ctor","arr","len","arg","arguments","length","ctors","isString","TypeError","format","isFunction","isNonNegativeInteger","isCollection","filledArray","isArrayBuffer","Error","isObject","ITERATOR_SYMBOL","next","it","i","done","push","call","filledArrayIterator","iterLength","isComplexDataType","isBooleanDataType","set","filledAccessors","gfillBy","value","aidx"],"mappings":";;sjDA0CA,IAAIA,EAAsBC,IACtBC,EAAgBC,EAASC,IAAK,kBA2MlC,SAASC,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAKJ,GAAe,KAHfN,EAAQO,UAAUC,QAKjB,OAAO,IADPL,EAAOM,EAAOd,IACG,GAIlB,GAAKe,EADLT,EAAQM,UAAW,IACM,CAExB,GAAKP,EAAQ,EACZ,MAAM,IAAIW,UAAWC,EAAO,UAG7B,GAAc,QADdT,EAAOM,EAAOR,IAEb,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,OAAO,IAAIE,EAAM,EACjB,CAED,GAAKH,EAAQ,EACZ,MAAM,IAAIW,UAAWC,EAAO,UAM7B,GAAKC,EAAYN,UAHjBP,GAAS,IAKR,GAAKa,EAAYN,UAAWP,EAAM,KAMjC,GALAD,EAAUQ,UAAWP,GAErBE,EAAOK,UADPP,GAAS,GAIM,IAAVA,EACJ,MAAM,IAAIW,UAAWC,EAAO,eAI7BV,EAAOK,UAAWP,OAIf,MAAKA,GAAS,GAUlB,MAAM,IAAIW,UAAWC,EAAO,UAN5B,GAHAb,EAAUQ,UAAWP,IAGfa,EADNX,EAAOK,UADPP,GAAS,IAGR,MAAM,IAAIW,UAAWC,EAAQ,QAASV,GAMvC,CAUD,IARAF,GAAS,IACK,GAAKU,EAAUH,UAAWP,KACvCC,EAAQM,UAAWP,GACnBA,GAAS,GAETC,EAAQN,EAGK,QADdQ,EAAOM,EAAOR,IAEb,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,GAAe,YAAVA,EAAsB,CAE1B,GADAK,EAAMC,UAAW,GACF,IAAVP,EAAc,CAMlB,GALKc,EAAsBR,GAC1BD,EAAMC,EACKS,EAAcT,KACzBD,EAAMC,EAAIE,aAEE,IAARH,EACJ,OAAOW,EAAaX,EAAKH,EAAMH,GAEhC,GAAKkB,EAAeX,GACnB,MAAM,IAAIY,MAAON,EAAO,UAEzB,GAAKO,EAAUb,GAAQ,CACtB,IAA6B,IAAxBb,EACJ,MAAM,IAAIkB,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAYP,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLP,EAAYP,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvC,OAvSJ,SAA8BgB,EAAIpB,EAAMH,GACvC,IAAIK,EACAmB,EAKJ,IAFAnB,EAAM,GACNmB,GAAK,GAEAD,EAAGD,OACAG,MAGPD,GAAK,EACLnB,EAAIqB,KAAMvB,EAAKwB,KAAM3B,EAASwB,IAE/B,OAAOnB,CACR,CAuRWuB,CAAqBrB,EAAKJ,EAAMH,EACvC,CACD,MAAM,IAAIY,UAAWC,EAAQ,QAASN,GACzC,CAAS,GAAKW,EAAeX,GAC1B,MAAM,IAAIY,MAAON,EAAO,UAEzB,MAAM,IAAID,UAAWC,EAAQ,QAASN,GACtC,CACD,GAAe,IAAVN,EAEJ,GAAKe,EADLT,EAAMC,UAAW,IAEhBH,EAAM,IAAID,EAAMG,EAAIE,aACd,GAAKS,EAAeX,GAC1BF,EAAM,IAAID,EAAMG,QACV,GAAKQ,EAAsBR,GACjCF,EAAM,IAAID,EAAMG,OACV,KAAKa,EAAUb,GAarB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAZtC,IAA6B,IAAxBb,EACJ,MAAM,IAAIkB,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAYP,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLP,EAAYP,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvCF,EAAM,IAAID,EAAMyB,EAAYtB,GAG5B,MAEDF,EADqB,IAAVJ,EACL,IAAIG,EAAMI,UAAU,GAAIA,UAAU,IAElC,IAAIJ,EAAMI,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKH,EAAII,OAAS,IACZqB,EAAmB5B,IAAW6B,EAAmB7B,GAjTxD,SAA0BG,EAAKF,EAAMH,GACpC,IAAIwB,EACJ,IAAMA,EAAI,EAAGA,EAAInB,EAAII,OAAQe,IAC5BnB,EAAI2B,IAAK7B,EAAKwB,KAAM3B,EAASwB,GAAKA,EAGpC,CA4SGS,CAAiB5B,EAAKF,EAAMH,GAE5BkC,EAAS7B,EAAII,OAAQJ,EAAK,GAe5B,SAAmB8B,EAAOC,GACzB,OAAOjC,EAAKwB,KAAM3B,EAASoC,EAC3B,KAdM/B,CAeR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index dabf69c..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From accc32fbefe3733ea63e9070d2f6c0b88dc57842 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 6 Apr 2026 04:04:04 +0000 Subject: [PATCH 105/117] Auto-generated commit --- .editorconfig | 189 - .eslintrc.js | 1 - .gitattributes | 68 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 101 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 199 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 236 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 49 +- SECURITY.md | 5 - benchmark/benchmark.js | 342 -- benchmark/benchmark.length.bool.js | 98 - benchmark/benchmark.length.complex128.js | 99 - benchmark/benchmark.length.complex64.js | 99 - benchmark/benchmark.length.float32.js | 98 - benchmark/benchmark.length.float64.js | 98 - benchmark/benchmark.length.generic.js | 98 - benchmark/benchmark.length.int16.js | 98 - benchmark/benchmark.length.int32.js | 98 - benchmark/benchmark.length.int8.js | 98 - benchmark/benchmark.length.uint16.js | 98 - benchmark/benchmark.length.uint32.js | 98 - benchmark/benchmark.length.uint8.js | 98 - benchmark/benchmark.length.uint8c.js | 98 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 36 - dist/index.js.map | 7 - docs/repl.txt | 157 - docs/types/test.ts | 606 --- examples/index.js | 37 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 192 - lib/main.js | 416 -- package.json | 96 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 4397 ---------------- 57 files changed, 4870 insertions(+), 11316 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.length.bool.js delete mode 100644 benchmark/benchmark.length.complex128.js delete mode 100644 benchmark/benchmark.length.complex64.js delete mode 100644 benchmark/benchmark.length.float32.js delete mode 100644 benchmark/benchmark.length.float64.js delete mode 100644 benchmark/benchmark.length.generic.js delete mode 100644 benchmark/benchmark.length.int16.js delete mode 100644 benchmark/benchmark.length.int32.js delete mode 100644 benchmark/benchmark.length.int8.js delete mode 100644 benchmark/benchmark.length.uint16.js delete mode 100644 benchmark/benchmark.length.uint32.js delete mode 100644 benchmark/benchmark.length.uint8.js delete mode 100644 benchmark/benchmark.length.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 80f3fca..0000000 --- a/.editorconfig +++ /dev/null @@ -1,189 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Ignore generated lock files for GitHub Agentic Workflows: -[*.lock.yml] -charset = unset -end_of_line = unset -indent_style = unset -indent_size = unset -trim_trailing_whitespace = unset -insert_final_newline = unset - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 24b327f..0000000 --- a/.gitattributes +++ /dev/null @@ -1,68 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation - -.github/workflows/*.lock.yml linguist-generated=true merge=ours diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 97b9726..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2026-04-06T03:38:19.580Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 2d6aaee..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/contributing/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index f988046..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index b2c1f9c..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '42 6 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 83d50c4..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,821 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send notification to Zulip if job fails: - - name: 'Send notification to Zulip in case of failure' - # Pin action to full length commit SHA - uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 - if: failure() - with: - api-key: ${{ secrets.ZULIP_API_KEY }} - email: 'github-actions-bot@stdlib.zulipchat.com' - organization-url: 'https://stdlib.zulipchat.com' - to: 'workflows-standalone' - type: 'stream' - topic: ${{ github.event.repository.name }} - content: | - :cross_mark: **${{ github.workflow }}** workflow failed - - **Repository:** [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) - **Run:** [View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -278,7 +269,7 @@ for ( i = 0; i < dt.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -347,13 +338,13 @@ Copyright © 2016-2026. 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/dtypes]: https://github.com/stdlib-js/array-dtypes/tree/esm -[@stdlib/array/filled]: https://github.com/stdlib-js/array-filled +[@stdlib/array/filled]: https://github.com/stdlib-js/array-filled/tree/esm -[@stdlib/array/typed]: https://github.com/stdlib-js/array-typed +[@stdlib/array/typed]: https://github.com/stdlib-js/array-typed/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 6fba606..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,342 +0,0 @@ -/** -* @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 isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); -var isArray = require( '@stdlib/assert-is-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var Complex64 = require( '@stdlib/complex-float32-ctor' ); -var Complex128 = require( '@stdlib/complex-float64-ctor' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var filledarrayBy = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 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( format( '%s:dtype=float64', pkg ), function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'float64', 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( format( '%s:dtype=float32', pkg ), function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'float32', 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( format( '%s:dtype=bool', pkg ), 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( format( '%s:dtype=complex128', pkg ), function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( new Complex128( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'complex128', 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( format( '%s:dtype=complex64', pkg ), function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( new Complex64( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'complex64', 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( format( '%s:dtype=int32', pkg ), function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int32', 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( format( '%s:dtype=uint32', pkg ), function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint32', 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( format( '%s:dtype=int16', pkg ), function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int16', 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( format( '%s:dtype=uint16', pkg ), function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint16', 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( format( '%s:dtype=int8', pkg ), function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int8', 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( format( '%s:dtype=uint8', pkg ), function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint8', 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( format( '%s:dtype=uint8c', pkg ), function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint8c', 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( format( '%s:dtype=generic', pkg ), function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'generic', clbk ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.length.bool.js b/benchmark/benchmark.length.bool.js deleted file mode 100644 index 52b3237..0000000 --- a/benchmark/benchmark.length.bool.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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 format = require( '@stdlib/string-format' ); -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( format( '%s:dtype=bool,len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.complex128.js b/benchmark/benchmark.length.complex128.js deleted file mode 100644 index 63c0843..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,99 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 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 Complex128 = require( '@stdlib/complex-float64-ctor' ); -var format = require( '@stdlib/string-format' ); -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( new Complex128( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'complex128', 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( format( '%s:dtype=complex128,len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.complex64.js b/benchmark/benchmark.length.complex64.js deleted file mode 100644 index 186f811..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,99 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 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 Complex64 = require( '@stdlib/complex-float32-ctor' ); -var format = require( '@stdlib/string-format' ); -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( new Complex64( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'complex64', 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( format( '%s:dtype=complex64,len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.float32.js b/benchmark/benchmark.length.float32.js deleted file mode 100644 index 5ba3130..0000000 --- a/benchmark/benchmark.length.float32.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/string-format' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'float32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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( format( '%s:dtype=float32,len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.float64.js b/benchmark/benchmark.length.float64.js deleted file mode 100644 index 4a2be6c..0000000 --- a/benchmark/benchmark.length.float64.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/string-format' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'float64', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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( format( '%s:dtype=float64,len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.generic.js b/benchmark/benchmark.length.generic.js deleted file mode 100644 index 6522748..0000000 --- a/benchmark/benchmark.length.generic.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isArray = require( '@stdlib/assert-is-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/string-format' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'generic', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isArray( 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( format( '%s:dtype=generic,len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int16.js b/benchmark/benchmark.length.int16.js deleted file mode 100644 index 9ac94e9..0000000 --- a/benchmark/benchmark.length.int16.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/string-format' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int16', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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( format( '%s:dtype=int16,len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int32.js b/benchmark/benchmark.length.int32.js deleted file mode 100644 index a5ce4d0..0000000 --- a/benchmark/benchmark.length.int32.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/string-format' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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( format( '%s:dtype=int32,len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int8.js b/benchmark/benchmark.length.int8.js deleted file mode 100644 index 6104616..0000000 --- a/benchmark/benchmark.length.int8.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/string-format' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int8', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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( format( '%s:dtype=int8,len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint16.js b/benchmark/benchmark.length.uint16.js deleted file mode 100644 index 3108633..0000000 --- a/benchmark/benchmark.length.uint16.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/string-format' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint16', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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( format( '%s:dtype=uint16,len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint32.js b/benchmark/benchmark.length.uint32.js deleted file mode 100644 index 602e232..0000000 --- a/benchmark/benchmark.length.uint32.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/string-format' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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( format( '%s:dtype=uint32,len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint8.js b/benchmark/benchmark.length.uint8.js deleted file mode 100644 index 8664da3..0000000 --- a/benchmark/benchmark.length.uint8.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/string-format' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint8', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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( format( '%s:dtype=uint8,len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint8c.js b/benchmark/benchmark.length.uint8c.js deleted file mode 100644 index 76645b9..0000000 --- a/benchmark/benchmark.length.uint8c.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/string-format' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint8c', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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( format( '%s:dtype=uint8c,len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index c138144..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by" -%% click B href "https://github.com/stdlib-js/array-filled-by/tree/main" -%% click C href "https://github.com/stdlib-js/array-filled-by/tree/production" -%% click D href "https://github.com/stdlib-js/array-filled-by/tree/esm" -%% click E href "https://github.com/stdlib-js/array-filled-by/tree/deno" -%% click F href "https://github.com/stdlib-js/array-filled-by/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by -[production-url]: https://github.com/stdlib-js/array-filled-by/tree/production -[deno-url]: https://github.com/stdlib-js/array-filled-by/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-filled-by/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-filled-by/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-filled-by/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-filled-by/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-filled-by/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 188fc9b..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import filledarrayBy from '../docs/types/index'; -export = filledarrayBy; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 65ae3db..0000000 --- a/dist/index.js +++ /dev/null @@ -1,36 +0,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 deleted file mode 100644 index b348e92..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "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 we 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,YACjDC,EAAuB,QAAS,uCAAwC,EAAE,YAC1EC,EAAoB,QAAS,+DAAgE,EAC7FC,EAAoB,QAAS,gDAAiD,EAC9EC,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,EAAQ,UAAU,OAGbA,IAAU,EACd,OAAAE,EAAOrB,EAAOS,CAAc,EACrB,IAAIY,EAAM,CAAE,EAIpB,GADAD,EAAQ,UAAW,CAAE,EAChB5B,EAAU4B,CAAM,EAAI,CAExB,GAAKD,EAAQ,EACZ,MAAM,IAAI,UAAW,2FAA4F,EAGlH,GADAE,EAAOrB,EAAOoB,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWd,EAAQ,sEAAuEa,CAAM,CAAE,EAG7G,OAAO,IAAIC,EAAM,CAAE,CACpB,CAEA,GAAKF,EAAQ,EACZ,MAAM,IAAI,UAAW,2FAA4F,EAMlH,GAHAA,GAAS,EAGJpB,EAAY,UAAWoB,CAAM,CAAE,EAEnC,GAAKpB,EAAY,UAAWoB,EAAM,CAAE,CAAE,GAMrC,GALAN,EAAU,UAAWM,CAAM,EAC3BA,GAAS,EACTP,EAAO,UAAWO,CAAM,EAGnBA,IAAU,EACd,MAAM,IAAI,UAAW,2FAA4F,OAIlHP,EAAO,UAAWO,CAAM,UAIhBA,GAAS,GAIlB,GAHAN,EAAU,UAAWM,CAAM,EAC3BA,GAAS,EACTP,EAAO,UAAWO,CAAM,EACnB,CAACpB,EAAYa,CAAK,EACtB,MAAM,IAAI,UAAWL,EAAQ,uEAAwEK,CAAK,CAAE,MAK7G,OAAM,IAAI,UAAW,2FAA4F,EAWlH,GARAO,GAAS,EACJA,GAAS,GAAK3B,EAAU,UAAW2B,CAAM,CAAE,GAC/CC,EAAQ,UAAWD,CAAM,EACzBA,GAAS,GAETC,EAAQX,EAETY,EAAOrB,EAAOoB,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWd,EAAQ,sEAAuEa,CAAM,CAAE,EAG7G,GAAKA,IAAU,UAAY,CAE1B,GADAG,EAAM,UAAW,CAAE,EACdJ,IAAU,EAAI,CAMlB,GALK1B,EAAsB8B,CAAI,EAC9BD,EAAMC,EACK3B,EAAc2B,CAAI,IAC7BD,EAAMC,EAAI,QAEND,IAAQ,OACZ,OAAOpB,EAAaoB,EAAKV,EAAMC,CAAQ,EAExC,GAAKhB,EAAe0B,CAAI,EACvB,MAAM,IAAI,MAAO,mFAAoF,EAEtG,GAAKzB,EAAUyB,CAAI,EAAI,CACtB,GAAKf,IAAwB,GAC5B,MAAM,IAAI,UAAWD,EAAQ,sIAAuIgB,CAAI,CAAE,EAE3K,GAAK,CAACxB,EAAYwB,EAAKnB,CAAgB,CAAE,EACxC,MAAM,IAAI,UAAWG,EAAQ,wGAAyGgB,CAAI,CAAE,EAG7I,GADAA,EAAMA,EAAKnB,CAAgB,EAAE,EACxB,CAACL,EAAYwB,EAAI,IAAK,EAC1B,MAAM,IAAI,UAAWhB,EAAQ,wGAAyGgB,CAAI,CAAE,EAE7I,OAAOb,EAAqBa,EAAKX,EAAMC,CAAQ,CAChD,CACA,MAAM,IAAI,UAAWN,EAAQ,wGAAyGgB,CAAI,CAAE,CAC7I,SAAY1B,EAAe0B,CAAI,EAC9B,MAAM,IAAI,MAAO,mFAAoF,EAEtG,MAAM,IAAI,UAAWhB,EAAQ,wGAAyGgB,CAAI,CAAE,CAC7I,CACA,GAAKJ,IAAU,EAEd,GADAI,EAAM,UAAW,CAAE,EACd3B,EAAc2B,CAAI,EACtBT,EAAM,IAAIO,EAAME,EAAI,MAAO,UAChB1B,EAAe0B,CAAI,EAC9BT,EAAM,IAAIO,EAAME,CAAI,UACT9B,EAAsB8B,CAAI,EACrCT,EAAM,IAAIO,EAAME,CAAI,UACTzB,EAAUyB,CAAI,EAAI,CAC7B,GAAKf,IAAwB,GAC5B,MAAM,IAAI,UAAWD,EAAQ,sIAAuIgB,CAAI,CAAE,EAE3K,GAAK,CAACxB,EAAYwB,EAAKnB,CAAgB,CAAE,EACxC,MAAM,IAAI,UAAWG,EAAQ,wGAAyGgB,CAAI,CAAE,EAG7I,GADAA,EAAMA,EAAKnB,CAAgB,EAAE,EACxB,CAACL,EAAYwB,EAAI,IAAK,EAC1B,MAAM,IAAI,UAAWhB,EAAQ,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,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 deleted file mode 100644 index 06f3146..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,157 +0,0 @@ - -{{alias}}( [dtype] ) - Creates a filled array. - - Parameters - ---------- - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr = {{alias}}() - - > arr = {{alias}}( 'float32' ) - - - -{{alias}}( length[, dtype], clbk[, thisArg] ) - Returns a filled array according to a provided callback function and having - a specified length. - - Parameters - ---------- - length: integer - Array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > function clbk() { return 1.0; }; - > var arr = {{alias}}( 5, clbk ) - [ 1.0, 1.0, 1.0, 1.0, 1.0 ] - > arr = {{alias}}( 5, 'int32', clbk ) - [ 1, 1, 1, 1, 1 ] - - -{{alias}}( array[, dtype], clbk[, thisArg] ) - Creates a filled array from another array (or array-like object) according - to a provided callback function. - - Parameters - ---------- - array: ArrayLikeObject - Array from which to generate another array. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias}}( [ 0.5, 0.5, 0.5 ], {{alias:@stdlib/utils/constant-function}}( 2.0 ) ) - [ 2.0, 2.0, 2.0 ] - > var arr2 = {{alias}}( arr1, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( iterable[, dtype], clbk[, thisArg] ) - Creates a filled array from an iterable according to a provided callback - function. - - Parameters - ---------- - iterable: Iterable - Iterable from which to generate an array. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias:@stdlib/iter/constant}}( 3.0, {'iter': 3} ); - > var arr2 = {{alias}}( arr1, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( buffer[, byteOffset[, length]][, dtype], clbk[, thisArg] ) - Returns a filled typed array view of an ArrayBuffer according to a provided - callback function. - - The 'generic' array data type is *not* supported. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( buf, 0, 4, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0, 1.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index bb876ed..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,606 +0,0 @@ -/* -* @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. -*/ - -/// - -import { IterableIterator } from '@stdlib/types/iter'; -import filledarrayBy = require( './index' ); - - -/** -* Returns an iterator protocol-compliant object. -* -* @returns iterator protocol-compliant object -*/ -function iterator(): IterableIterator { - const obj: IterableIterator = { - [Symbol.iterator]: iterator, - 'next': next - }; - return obj; -} - -/** -* Implements the iterator protocol `next` method. -* -* @returns iterator protocol-compliant object -*/ -function next(): any { - return { - 'value': 1.0, - 'done': false - }; -} - -/** -* Callback function. -* -* @param i - current array index -* @returns return value -*/ -function clbk( i: number ): number { - return i; -} - - -// TESTS // - -// The function returns an array or typed array... -{ - filledarrayBy(); // $ExpectType ArrayOrTypedArray - filledarrayBy( 'float32' ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( 10, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( 10, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( 10, 'int32', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( 10, 'int32', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const x = new Float64Array( 10 ); - filledarrayBy( x, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( x, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( x, 'uint8', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( x, 'uint8', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const y = [ 2.0, 2.0, 2.0 ]; - filledarrayBy( y, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( y, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( y, 'float64', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( y, 'float64', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const it = iterator(); - filledarrayBy( it, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( it, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( it, 'uint8c', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( it, 'uint8c', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const buf = new ArrayBuffer( 32 ); - filledarrayBy( buf, clbk ); // $ExpectType RealOrComplexTypedArray | BooleanArray - filledarrayBy( buf, clbk, {} ); // $ExpectType RealOrComplexTypedArray | BooleanArray - - filledarrayBy( buf, 'uint32', clbk ); // $ExpectType RealOrComplexTypedArray | BooleanArray - filledarrayBy( buf, 'uint32', clbk, {} ); // $ExpectType RealOrComplexTypedArray | BooleanArray - - filledarrayBy( buf, 8, clbk ); // $ExpectType RealOrComplexTypedArray | BooleanArray - filledarrayBy( buf, 8, clbk, {} ); // $ExpectType RealOrComplexTypedArray | BooleanArray - - filledarrayBy( buf, 8, 'uint16', clbk ); // $ExpectType RealOrComplexTypedArray | BooleanArray - filledarrayBy( buf, 8, 'uint16', clbk, {} ); // $ExpectType RealOrComplexTypedArray | BooleanArray - - filledarrayBy( buf, 8, 2, clbk ); // $ExpectType RealOrComplexTypedArray | BooleanArray - filledarrayBy( buf, 8, 2, clbk, {} ); // $ExpectType RealOrComplexTypedArray | BooleanArray - - filledarrayBy( buf, 8, 2, 'int16', clbk ); // $ExpectType RealOrComplexTypedArray | BooleanArray - filledarrayBy( buf, 8, 2, 'int16', clbk, {} ); // $ExpectType RealOrComplexTypedArray | BooleanArray -} - -// The compiler throws an error if a callback function argument is not a function... -{ - filledarrayBy( 'float64', '5' ); // $ExpectError - filledarrayBy( 'float64', 1.0 ); // $ExpectError - filledarrayBy( 'float64', false ); // $ExpectError - filledarrayBy( 'float64', true ); // $ExpectError - filledarrayBy( 'float64', null ); // $ExpectError - filledarrayBy( 'float64', undefined ); // $ExpectError - filledarrayBy( 'float64', [] ); // $ExpectError - filledarrayBy( 'float64', {} ); // $ExpectError - - filledarrayBy( 'float64', '5', {} ); // $ExpectError - filledarrayBy( 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( 'float64', false, {} ); // $ExpectError - filledarrayBy( 'float64', true, {} ); // $ExpectError - filledarrayBy( 'float64', null, {} ); // $ExpectError - filledarrayBy( 'float64', undefined, {} ); // $ExpectError - filledarrayBy( 'float64', [], {} ); // $ExpectError - filledarrayBy( 'float64', {}, {} ); // $ExpectError - - filledarrayBy( 10, '5' ); // $ExpectError - filledarrayBy( 10, 1.0 ); // $ExpectError - filledarrayBy( 10, false ); // $ExpectError - filledarrayBy( 10, true ); // $ExpectError - filledarrayBy( 10, null ); // $ExpectError - filledarrayBy( 10, undefined ); // $ExpectError - filledarrayBy( 10, [] ); // $ExpectError - filledarrayBy( 10, {} ); // $ExpectError - - filledarrayBy( 10, '5', {} ); // $ExpectError - filledarrayBy( 10, 1.0, {} ); // $ExpectError - filledarrayBy( 10, false, {} ); // $ExpectError - filledarrayBy( 10, true, {} ); // $ExpectError - filledarrayBy( 10, null, {} ); // $ExpectError - filledarrayBy( 10, undefined, {} ); // $ExpectError - filledarrayBy( 10, [], {} ); // $ExpectError - filledarrayBy( 10, {}, {} ); // $ExpectError - - filledarrayBy( 10, 'float64', '5' ); // $ExpectError - filledarrayBy( 10, 'float64', 1.0 ); // $ExpectError - filledarrayBy( 10, 'float64', false ); // $ExpectError - filledarrayBy( 10, 'float64', true ); // $ExpectError - filledarrayBy( 10, 'float64', null ); // $ExpectError - filledarrayBy( 10, 'float64', undefined ); // $ExpectError - filledarrayBy( 10, 'float64', [] ); // $ExpectError - filledarrayBy( 10, 'float64', {} ); // $ExpectError - - filledarrayBy( 10, 'float64', '5', {} ); // $ExpectError - filledarrayBy( 10, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( 10, 'float64', false, {} ); // $ExpectError - filledarrayBy( 10, 'float64', true, {} ); // $ExpectError - filledarrayBy( 10, 'float64', null, {} ); // $ExpectError - filledarrayBy( 10, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( 10, 'float64', [], {} ); // $ExpectError - filledarrayBy( 10, 'float64', {}, {} ); // $ExpectError - - const x = new Float64Array( 10 ); - filledarrayBy( x, '5' ); // $ExpectError - filledarrayBy( x, 1.0 ); // $ExpectError - filledarrayBy( x, false ); // $ExpectError - filledarrayBy( x, true ); // $ExpectError - filledarrayBy( x, null ); // $ExpectError - filledarrayBy( x, undefined ); // $ExpectError - filledarrayBy( x, [] ); // $ExpectError - filledarrayBy( x, {} ); // $ExpectError - - filledarrayBy( x, '5', {} ); // $ExpectError - filledarrayBy( x, 1.0, {} ); // $ExpectError - filledarrayBy( x, false, {} ); // $ExpectError - filledarrayBy( x, true, {} ); // $ExpectError - filledarrayBy( x, null, {} ); // $ExpectError - filledarrayBy( x, undefined, {} ); // $ExpectError - filledarrayBy( x, [], {} ); // $ExpectError - filledarrayBy( x, {}, {} ); // $ExpectError - - filledarrayBy( x, 'float64', '5' ); // $ExpectError - filledarrayBy( x, 'float64', 1.0 ); // $ExpectError - filledarrayBy( x, 'float64', false ); // $ExpectError - filledarrayBy( x, 'float64', true ); // $ExpectError - filledarrayBy( x, 'float64', null ); // $ExpectError - filledarrayBy( x, 'float64', undefined ); // $ExpectError - filledarrayBy( x, 'float64', [] ); // $ExpectError - filledarrayBy( x, 'float64', {} ); // $ExpectError - - filledarrayBy( x, 'float64', '5', {} ); // $ExpectError - filledarrayBy( x, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( x, 'float64', false, {} ); // $ExpectError - filledarrayBy( x, 'float64', true, {} ); // $ExpectError - filledarrayBy( x, 'float64', null, {} ); // $ExpectError - filledarrayBy( x, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( x, 'float64', [], {} ); // $ExpectError - filledarrayBy( x, 'float64', {}, {} ); // $ExpectError - - const y = [ 2.0, 2.0, 2.0 ]; - filledarrayBy( y, '5' ); // $ExpectError - filledarrayBy( y, 1.0 ); // $ExpectError - filledarrayBy( y, false ); // $ExpectError - filledarrayBy( y, true ); // $ExpectError - filledarrayBy( y, null ); // $ExpectError - filledarrayBy( y, undefined ); // $ExpectError - filledarrayBy( y, [] ); // $ExpectError - filledarrayBy( y, {} ); // $ExpectError - - filledarrayBy( y, '5', {} ); // $ExpectError - filledarrayBy( y, 1.0, {} ); // $ExpectError - filledarrayBy( y, false, {} ); // $ExpectError - filledarrayBy( y, true, {} ); // $ExpectError - filledarrayBy( y, null, {} ); // $ExpectError - filledarrayBy( y, undefined, {} ); // $ExpectError - filledarrayBy( y, [], {} ); // $ExpectError - filledarrayBy( y, {}, {} ); // $ExpectError - - filledarrayBy( y, 'float64', '5' ); // $ExpectError - filledarrayBy( y, 'float64', 1.0 ); // $ExpectError - filledarrayBy( y, 'float64', false ); // $ExpectError - filledarrayBy( y, 'float64', true ); // $ExpectError - filledarrayBy( y, 'float64', null ); // $ExpectError - filledarrayBy( y, 'float64', undefined ); // $ExpectError - filledarrayBy( y, 'float64', [] ); // $ExpectError - filledarrayBy( y, 'float64', {} ); // $ExpectError - - filledarrayBy( y, 'float64', '5', {} ); // $ExpectError - filledarrayBy( y, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( y, 'float64', false, {} ); // $ExpectError - filledarrayBy( y, 'float64', true, {} ); // $ExpectError - filledarrayBy( y, 'float64', null, {} ); // $ExpectError - filledarrayBy( y, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( y, 'float64', [], {} ); // $ExpectError - filledarrayBy( y, 'float64', {}, {} ); // $ExpectError - - const it = iterator(); - filledarrayBy( it, '5' ); // $ExpectError - filledarrayBy( it, 1.0 ); // $ExpectError - filledarrayBy( it, false ); // $ExpectError - filledarrayBy( it, true ); // $ExpectError - filledarrayBy( it, null ); // $ExpectError - filledarrayBy( it, undefined ); // $ExpectError - filledarrayBy( it, [] ); // $ExpectError - filledarrayBy( it, {} ); // $ExpectError - - filledarrayBy( it, '5', {} ); // $ExpectError - filledarrayBy( it, 1.0, {} ); // $ExpectError - filledarrayBy( it, false, {} ); // $ExpectError - filledarrayBy( it, true, {} ); // $ExpectError - filledarrayBy( it, null, {} ); // $ExpectError - filledarrayBy( it, undefined, {} ); // $ExpectError - filledarrayBy( it, [], {} ); // $ExpectError - filledarrayBy( it, {}, {} ); // $ExpectError - - filledarrayBy( it, 'float64', '5' ); // $ExpectError - filledarrayBy( it, 'float64', 1.0 ); // $ExpectError - filledarrayBy( it, 'float64', false ); // $ExpectError - filledarrayBy( it, 'float64', true ); // $ExpectError - filledarrayBy( it, 'float64', null ); // $ExpectError - filledarrayBy( it, 'float64', undefined ); // $ExpectError - filledarrayBy( it, 'float64', [] ); // $ExpectError - filledarrayBy( it, 'float64', {} ); // $ExpectError - - filledarrayBy( it, 'float64', '5', {} ); // $ExpectError - filledarrayBy( it, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( it, 'float64', false, {} ); // $ExpectError - filledarrayBy( it, 'float64', true, {} ); // $ExpectError - filledarrayBy( it, 'float64', null, {} ); // $ExpectError - filledarrayBy( it, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( it, 'float64', [], {} ); // $ExpectError - filledarrayBy( it, 'float64', {}, {} ); // $ExpectError - - const buf = new ArrayBuffer( 32 ); - filledarrayBy( buf, '5' ); // $ExpectError - filledarrayBy( buf, 1.0 ); // $ExpectError - filledarrayBy( buf, false ); // $ExpectError - filledarrayBy( buf, true ); // $ExpectError - filledarrayBy( buf, null ); // $ExpectError - filledarrayBy( buf, undefined ); // $ExpectError - filledarrayBy( buf, [] ); // $ExpectError - filledarrayBy( buf, {} ); // $ExpectError - - filledarrayBy( buf, '5', {} ); // $ExpectError - filledarrayBy( buf, 1.0, {} ); // $ExpectError - filledarrayBy( buf, false, {} ); // $ExpectError - filledarrayBy( buf, true, {} ); // $ExpectError - filledarrayBy( buf, null, {} ); // $ExpectError - filledarrayBy( buf, undefined, {} ); // $ExpectError - filledarrayBy( buf, [], {} ); // $ExpectError - filledarrayBy( buf, {}, {} ); // $ExpectError - - filledarrayBy( buf, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 'float64', false ); // $ExpectError - filledarrayBy( buf, 'float64', true ); // $ExpectError - filledarrayBy( buf, 'float64', null ); // $ExpectError - filledarrayBy( buf, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 'float64', {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5' ); // $ExpectError - filledarrayBy( buf, 8, 1.0 ); // $ExpectError - filledarrayBy( buf, 8, false ); // $ExpectError - filledarrayBy( buf, 8, true ); // $ExpectError - filledarrayBy( buf, 8, null ); // $ExpectError - filledarrayBy( buf, 8, undefined ); // $ExpectError - filledarrayBy( buf, 8, [] ); // $ExpectError - filledarrayBy( buf, 8, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, false, {} ); // $ExpectError - filledarrayBy( buf, 8, true, {} ); // $ExpectError - filledarrayBy( buf, 8, null, {} ); // $ExpectError - filledarrayBy( buf, 8, undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, [], {} ); // $ExpectError - filledarrayBy( buf, 8, {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 8, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 'float64', false ); // $ExpectError - filledarrayBy( buf, 8, 'float64', true ); // $ExpectError - filledarrayBy( buf, 8, 'float64', null ); // $ExpectError - filledarrayBy( buf, 8, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 8, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 8, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 8, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, '5' ); // $ExpectError - filledarrayBy( buf, 8, 2, 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 2, false ); // $ExpectError - filledarrayBy( buf, 8, 2, true ); // $ExpectError - filledarrayBy( buf, 8, 2, null ); // $ExpectError - filledarrayBy( buf, 8, 2, undefined ); // $ExpectError - filledarrayBy( buf, 8, 2, [] ); // $ExpectError - filledarrayBy( buf, 8, 2, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, false, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, true, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, null, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, [], {} ); // $ExpectError - filledarrayBy( buf, 8, 2, {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', false ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', true ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', null ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', {}, {} ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid length, typed array, array-like object, `ArrayBuffer`, or iterable argument... -{ - filledarrayBy( false, clbk ); // $ExpectError - filledarrayBy( true, clbk ); // $ExpectError - filledarrayBy( null, clbk ); // $ExpectError - filledarrayBy( {}, clbk ); // $ExpectError - - filledarrayBy( false, clbk, {} ); // $ExpectError - filledarrayBy( true, clbk, {} ); // $ExpectError - filledarrayBy( null, clbk, {} ); // $ExpectError - filledarrayBy( {}, clbk, {} ); // $ExpectError - - filledarrayBy( false, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 'float64', clbk ); // $ExpectError - - filledarrayBy( false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, clbk ); // $ExpectError - filledarrayBy( 1.0, 8, clbk ); // $ExpectError - filledarrayBy( false, 8, clbk ); // $ExpectError - filledarrayBy( true, 8, clbk ); // $ExpectError - filledarrayBy( null, 8, clbk ); // $ExpectError - filledarrayBy( undefined, 8, clbk ); // $ExpectError - filledarrayBy( [], 8, clbk ); // $ExpectError - filledarrayBy( {}, 8, clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, clbk ); // $ExpectError - - filledarrayBy( '5', 8, clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, clbk, {} ); // $ExpectError - filledarrayBy( false, 8, clbk, {} ); // $ExpectError - filledarrayBy( true, 8, clbk, {} ); // $ExpectError - filledarrayBy( null, 8, clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, clbk, {} ); // $ExpectError - filledarrayBy( [], 8, clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 'float64', clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( false, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( [], 8, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 'float64', clbk ); // $ExpectError - - filledarrayBy( '5', 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 2, clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 2, clbk ); // $ExpectError - filledarrayBy( false, 8, 2, clbk ); // $ExpectError - filledarrayBy( true, 8, 2, clbk ); // $ExpectError - filledarrayBy( null, 8, 2, clbk ); // $ExpectError - filledarrayBy( undefined, 8, 2, clbk ); // $ExpectError - filledarrayBy( [], 8, 2, clbk ); // $ExpectError - filledarrayBy( {}, 8, 2, clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, clbk ); // $ExpectError - - filledarrayBy( '5', 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( false, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( [], 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, 'float64', clbk ); // $ExpectError - - filledarrayBy( '5', 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a byte offset argument which is not a number... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, false, clbk ); // $ExpectError - filledarrayBy( buf, true, clbk ); // $ExpectError - filledarrayBy( buf, null, clbk ); // $ExpectError - filledarrayBy( buf, [], clbk ); // $ExpectError - filledarrayBy( buf, {}, clbk ); // $ExpectError - - filledarrayBy( buf, false, clbk, {} ); // $ExpectError - filledarrayBy( buf, true, clbk, {} ); // $ExpectError - filledarrayBy( buf, null, clbk, {} ); // $ExpectError - filledarrayBy( buf, [], clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, clbk, {} ); // $ExpectError - - filledarrayBy( buf, '5', 'float64', clbk ); // $ExpectError - filledarrayBy( buf, false, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, true, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, null, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, [], 'float64', clbk ); // $ExpectError - filledarrayBy( buf, {}, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, '5', 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( buf, false, 2, clbk ); // $ExpectError - filledarrayBy( buf, true, 2, clbk ); // $ExpectError - filledarrayBy( buf, null, 2, clbk ); // $ExpectError - filledarrayBy( buf, [], 2, clbk ); // $ExpectError - filledarrayBy( buf, {}, 2, clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, clbk ); // $ExpectError - - filledarrayBy( buf, false, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, clbk, {} ); // $ExpectError - - filledarrayBy( buf, '5', 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, false, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, true, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, null, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, undefined, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, [], 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, {}, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, '5', 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, false, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, undefined, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a view length argument which is not a number... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, 8, false, clbk ); // $ExpectError - filledarrayBy( buf, 8, true, clbk ); // $ExpectError - filledarrayBy( buf, 8, null, clbk ); // $ExpectError - filledarrayBy( buf, 8, [], clbk ); // $ExpectError - filledarrayBy( buf, 8, {}, clbk ); // $ExpectError - - filledarrayBy( buf, 8, false, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, true, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, null, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, [], clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, {}, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, clbk, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5', 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, false, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, true, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, null, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, [], 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, {}, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, 8, '5', 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, [], 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, {}, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided too many arguments... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, 8, 2, 'float64', 1, clbk, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 997a381..0000000 --- a/examples/index.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ).factory; -var dtypes = require( '@stdlib/array-typed-real-dtypes' ); -var filledarrayBy = require( './../lib' ); - -// Create a pseudorandom number generator: -var rand = discreteUniform( 0, 100 ); - -// Get a list of array data types: -var dt = dtypes(); - -// Generate filled arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = filledarrayBy( 10, dt[ i ], rand ); - console.log( arr ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 764e40e..cb63cd1 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, RealOrComplexTypedArray, BooleanArray, DataType } from '@stdlib/types/array'; import { IterableIterator } from '@stdlib/types/iter'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..6f157fa --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.3-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.3-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@v0.0.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.3-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.3-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.3-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-ctors@v0.3.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill-by@v0.2.3-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled-by@v0.2.3-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.2.3-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.3-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@v0.2.3-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.4.1-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";var v=f(),g=j.get("dtypes.default");function c(){var f,j,c,b,y,x,u,E;if(0===(j=arguments.length))return new(y=d(g))(0);if(r(c=arguments[0])){if(j>1)throw new TypeError(w("00h05"));if(null===(y=d(c)))throw new TypeError(w("00h2Y",c));return new y(0)}if(j<2)throw new TypeError(w("00h05"));if(h(arguments[j-=1]))if(h(arguments[j-1])){if(f=arguments[j],b=arguments[j-=1],0===j)throw new TypeError(w("00h05"))}else b=arguments[j];else{if(!(j>=2))throw new TypeError(w("00h05"));if(f=arguments[j],!h(b=arguments[j-=1]))throw new TypeError(w("00h2b",b))}if((j-=1)>=0&&r(arguments[j])?(c=arguments[j],j-=1):c=g,null===(y=d(c)))throw new TypeError(w("00h2Y",c));if("generic"===c){if(E=arguments[0],0===j){if(e(E)?u=E:i(E)&&(u=E.length),void 0!==u)return m(u,b,f);if(n(E))throw new Error(w("00h04"));if(o(E)){if(!1===v)throw new TypeError(w("00h2Z",E));if(!h(E[p]))throw new TypeError(w("00h2a",E));if(E=E[p](),!h(E.next))throw new TypeError(w("00h2a",E));return function(r,e,t){var s,i;for(s=[],i=-1;!r.next().done;)i+=1,s.push(e.call(t,i));return s}(E,b,f)}throw new TypeError(w("00h2a",E))}if(n(E))throw new Error(w("00h04"));throw new TypeError(w("00h2a",E))}if(0===j)if(i(E=arguments[0]))x=new y(E.length);else if(n(E))x=new y(E);else if(e(E))x=new y(E);else{if(!o(E))throw new TypeError(w("00h2a",E));if(!1===v)throw new TypeError(w("00h2Z",E));if(!h(E[p]))throw new TypeError(w("00h2a",E));if(E=E[p](),!h(E.next))throw new TypeError(w("00h2a",E));x=new y(a(E))}else x=1===j?new y(arguments[0],arguments[1]):new y(arguments[0],arguments[1],arguments[2]);return x.length>0&&(t(c)||s(c)?function(r,e,t){var s;for(s=0;s\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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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( format('00h05') );\n\t\t}\n\t\tctor = ctors( dtype );\n\t\tif ( ctor === null ) {\n\t\t\tthrow new TypeError( format( '00h2Y', 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( format('00h05') );\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( format('00h05') );\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( '00h2b', clbk ) );\n\t\t}\n\t}\n\t// If we 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( format('00h05') );\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( '00h2Y', 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( format('00h04') );\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( '00h2Z', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00h2a', 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( '00h2a', 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( '00h2a', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format('00h04') );\n\t\t}\n\t\tthrow new TypeError( format( '00h2a', 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( '00h2Z', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00h2a', 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( '00h2a', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00h2a', 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\nexport default filledarrayBy;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","DEFAULT_DTYPE","defaults","get","filledarrayBy","thisArg","nargs","dtype","clbk","ctor","arr","len","arg","arguments","length","ctors","isString","TypeError","format","isFunction","isNonNegativeInteger","isCollection","filledArray","isArrayBuffer","Error","isObject","ITERATOR_SYMBOL","next","it","i","done","push","call","filledArrayIterator","iterLength","isComplexDataType","isBooleanDataType","set","filledAccessors","gfillBy","value","aidx"],"mappings":";;sjDA0CA,IAAIA,EAAsBC,IACtBC,EAAgBC,EAASC,IAAK,kBA2MlC,SAASC,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAKJ,GAAe,KAHfN,EAAQO,UAAUC,QAKjB,OAAO,IADPL,EAAOM,EAAOd,IACG,GAIlB,GAAKe,EADLT,EAAQM,UAAW,IACM,CAExB,GAAKP,EAAQ,EACZ,MAAM,IAAIW,UAAWC,EAAO,UAG7B,GAAc,QADdT,EAAOM,EAAOR,IAEb,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,OAAO,IAAIE,EAAM,EACjB,CAED,GAAKH,EAAQ,EACZ,MAAM,IAAIW,UAAWC,EAAO,UAM7B,GAAKC,EAAYN,UAHjBP,GAAS,IAKR,GAAKa,EAAYN,UAAWP,EAAM,KAMjC,GALAD,EAAUQ,UAAWP,GAErBE,EAAOK,UADPP,GAAS,GAIM,IAAVA,EACJ,MAAM,IAAIW,UAAWC,EAAO,eAI7BV,EAAOK,UAAWP,OAIf,MAAKA,GAAS,GAUlB,MAAM,IAAIW,UAAWC,EAAO,UAN5B,GAHAb,EAAUQ,UAAWP,IAGfa,EADNX,EAAOK,UADPP,GAAS,IAGR,MAAM,IAAIW,UAAWC,EAAQ,QAASV,GAMvC,CAUD,IARAF,GAAS,IACK,GAAKU,EAAUH,UAAWP,KACvCC,EAAQM,UAAWP,GACnBA,GAAS,GAETC,EAAQN,EAGK,QADdQ,EAAOM,EAAOR,IAEb,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,GAAe,YAAVA,EAAsB,CAE1B,GADAK,EAAMC,UAAW,GACF,IAAVP,EAAc,CAMlB,GALKc,EAAsBR,GAC1BD,EAAMC,EACKS,EAAcT,KACzBD,EAAMC,EAAIE,aAEE,IAARH,EACJ,OAAOW,EAAaX,EAAKH,EAAMH,GAEhC,GAAKkB,EAAeX,GACnB,MAAM,IAAIY,MAAON,EAAO,UAEzB,GAAKO,EAAUb,GAAQ,CACtB,IAA6B,IAAxBb,EACJ,MAAM,IAAIkB,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAYP,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLP,EAAYP,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvC,OAvSJ,SAA8BgB,EAAIpB,EAAMH,GACvC,IAAIK,EACAmB,EAKJ,IAFAnB,EAAM,GACNmB,GAAK,GAEAD,EAAGD,OACAG,MAGPD,GAAK,EACLnB,EAAIqB,KAAMvB,EAAKwB,KAAM3B,EAASwB,IAE/B,OAAOnB,CACR,CAuRWuB,CAAqBrB,EAAKJ,EAAMH,EACvC,CACD,MAAM,IAAIY,UAAWC,EAAQ,QAASN,GACzC,CAAS,GAAKW,EAAeX,GAC1B,MAAM,IAAIY,MAAON,EAAO,UAEzB,MAAM,IAAID,UAAWC,EAAQ,QAASN,GACtC,CACD,GAAe,IAAVN,EAEJ,GAAKe,EADLT,EAAMC,UAAW,IAEhBH,EAAM,IAAID,EAAMG,EAAIE,aACd,GAAKS,EAAeX,GAC1BF,EAAM,IAAID,EAAMG,QACV,GAAKQ,EAAsBR,GACjCF,EAAM,IAAID,EAAMG,OACV,KAAKa,EAAUb,GAarB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAZtC,IAA6B,IAAxBb,EACJ,MAAM,IAAIkB,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAYP,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLP,EAAYP,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvCF,EAAM,IAAID,EAAMyB,EAAYtB,GAG5B,MAEDF,EADqB,IAAVJ,EACL,IAAIG,EAAMI,UAAU,GAAIA,UAAU,IAElC,IAAIJ,EAAMI,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKH,EAAII,OAAS,IACZqB,EAAmB5B,IAAW6B,EAAmB7B,GAjTxD,SAA0BG,EAAKF,EAAMH,GACpC,IAAIwB,EACJ,IAAMA,EAAI,EAAGA,EAAInB,EAAII,OAAQe,IAC5BnB,EAAI2B,IAAK7B,EAAKwB,KAAM3B,EAASwB,GAAKA,EAGpC,CA4SGS,CAAiB5B,EAAKF,EAAMH,GAE5BkC,EAAS7B,EAAII,OAAQJ,EAAK,GAe5B,SAAmB8B,EAAOC,GACzB,OAAOjC,EAAKwB,KAAM3B,EAASoC,EAC3B,KAdM/B,CAeR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d115cf0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,192 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -/** -* Create a filled array according to a provided callback function. -* -* @module @stdlib/array-filled-by -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* var arr = filledarrayBy(); -* // returns -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'generic', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( [ 0.5, 0.5 ], clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1; -* } -* -* var arr = filledarrayBy( [ 5, -3 ], 'int32', clbk ); -* // returns [ 1, 1 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk1() { -* return 10; -* } -* -* function clbk2() { -* return 1.0; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, clbk2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk1() { -* return 1.0; -* } -* -* function clbk2() { -* return 2; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, 'uint32', clbk2 ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 'float32', clbk ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, clbk ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, 'int32', clbk ); -* // returns [ 1, 1 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 32b6545..0000000 --- a/lib/main.js +++ /dev/null @@ -1,416 +0,0 @@ -/** -* @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 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' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var ctors = require( '@stdlib/array-ctors' ); -var gfillBy = require( '@stdlib/blas-ext-base-gfill-by' ); -var filledArray = require( '@stdlib/array-base-filled-by' ); -var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var iterLength = require( '@stdlib/iter-length' ); -var defaults = require( '@stdlib/array-defaults' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport(); -var DEFAULT_DTYPE = defaults.get( 'dtypes.default' ); - - -// FUNCTIONS // - -/** -* Creates a filled "generic" array from an iterator. -* -* @private -* @param {Iterable} it - iterator -* @param {Callback} clbk - callback function -* @param {*} thisArg - callback function execution context -* @returns {Array} filled array -*/ -function filledArrayIterator( it, clbk, thisArg ) { - var arr; - var i; - var v; - - arr = []; - i = -1; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - i += 1; - arr.push( clbk.call( thisArg, i ) ); - } - return arr; -} - -/** -* Fills an array exposing accessors for getting and setting array elements. -* -* @private -* @param {Collection} arr - input array -* @param {Callback} clbk - callback function -* @param {*} thisArg - callback function execution context -* @returns {Collection} input array -*/ -function filledAccessors( arr, clbk, thisArg ) { - var i; - for ( i = 0; i < arr.length; i++ ) { - arr.set( clbk.call( thisArg, i ), i ); - } - return arr; -} - - -// MAIN // - -/** -* Creates a filled array according to a provided callback function. -* -* @param {(NonNegativeInteger|TypedArray|ArrayLikeObject|ArrayBuffer|Iterable)} [arg] - a length, typed array, array-like object, buffer, or iterable -* @param {NonNegativeInteger} [byteOffset=0] - byte offset -* @param {NonNegativeInteger} [length] - view length -* @param {string} [dtype="float64"] - data type -* @param {Callback} [clbk] - callback to invoke -* @param {*} [thisArg] - callback execution context -* @throws {TypeError} must provide a recognized data type -* @throws {TypeError} must provide a length, typed array, array-like object, buffer, or iterable -* @throws {TypeError} callback argument must be a function. -* @throws {Error} creating a generic array from an `ArrayBuffer` is not supported -* @returns {(TypedArray|Array)} array or typed array -* -* @example -* var arr = filledarrayBy(); -* // returns -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'generic', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( [ 0.5, 0.5 ], clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1; -* } -* -* var arr = filledarrayBy( [ 5, -3 ], 'int32', clbk ); -* // returns [ 1, 1 ] -* -* @example -* function clbk1() { -* return 10; -* } -* -* function clbk2() { -* return 1.0; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, clbk2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk1() { -* return 1.0; -* } -* -* function clbk2() { -* return 2; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, 'uint32', clbk2 ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 'float32', clbk ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, clbk ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, 'int32', clbk ); -* // returns [ 1, 1 ] -*/ -function filledarrayBy() { - var thisArg; - var nargs; - var dtype; - var clbk; - var ctor; - var arr; - var len; - var arg; - - nargs = arguments.length; - - // If we weren't provided any arguments, return an empty array... - if ( nargs === 0 ) { - ctor = ctors( DEFAULT_DTYPE ); - return new ctor( 0 ); - } - // Check if we were provided a dtype as the first argument... - dtype = arguments[ 0 ]; - if ( isString( dtype ) ) { - // Invoking this function with arguments `f( dtype, clbk[, thisArg] )` is not allowed (otherwise, we'd need to also allow `f( clbk[, thisArg] )`)... - if ( nargs > 1 ) { - throw new TypeError( format('00h05') ); - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '00h2Y', dtype ) ); - } - // Return an empty array having the specified dtype: - return new ctor( 0 ); - } - // For all other supported invocations, we need at least two arguments... - if ( nargs < 2 ) { - throw new TypeError( format('00h05') ); - } - // At this point, we need to do some argument juggling... - nargs -= 1; // henceforth, the number of available arguments is `nargs+1` - - // Determine whether the last argument is a callback or "this" context... - if ( isFunction( arguments[ nargs ] ) ) { - // 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... - if ( isFunction( arguments[ nargs-1 ] ) ) { - thisArg = arguments[ nargs ]; - nargs -= 1; - clbk = arguments[ nargs ]; - - // Check if we were provided only a callback and a "this" context.. - if ( nargs === 0 ) { - throw new TypeError( format('00h05') ); - } - } else { - // "this" context is left undefined... - clbk = arguments[ nargs ]; - } - } - // 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... - else if ( nargs >= 2 ) { - thisArg = arguments[ nargs ]; - nargs -= 1; - clbk = arguments[ nargs ]; - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '00h2b', clbk ) ); - } - } - // If we were only provided 2 arguments and the last argument was not a function, we've been provided an insufficient number of arguments... - else { - throw new TypeError( format('00h05') ); - } - // Now that we've processed the callback arguments, let's continue working backward to see if we've been provided a `dtype` argument... - nargs -= 1; - if ( nargs >= 0 && isString( arguments[ nargs ] ) ) { - dtype = arguments[ nargs ]; - nargs -= 1; - } else { - dtype = DEFAULT_DTYPE; - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '00h2Y', dtype ) ); - } - // At this point, we've resolved the output array data type, and now we can actually create the output array... - if ( dtype === 'generic' ) { - arg = arguments[ 0 ]; - if ( nargs === 0 ) { - if ( isNonNegativeInteger( arg ) ) { - len = arg; - } else if ( isCollection( arg ) ) { - len = arg.length; - } - if ( len !== void 0 ) { - return filledArray( len, clbk, thisArg ); - } - if ( isArrayBuffer( arg ) ) { - throw new Error( format('00h04') ); - } - if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( '00h2Z', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00h2a', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00h2a', arg ) ); - } - return filledArrayIterator( arg, clbk, thisArg ); - } - throw new TypeError( format( '00h2a', arg ) ); - } else if ( isArrayBuffer( arg ) ) { - throw new Error( format('00h04') ); - } - throw new TypeError( format( '00h2a', arg ) ); - } - if ( nargs === 0 ) { // length || array-like || ArrayBuffer || iterable - arg = arguments[ 0 ]; - if ( isCollection( arg ) ) { - arr = new ctor( arg.length ); - } else if ( isArrayBuffer( arg ) ) { - arr = new ctor( arg ); - } else if ( isNonNegativeInteger( arg ) ) { - arr = new ctor( arg ); - } else if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( '00h2Z', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00h2a', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00h2a', arg ) ); - } - arr = new ctor( iterLength( arg ) ); - } else { - throw new TypeError( format( '00h2a', arg ) ); - } - } else if ( nargs === 1 ) { - arr = new ctor( arguments[0], arguments[1] ); // (ArrayBuffer, byteOffset) - } else { - arr = new ctor( arguments[0], arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset, length) - } - if ( arr.length > 0 ) { - if ( isComplexDataType( dtype ) || isBooleanDataType( dtype ) ) { - filledAccessors( arr, clbk, thisArg ); - } else { - gfillBy( arr.length, arr, 1, callback ); - } - } - return arr; - - /** - * Callback which wraps a provided callback and is invoked for each array element. - * - * @private - * @param {*} value - element value - * @param {NonNegativeInteger} aidx - array index - * @param {NonNegativeInteger} sidx - strided index - * @param {Collection} array - input array/collection - * @returns {*} callback return value - */ - function callback( value, aidx ) { - return clbk.call( thisArg, aidx ); - } -} - - -// EXPORTS // - -module.exports = filledarrayBy; diff --git a/package.json b/package.json index ecbe58e..026d062 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.3.1", "description": "Create a filled array according to a provided callback function.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,75 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-assert-is-boolean-data-type": "^0.0.2", - "@stdlib/array-base-assert-is-complex-floating-point-data-type": "^0.2.2", - "@stdlib/array-base-filled-by": "^0.2.3", - "@stdlib/array-ctors": "^0.3.1", - "@stdlib/array-defaults": "^0.4.1", - "@stdlib/assert-has-iterator-symbol-support": "^0.2.3", - "@stdlib/assert-is-arraybuffer": "^0.2.3", - "@stdlib/assert-is-collection": "^0.2.3", - "@stdlib/assert-is-function": "^0.2.3", - "@stdlib/assert-is-nonnegative-integer": "^0.2.3", - "@stdlib/assert-is-object": "^0.2.3", - "@stdlib/assert-is-string": "^0.2.3", - "@stdlib/blas-ext-base-gfill-by": "^0.2.3", - "@stdlib/iter-length": "^0.2.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3", - "@stdlib/symbol-iterator": "^0.2.3", - "@stdlib/types": "^0.4.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3" - }, - "devDependencies": { - "@stdlib/array-bool": "^0.1.2", - "@stdlib/array-buffer": "^0.2.3", - "@stdlib/array-complex128": "^0.3.2", - "@stdlib/array-complex64": "^0.3.2", - "@stdlib/array-float32": "^0.2.3", - "@stdlib/array-float64": "^0.2.3", - "@stdlib/array-int16": "^0.2.3", - "@stdlib/array-int32": "^0.2.3", - "@stdlib/array-int8": "^0.2.3", - "@stdlib/array-typed-real-dtypes": "^0.2.3", - "@stdlib/array-uint16": "^0.2.3", - "@stdlib/array-uint32": "^0.2.3", - "@stdlib/array-uint8": "^0.2.3", - "@stdlib/array-uint8c": "^0.2.3", - "@stdlib/assert-instance-of": "^0.3.1", - "@stdlib/assert-is-array": "^0.2.3", - "@stdlib/assert-is-typed-array": "^0.2.3", - "@stdlib/assert-is-typed-array-like": "^0.2.3", - "@stdlib/complex-float32-ctor": "^0.1.1", - "@stdlib/complex-float64-ctor": "^0.1.2", - "@stdlib/iter-constant": "^0.2.3", - "@stdlib/math-base-special-pow": "^0.3.1", - "@stdlib/random-base-discrete-uniform": "^0.2.2", - "@stdlib/strided-base-reinterpret-boolean": "^0.0.3", - "@stdlib/strided-base-reinterpret-complex128": "^0.2.3", - "@stdlib/strided-base-reinterpret-complex64": "^0.2.2", - "@stdlib/utils-constant-function": "^0.2.3", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.3" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..dabf69c --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index ca0cf25..0000000 --- a/test/test.js +++ /dev/null @@ -1,4397 +0,0 @@ -/** -* @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. -*/ - -/* eslint-disable max-len */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -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' ); -var iterConstant = require( '@stdlib/iter-constant' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var filledarrayBy = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': !hasIteratorSymbolSupport() -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof filledarrayBy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if only provided callback arguments', function test( t ) { - t.throws( clbk1, TypeError, 'throws an error' ); - t.throws( clbk2, TypeError, 'throws an error' ); - t.throws( clbk3, TypeError, 'throws an error' ); - t.end(); - - function clbk1() { - filledarrayBy( constantFunction( 1.0 ) ); - } - - function clbk2() { - filledarrayBy( constantFunction( 1.0 ), {} ); - } - - function clbk3() { - filledarrayBy( constantFunction( 1.0 ), constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (only argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (typed array; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (array-like object)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (array-like object; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 8 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 8 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, 1, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (iterator)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( iterConstant( 1.0 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (iterator; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( iterConstant( 1.0 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if only provided data type and callback arguments', function test( t ) { - t.throws( clbk1, TypeError, 'throws an error' ); - t.throws( clbk2, TypeError, 'throws an error' ); - t.throws( clbk3, TypeError, 'throws an error' ); - t.end(); - - function clbk1() { - filledarrayBy( 'float64', constantFunction( 1.0 ) ); - } - - function clbk2() { - filledarrayBy( 'float64', constantFunction( 1.0 ), {} ); - } - - function clbk3() { - filledarrayBy( 'float64', constantFunction( 1.0 ), constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (array-like object)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (array-like object; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, 1, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, 1, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (no iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (no iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (non-function iterator symbol property)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (non-function iterator symbol property; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (`next` property is not a function)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ) ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (`next` property is not a function; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ), {} ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (no iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (no iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (non-function iterator symbol property)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (non-function iterator symbol property; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (`next` property is not a function)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ) ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (`next` property is not a function; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ), {} ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 1, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 1, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function returns a filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - arr = filledarrayBy(); - - t.strictEqual( instanceOf( arr, Float64Array ), 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=float64)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - arr = filledarrayBy( 'float64' ); - - t.strictEqual( instanceOf( arr, Float64Array ), 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=float32)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( 0 ); - arr = filledarrayBy( 'float32' ); - - t.strictEqual( instanceOf( arr, Float32Array ), 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=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; - - expected = new Complex128Array( 0 ); - arr = filledarrayBy( 'complex128' ); - - t.strictEqual( instanceOf( arr, Complex128Array ), 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=complex64)', function test( t ) { - var expected; - var arr; - - expected = new Complex64Array( 0 ); - arr = filledarrayBy( 'complex64' ); - - t.strictEqual( instanceOf( arr, Complex64Array ), 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=int32)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( 0 ); - arr = filledarrayBy( 'int32' ); - - t.strictEqual( instanceOf( arr, Int32Array ), 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=uint32)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( 0 ); - arr = filledarrayBy( 'uint32' ); - - t.strictEqual( instanceOf( arr, Uint32Array ), 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=int16)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( 0 ); - arr = filledarrayBy( 'int16' ); - - t.strictEqual( instanceOf( arr, Int16Array ), 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=uint16)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( 0 ); - arr = filledarrayBy( 'uint16' ); - - t.strictEqual( instanceOf( arr, Uint16Array ), 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=int8)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( 0 ); - arr = filledarrayBy( 'int8' ); - - t.strictEqual( instanceOf( arr, Int8Array ), 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=uint8)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( 0 ); - arr = filledarrayBy( 'uint8' ); - - t.strictEqual( instanceOf( arr, Uint8Array ), 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=uint8c)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( 0 ); - arr = filledarrayBy( 'uint8c' ); - - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), 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=generic)', function test( t ) { - var expected; - var arr; - - expected = []; - arr = filledarrayBy( 'generic' ); - - t.strictEqual( instanceOf( arr, Array ), 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 (default, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, length=0)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array(); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 0, clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, clbk, ctx ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (default, length; thisArg=function)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, clbk, context ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this(); // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } - - function context() { - ctx.count += 1; - } -}); - -tape( 'the function returns a filled array (dtype=float64, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, 'float64', clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, length; thisArg=function)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, 'float64', clbk, context ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this(); // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } - - function context() { - ctx.count += 1; - } -}); - -tape( 'the function returns a filled array (dtype=float32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, 'float32', clbk ); - - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - 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; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = filledarrayBy( 5, 'complex128', clbk ); - - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = filledarrayBy( 5, 'complex64', clbk ); - - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int32Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int32', clbk ); - - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint32Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint32', clbk ); - - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int16Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int16', clbk ); - - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint16', clbk ); - - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int8Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int8', clbk ); - - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint8', clbk ); - - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint8c', clbk ); - - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = [ 1, 1, 1, 1, 1 ]; - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'generic', clbk ); - - t.strictEqual( instanceOf( arr, Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - 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; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = [ 1.0, 2.0 ]; - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = [ 1.0, 2.0 ]; - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int32', clbk ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, typed array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, typed array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - 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; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = new Float64Array( [ 1.0, 2.0 ] ); - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = new Float64Array( [ 1.0, 2.0 ] ); - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (default, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - 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; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer, byteoffset; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer, byteoffset; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - 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; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 48 ); - out = filledarrayBy( buf, 16, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 24 ); - out = filledarrayBy( buf, 8, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int32', clbk ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint8c', clbk ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - 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; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 64 ); - out = filledarrayBy( buf, 16, 2, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset, length)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 1, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 1, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled array (default, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, iterator; thisArg)', opts, function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - ctx = { - 'count': 0 - }; - indices = []; - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, iterator; thisArg)', opts, function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - ctx = { - 'count': 0 - }; - indices = []; - out = filledarrayBy( arr, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - 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; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = iterConstant( new Complex128( 3.0, 3.0 ), { - 'iter': 2 - }); - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = iterConstant( new Complex64( 3.0, 3.0 ), { - 'iter': 2 - }); - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); From 117746837d654ebef95c5f23d2d3283c0a5ac1b5 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 14 May 2026 03:43:57 +0000 Subject: [PATCH 106/117] Transform error messages --- lib/main.js | 38 +++++++++++++++++++------------------- package.json | 2 +- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/lib/main.js b/lib/main.js index d2128f5..32b6545 100644 --- a/lib/main.js +++ b/lib/main.js @@ -35,7 +35,7 @@ var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-supp var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); var iterLength = require( '@stdlib/iter-length' ); var defaults = require( '@stdlib/array-defaults' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -266,18 +266,18 @@ function filledarrayBy() { if ( isString( dtype ) ) { // Invoking this function with arguments `f( dtype, clbk[, thisArg] )` is not allowed (otherwise, we'd need to also allow `f( clbk[, thisArg] )`)... if ( nargs > 1 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format('00h05') ); } ctor = ctors( dtype ); if ( ctor === null ) { - throw new TypeError( format( 'invalid argument. Must provide a recognized data type. Value: `%s`.', dtype ) ); + throw new TypeError( format( '00h2Y', dtype ) ); } // Return an empty array having the specified dtype: return new ctor( 0 ); } // For all other supported invocations, we need at least two arguments... if ( nargs < 2 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format('00h05') ); } // At this point, we need to do some argument juggling... nargs -= 1; // henceforth, the number of available arguments is `nargs+1` @@ -292,7 +292,7 @@ function filledarrayBy() { // Check if we were provided only a callback and a "this" context.. if ( nargs === 0 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format('00h05') ); } } else { // "this" context is left undefined... @@ -305,12 +305,12 @@ function filledarrayBy() { nargs -= 1; clbk = arguments[ nargs ]; if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '00h2b', clbk ) ); } } // If we were only provided 2 arguments and the last argument was not a function, we've been provided an insufficient number of arguments... else { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format('00h05') ); } // Now that we've processed the callback arguments, let's continue working backward to see if we've been provided a `dtype` argument... nargs -= 1; @@ -322,7 +322,7 @@ function filledarrayBy() { } ctor = ctors( dtype ); if ( ctor === null ) { - throw new TypeError( format( 'invalid argument. Must provide a recognized data type. Value: `%s`.', dtype ) ); + throw new TypeError( format( '00h2Y', dtype ) ); } // At this point, we've resolved the output array data type, and now we can actually create the output array... if ( dtype === 'generic' ) { @@ -337,26 +337,26 @@ function filledarrayBy() { return filledArray( len, clbk, thisArg ); } if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format('00h04') ); } if ( isObject( arg ) ) { if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2Z', arg ) ); } if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } arg = arg[ ITERATOR_SYMBOL ](); if ( !isFunction( arg.next ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } return filledArrayIterator( arg, clbk, thisArg ); } - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } else if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format('00h04') ); } - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } if ( nargs === 0 ) { // length || array-like || ArrayBuffer || iterable arg = arguments[ 0 ]; @@ -368,18 +368,18 @@ function filledarrayBy() { arr = new ctor( arg ); } else if ( isObject( arg ) ) { if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2Z', arg ) ); } if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } arg = arg[ ITERATOR_SYMBOL ](); if ( !isFunction( arg.next ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } arr = new ctor( iterLength( arg ) ); } else { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } } else if ( nargs === 1 ) { arr = new ctor( arguments[0], arguments[1] ); // (ArrayBuffer, byteOffset) diff --git a/package.json b/package.json index 0edfb95..ecbe58e 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "@stdlib/assert-is-string": "^0.2.3", "@stdlib/blas-ext-base-gfill-by": "^0.2.3", "@stdlib/iter-length": "^0.2.3", - "@stdlib/string-format": "^0.2.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.3", "@stdlib/symbol-iterator": "^0.2.3", "@stdlib/types": "^0.4.3", "@stdlib/error-tools-fmtprodmsg": "^0.2.3" From ad732be576948abbd0820fc93718588c86f58326 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 14 May 2026 03:54:49 +0000 Subject: [PATCH 107/117] Remove files --- index.d.ts | 322 ---- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5169 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index cb63cd1..0000000 --- a/index.d.ts +++ /dev/null @@ -1,322 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, RealOrComplexTypedArray, BooleanArray, DataType } from '@stdlib/types/array'; -import { IterableIterator } from '@stdlib/types/iter'; - -/** -* Array or typed array. -*/ -type ArrayOrTypedArray = Array | RealOrComplexTypedArray | BooleanArray; - -/** -* Nullary callback function. -* -* @returns fill value -*/ -type Nullary = () => any; - -/** -* Unary callback function. -* -* @param i - current array index -* @returns fill value -*/ -type Unary = ( i: number ) => any; - -/** -* Callback function. -* -* @param i - current array index -* @returns fill value -*/ -type Callback = Nullary | Unary; - -/** -* Creates a filled array according to a provided callback function and having a specified data type. -* -* @param dtype - data type -* @returns filled array -* -* @example -* var arr = filledarrayBy(); -* // returns -* -* @example -* var arr = filledarrayBy( 'float32' ); -* // returns -*/ -declare function filledarrayBy( dtype?: DataType ): ArrayOrTypedArray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Creates a filled array according to a provided callback function and having a specified `length`. -* -* @param length - array length -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* -* var arr = filledarrayBy( 5, constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( length: number, clbk: Callback, thisArg?: any ): ArrayOrTypedArray; - -/** -* Creates a filled array according to a provided callback function and having a specified `length`. -* -* @param length - array length -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* -* var arr = filledarrayBy( 5, 'float64', constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( length: number, dtype: DataType, clbk: Callback, thisArg?: any ): ArrayOrTypedArray; - -/** -* Creates a filled array from another `array` according to a provided callback function. -* -* @param array - typed array or array-like object -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* -* 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; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Creates a filled array from another `array` according to a provided callback function. -* -* @param array - typed array or array-like object -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* -* 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; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Creates a filled array from an iterable according to a callback function. -* -* @param iterable - iterable -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var iterConstant = require( '@stdlib/iter-constant' ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarrayBy( it, constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( iterable: IterableIterator, clbk: Callback, thisArg?: any ): ArrayOrTypedArray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Creates a filled array from an iterable according to a callback function. -* -* @param iterable - iterable -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var iterConstant = require( '@stdlib/iter-constant' ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarrayBy( it, 'float64', constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( iterable: IterableIterator, dtype: DataType, clbk: 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. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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 | BooleanArray; - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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 | BooleanArray; - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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 | BooleanArray; - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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 | BooleanArray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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 | BooleanArray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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 | BooleanArray; // eslint-disable-line @typescript-eslint/unified-signatures - - -// EXPORTS // - -export = filledarrayBy; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 6f157fa..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.3-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.3-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@v0.0.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.3-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.3-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.3-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-ctors@v0.3.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill-by@v0.2.3-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled-by@v0.2.3-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.2.3-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.3-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@v0.2.3-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.4.1-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";var v=f(),g=j.get("dtypes.default");function c(){var f,j,c,b,y,x,u,E;if(0===(j=arguments.length))return new(y=d(g))(0);if(r(c=arguments[0])){if(j>1)throw new TypeError(w("00h05"));if(null===(y=d(c)))throw new TypeError(w("00h2Y",c));return new y(0)}if(j<2)throw new TypeError(w("00h05"));if(h(arguments[j-=1]))if(h(arguments[j-1])){if(f=arguments[j],b=arguments[j-=1],0===j)throw new TypeError(w("00h05"))}else b=arguments[j];else{if(!(j>=2))throw new TypeError(w("00h05"));if(f=arguments[j],!h(b=arguments[j-=1]))throw new TypeError(w("00h2b",b))}if((j-=1)>=0&&r(arguments[j])?(c=arguments[j],j-=1):c=g,null===(y=d(c)))throw new TypeError(w("00h2Y",c));if("generic"===c){if(E=arguments[0],0===j){if(e(E)?u=E:i(E)&&(u=E.length),void 0!==u)return m(u,b,f);if(n(E))throw new Error(w("00h04"));if(o(E)){if(!1===v)throw new TypeError(w("00h2Z",E));if(!h(E[p]))throw new TypeError(w("00h2a",E));if(E=E[p](),!h(E.next))throw new TypeError(w("00h2a",E));return function(r,e,t){var s,i;for(s=[],i=-1;!r.next().done;)i+=1,s.push(e.call(t,i));return s}(E,b,f)}throw new TypeError(w("00h2a",E))}if(n(E))throw new Error(w("00h04"));throw new TypeError(w("00h2a",E))}if(0===j)if(i(E=arguments[0]))x=new y(E.length);else if(n(E))x=new y(E);else if(e(E))x=new y(E);else{if(!o(E))throw new TypeError(w("00h2a",E));if(!1===v)throw new TypeError(w("00h2Z",E));if(!h(E[p]))throw new TypeError(w("00h2a",E));if(E=E[p](),!h(E.next))throw new TypeError(w("00h2a",E));x=new y(a(E))}else x=1===j?new y(arguments[0],arguments[1]):new y(arguments[0],arguments[1],arguments[2]);return x.length>0&&(t(c)||s(c)?function(r,e,t){var s;for(s=0;s\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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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( format('00h05') );\n\t\t}\n\t\tctor = ctors( dtype );\n\t\tif ( ctor === null ) {\n\t\t\tthrow new TypeError( format( '00h2Y', 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( format('00h05') );\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( format('00h05') );\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( '00h2b', clbk ) );\n\t\t}\n\t}\n\t// If we 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( format('00h05') );\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( '00h2Y', 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( format('00h04') );\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( '00h2Z', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00h2a', 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( '00h2a', 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( '00h2a', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format('00h04') );\n\t\t}\n\t\tthrow new TypeError( format( '00h2a', 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( '00h2Z', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00h2a', 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( '00h2a', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00h2a', 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\nexport default filledarrayBy;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","DEFAULT_DTYPE","defaults","get","filledarrayBy","thisArg","nargs","dtype","clbk","ctor","arr","len","arg","arguments","length","ctors","isString","TypeError","format","isFunction","isNonNegativeInteger","isCollection","filledArray","isArrayBuffer","Error","isObject","ITERATOR_SYMBOL","next","it","i","done","push","call","filledArrayIterator","iterLength","isComplexDataType","isBooleanDataType","set","filledAccessors","gfillBy","value","aidx"],"mappings":";;sjDA0CA,IAAIA,EAAsBC,IACtBC,EAAgBC,EAASC,IAAK,kBA2MlC,SAASC,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAKJ,GAAe,KAHfN,EAAQO,UAAUC,QAKjB,OAAO,IADPL,EAAOM,EAAOd,IACG,GAIlB,GAAKe,EADLT,EAAQM,UAAW,IACM,CAExB,GAAKP,EAAQ,EACZ,MAAM,IAAIW,UAAWC,EAAO,UAG7B,GAAc,QADdT,EAAOM,EAAOR,IAEb,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,OAAO,IAAIE,EAAM,EACjB,CAED,GAAKH,EAAQ,EACZ,MAAM,IAAIW,UAAWC,EAAO,UAM7B,GAAKC,EAAYN,UAHjBP,GAAS,IAKR,GAAKa,EAAYN,UAAWP,EAAM,KAMjC,GALAD,EAAUQ,UAAWP,GAErBE,EAAOK,UADPP,GAAS,GAIM,IAAVA,EACJ,MAAM,IAAIW,UAAWC,EAAO,eAI7BV,EAAOK,UAAWP,OAIf,MAAKA,GAAS,GAUlB,MAAM,IAAIW,UAAWC,EAAO,UAN5B,GAHAb,EAAUQ,UAAWP,IAGfa,EADNX,EAAOK,UADPP,GAAS,IAGR,MAAM,IAAIW,UAAWC,EAAQ,QAASV,GAMvC,CAUD,IARAF,GAAS,IACK,GAAKU,EAAUH,UAAWP,KACvCC,EAAQM,UAAWP,GACnBA,GAAS,GAETC,EAAQN,EAGK,QADdQ,EAAOM,EAAOR,IAEb,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,GAAe,YAAVA,EAAsB,CAE1B,GADAK,EAAMC,UAAW,GACF,IAAVP,EAAc,CAMlB,GALKc,EAAsBR,GAC1BD,EAAMC,EACKS,EAAcT,KACzBD,EAAMC,EAAIE,aAEE,IAARH,EACJ,OAAOW,EAAaX,EAAKH,EAAMH,GAEhC,GAAKkB,EAAeX,GACnB,MAAM,IAAIY,MAAON,EAAO,UAEzB,GAAKO,EAAUb,GAAQ,CACtB,IAA6B,IAAxBb,EACJ,MAAM,IAAIkB,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAYP,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLP,EAAYP,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvC,OAvSJ,SAA8BgB,EAAIpB,EAAMH,GACvC,IAAIK,EACAmB,EAKJ,IAFAnB,EAAM,GACNmB,GAAK,GAEAD,EAAGD,OACAG,MAGPD,GAAK,EACLnB,EAAIqB,KAAMvB,EAAKwB,KAAM3B,EAASwB,IAE/B,OAAOnB,CACR,CAuRWuB,CAAqBrB,EAAKJ,EAAMH,EACvC,CACD,MAAM,IAAIY,UAAWC,EAAQ,QAASN,GACzC,CAAS,GAAKW,EAAeX,GAC1B,MAAM,IAAIY,MAAON,EAAO,UAEzB,MAAM,IAAID,UAAWC,EAAQ,QAASN,GACtC,CACD,GAAe,IAAVN,EAEJ,GAAKe,EADLT,EAAMC,UAAW,IAEhBH,EAAM,IAAID,EAAMG,EAAIE,aACd,GAAKS,EAAeX,GAC1BF,EAAM,IAAID,EAAMG,QACV,GAAKQ,EAAsBR,GACjCF,EAAM,IAAID,EAAMG,OACV,KAAKa,EAAUb,GAarB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAZtC,IAA6B,IAAxBb,EACJ,MAAM,IAAIkB,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAYP,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLP,EAAYP,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvCF,EAAM,IAAID,EAAMyB,EAAYtB,GAG5B,MAEDF,EADqB,IAAVJ,EACL,IAAIG,EAAMI,UAAU,GAAIA,UAAU,IAElC,IAAIJ,EAAMI,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKH,EAAII,OAAS,IACZqB,EAAmB5B,IAAW6B,EAAmB7B,GAjTxD,SAA0BG,EAAKF,EAAMH,GACpC,IAAIwB,EACJ,IAAMA,EAAI,EAAGA,EAAInB,EAAII,OAAQe,IAC5BnB,EAAI2B,IAAK7B,EAAKwB,KAAM3B,EAASwB,GAAKA,EAGpC,CA4SGS,CAAiB5B,EAAKF,EAAMH,GAE5BkC,EAAS7B,EAAII,OAAQJ,EAAK,GAe5B,SAAmB8B,EAAOC,GACzB,OAAOjC,EAAKwB,KAAM3B,EAASoC,EAC3B,KAdM/B,CAeR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index dabf69c..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 9c6821e3ea73db3884b49098ad36af189b38c23d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 14 May 2026 03:55:10 +0000 Subject: [PATCH 108/117] Auto-generated commit --- .editorconfig | 189 - .eslintrc.js | 1 - .gitattributes | 68 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 101 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 204 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 236 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 49 +- SECURITY.md | 5 - benchmark/benchmark.js | 342 -- benchmark/benchmark.length.bool.js | 98 - benchmark/benchmark.length.complex128.js | 99 - benchmark/benchmark.length.complex64.js | 99 - benchmark/benchmark.length.float32.js | 98 - benchmark/benchmark.length.float64.js | 98 - benchmark/benchmark.length.generic.js | 98 - benchmark/benchmark.length.int16.js | 98 - benchmark/benchmark.length.int32.js | 98 - benchmark/benchmark.length.int8.js | 98 - benchmark/benchmark.length.uint16.js | 98 - benchmark/benchmark.length.uint32.js | 98 - benchmark/benchmark.length.uint8.js | 98 - benchmark/benchmark.length.uint8c.js | 98 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 36 - dist/index.js.map | 7 - docs/repl.txt | 157 - docs/types/test.ts | 606 --- examples/index.js | 37 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 192 - lib/main.js | 416 -- package.json | 96 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 4397 ---------------- 57 files changed, 4870 insertions(+), 11321 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.length.bool.js delete mode 100644 benchmark/benchmark.length.complex128.js delete mode 100644 benchmark/benchmark.length.complex64.js delete mode 100644 benchmark/benchmark.length.float32.js delete mode 100644 benchmark/benchmark.length.float64.js delete mode 100644 benchmark/benchmark.length.generic.js delete mode 100644 benchmark/benchmark.length.int16.js delete mode 100644 benchmark/benchmark.length.int32.js delete mode 100644 benchmark/benchmark.length.int8.js delete mode 100644 benchmark/benchmark.length.uint16.js delete mode 100644 benchmark/benchmark.length.uint32.js delete mode 100644 benchmark/benchmark.length.uint8.js delete mode 100644 benchmark/benchmark.length.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 80f3fca..0000000 --- a/.editorconfig +++ /dev/null @@ -1,189 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Ignore generated lock files for GitHub Agentic Workflows: -[*.lock.yml] -charset = unset -end_of_line = unset -indent_style = unset -indent_size = unset -trim_trailing_whitespace = unset -insert_final_newline = unset - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 24b327f..0000000 --- a/.gitattributes +++ /dev/null @@ -1,68 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation - -.github/workflows/*.lock.yml linguist-generated=true merge=ours diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 6e3315f..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2026-05-14T03:35:24.094Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 2d6aaee..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/contributing/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index f988046..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index b2c1f9c..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '42 6 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 83d50c4..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,821 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send notification to Zulip if job fails: - - name: 'Send notification to Zulip in case of failure' - # Pin action to full length commit SHA - uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 - if: failure() - with: - api-key: ${{ secrets.ZULIP_API_KEY }} - email: 'github-actions-bot@stdlib.zulipchat.com' - organization-url: 'https://stdlib.zulipchat.com' - to: 'workflows-standalone' - type: 'stream' - topic: ${{ github.event.repository.name }} - content: | - :cross_mark: **${{ github.workflow }}** workflow failed - - **Repository:** [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) - **Run:** [View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -278,7 +269,7 @@ for ( i = 0; i < dt.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -347,13 +338,13 @@ Copyright © 2016-2026. 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/dtypes]: https://github.com/stdlib-js/array-dtypes/tree/esm -[@stdlib/array/filled]: https://github.com/stdlib-js/array-filled +[@stdlib/array/filled]: https://github.com/stdlib-js/array-filled/tree/esm -[@stdlib/array/typed]: https://github.com/stdlib-js/array-typed +[@stdlib/array/typed]: https://github.com/stdlib-js/array-typed/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 6fba606..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,342 +0,0 @@ -/** -* @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 isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); -var isArray = require( '@stdlib/assert-is-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var Complex64 = require( '@stdlib/complex-float32-ctor' ); -var Complex128 = require( '@stdlib/complex-float64-ctor' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var filledarrayBy = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 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( format( '%s:dtype=float64', pkg ), function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'float64', 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( format( '%s:dtype=float32', pkg ), function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'float32', 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( format( '%s:dtype=bool', pkg ), 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( format( '%s:dtype=complex128', pkg ), function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( new Complex128( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'complex128', 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( format( '%s:dtype=complex64', pkg ), function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( new Complex64( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'complex64', 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( format( '%s:dtype=int32', pkg ), function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int32', 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( format( '%s:dtype=uint32', pkg ), function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint32', 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( format( '%s:dtype=int16', pkg ), function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int16', 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( format( '%s:dtype=uint16', pkg ), function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint16', 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( format( '%s:dtype=int8', pkg ), function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int8', 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( format( '%s:dtype=uint8', pkg ), function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint8', 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( format( '%s:dtype=uint8c', pkg ), function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint8c', 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( format( '%s:dtype=generic', pkg ), function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'generic', clbk ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.length.bool.js b/benchmark/benchmark.length.bool.js deleted file mode 100644 index 52b3237..0000000 --- a/benchmark/benchmark.length.bool.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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 format = require( '@stdlib/string-format' ); -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( format( '%s:dtype=bool,len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.complex128.js b/benchmark/benchmark.length.complex128.js deleted file mode 100644 index 63c0843..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,99 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 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 Complex128 = require( '@stdlib/complex-float64-ctor' ); -var format = require( '@stdlib/string-format' ); -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( new Complex128( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'complex128', 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( format( '%s:dtype=complex128,len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.complex64.js b/benchmark/benchmark.length.complex64.js deleted file mode 100644 index 186f811..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,99 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 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 Complex64 = require( '@stdlib/complex-float32-ctor' ); -var format = require( '@stdlib/string-format' ); -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( new Complex64( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'complex64', 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( format( '%s:dtype=complex64,len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.float32.js b/benchmark/benchmark.length.float32.js deleted file mode 100644 index 5ba3130..0000000 --- a/benchmark/benchmark.length.float32.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/string-format' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'float32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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( format( '%s:dtype=float32,len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.float64.js b/benchmark/benchmark.length.float64.js deleted file mode 100644 index 4a2be6c..0000000 --- a/benchmark/benchmark.length.float64.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/string-format' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'float64', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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( format( '%s:dtype=float64,len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.generic.js b/benchmark/benchmark.length.generic.js deleted file mode 100644 index 6522748..0000000 --- a/benchmark/benchmark.length.generic.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isArray = require( '@stdlib/assert-is-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/string-format' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'generic', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isArray( 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( format( '%s:dtype=generic,len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int16.js b/benchmark/benchmark.length.int16.js deleted file mode 100644 index 9ac94e9..0000000 --- a/benchmark/benchmark.length.int16.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/string-format' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int16', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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( format( '%s:dtype=int16,len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int32.js b/benchmark/benchmark.length.int32.js deleted file mode 100644 index a5ce4d0..0000000 --- a/benchmark/benchmark.length.int32.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/string-format' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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( format( '%s:dtype=int32,len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int8.js b/benchmark/benchmark.length.int8.js deleted file mode 100644 index 6104616..0000000 --- a/benchmark/benchmark.length.int8.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/string-format' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int8', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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( format( '%s:dtype=int8,len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint16.js b/benchmark/benchmark.length.uint16.js deleted file mode 100644 index 3108633..0000000 --- a/benchmark/benchmark.length.uint16.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/string-format' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint16', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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( format( '%s:dtype=uint16,len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint32.js b/benchmark/benchmark.length.uint32.js deleted file mode 100644 index 602e232..0000000 --- a/benchmark/benchmark.length.uint32.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/string-format' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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( format( '%s:dtype=uint32,len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint8.js b/benchmark/benchmark.length.uint8.js deleted file mode 100644 index 8664da3..0000000 --- a/benchmark/benchmark.length.uint8.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/string-format' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint8', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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( format( '%s:dtype=uint8,len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint8c.js b/benchmark/benchmark.length.uint8c.js deleted file mode 100644 index 76645b9..0000000 --- a/benchmark/benchmark.length.uint8c.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/string-format' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint8c', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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( format( '%s:dtype=uint8c,len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index c138144..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by" -%% click B href "https://github.com/stdlib-js/array-filled-by/tree/main" -%% click C href "https://github.com/stdlib-js/array-filled-by/tree/production" -%% click D href "https://github.com/stdlib-js/array-filled-by/tree/esm" -%% click E href "https://github.com/stdlib-js/array-filled-by/tree/deno" -%% click F href "https://github.com/stdlib-js/array-filled-by/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by -[production-url]: https://github.com/stdlib-js/array-filled-by/tree/production -[deno-url]: https://github.com/stdlib-js/array-filled-by/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-filled-by/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-filled-by/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-filled-by/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-filled-by/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-filled-by/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 188fc9b..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import filledarrayBy from '../docs/types/index'; -export = filledarrayBy; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 65ae3db..0000000 --- a/dist/index.js +++ /dev/null @@ -1,36 +0,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 deleted file mode 100644 index b348e92..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "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 we 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,YACjDC,EAAuB,QAAS,uCAAwC,EAAE,YAC1EC,EAAoB,QAAS,+DAAgE,EAC7FC,EAAoB,QAAS,gDAAiD,EAC9EC,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,EAAQ,UAAU,OAGbA,IAAU,EACd,OAAAE,EAAOrB,EAAOS,CAAc,EACrB,IAAIY,EAAM,CAAE,EAIpB,GADAD,EAAQ,UAAW,CAAE,EAChB5B,EAAU4B,CAAM,EAAI,CAExB,GAAKD,EAAQ,EACZ,MAAM,IAAI,UAAW,2FAA4F,EAGlH,GADAE,EAAOrB,EAAOoB,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWd,EAAQ,sEAAuEa,CAAM,CAAE,EAG7G,OAAO,IAAIC,EAAM,CAAE,CACpB,CAEA,GAAKF,EAAQ,EACZ,MAAM,IAAI,UAAW,2FAA4F,EAMlH,GAHAA,GAAS,EAGJpB,EAAY,UAAWoB,CAAM,CAAE,EAEnC,GAAKpB,EAAY,UAAWoB,EAAM,CAAE,CAAE,GAMrC,GALAN,EAAU,UAAWM,CAAM,EAC3BA,GAAS,EACTP,EAAO,UAAWO,CAAM,EAGnBA,IAAU,EACd,MAAM,IAAI,UAAW,2FAA4F,OAIlHP,EAAO,UAAWO,CAAM,UAIhBA,GAAS,GAIlB,GAHAN,EAAU,UAAWM,CAAM,EAC3BA,GAAS,EACTP,EAAO,UAAWO,CAAM,EACnB,CAACpB,EAAYa,CAAK,EACtB,MAAM,IAAI,UAAWL,EAAQ,uEAAwEK,CAAK,CAAE,MAK7G,OAAM,IAAI,UAAW,2FAA4F,EAWlH,GARAO,GAAS,EACJA,GAAS,GAAK3B,EAAU,UAAW2B,CAAM,CAAE,GAC/CC,EAAQ,UAAWD,CAAM,EACzBA,GAAS,GAETC,EAAQX,EAETY,EAAOrB,EAAOoB,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWd,EAAQ,sEAAuEa,CAAM,CAAE,EAG7G,GAAKA,IAAU,UAAY,CAE1B,GADAG,EAAM,UAAW,CAAE,EACdJ,IAAU,EAAI,CAMlB,GALK1B,EAAsB8B,CAAI,EAC9BD,EAAMC,EACK3B,EAAc2B,CAAI,IAC7BD,EAAMC,EAAI,QAEND,IAAQ,OACZ,OAAOpB,EAAaoB,EAAKV,EAAMC,CAAQ,EAExC,GAAKhB,EAAe0B,CAAI,EACvB,MAAM,IAAI,MAAO,mFAAoF,EAEtG,GAAKzB,EAAUyB,CAAI,EAAI,CACtB,GAAKf,IAAwB,GAC5B,MAAM,IAAI,UAAWD,EAAQ,sIAAuIgB,CAAI,CAAE,EAE3K,GAAK,CAACxB,EAAYwB,EAAKnB,CAAgB,CAAE,EACxC,MAAM,IAAI,UAAWG,EAAQ,wGAAyGgB,CAAI,CAAE,EAG7I,GADAA,EAAMA,EAAKnB,CAAgB,EAAE,EACxB,CAACL,EAAYwB,EAAI,IAAK,EAC1B,MAAM,IAAI,UAAWhB,EAAQ,wGAAyGgB,CAAI,CAAE,EAE7I,OAAOb,EAAqBa,EAAKX,EAAMC,CAAQ,CAChD,CACA,MAAM,IAAI,UAAWN,EAAQ,wGAAyGgB,CAAI,CAAE,CAC7I,SAAY1B,EAAe0B,CAAI,EAC9B,MAAM,IAAI,MAAO,mFAAoF,EAEtG,MAAM,IAAI,UAAWhB,EAAQ,wGAAyGgB,CAAI,CAAE,CAC7I,CACA,GAAKJ,IAAU,EAEd,GADAI,EAAM,UAAW,CAAE,EACd3B,EAAc2B,CAAI,EACtBT,EAAM,IAAIO,EAAME,EAAI,MAAO,UAChB1B,EAAe0B,CAAI,EAC9BT,EAAM,IAAIO,EAAME,CAAI,UACT9B,EAAsB8B,CAAI,EACrCT,EAAM,IAAIO,EAAME,CAAI,UACTzB,EAAUyB,CAAI,EAAI,CAC7B,GAAKf,IAAwB,GAC5B,MAAM,IAAI,UAAWD,EAAQ,sIAAuIgB,CAAI,CAAE,EAE3K,GAAK,CAACxB,EAAYwB,EAAKnB,CAAgB,CAAE,EACxC,MAAM,IAAI,UAAWG,EAAQ,wGAAyGgB,CAAI,CAAE,EAG7I,GADAA,EAAMA,EAAKnB,CAAgB,EAAE,EACxB,CAACL,EAAYwB,EAAI,IAAK,EAC1B,MAAM,IAAI,UAAWhB,EAAQ,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,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 deleted file mode 100644 index 06f3146..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,157 +0,0 @@ - -{{alias}}( [dtype] ) - Creates a filled array. - - Parameters - ---------- - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr = {{alias}}() - - > arr = {{alias}}( 'float32' ) - - - -{{alias}}( length[, dtype], clbk[, thisArg] ) - Returns a filled array according to a provided callback function and having - a specified length. - - Parameters - ---------- - length: integer - Array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > function clbk() { return 1.0; }; - > var arr = {{alias}}( 5, clbk ) - [ 1.0, 1.0, 1.0, 1.0, 1.0 ] - > arr = {{alias}}( 5, 'int32', clbk ) - [ 1, 1, 1, 1, 1 ] - - -{{alias}}( array[, dtype], clbk[, thisArg] ) - Creates a filled array from another array (or array-like object) according - to a provided callback function. - - Parameters - ---------- - array: ArrayLikeObject - Array from which to generate another array. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias}}( [ 0.5, 0.5, 0.5 ], {{alias:@stdlib/utils/constant-function}}( 2.0 ) ) - [ 2.0, 2.0, 2.0 ] - > var arr2 = {{alias}}( arr1, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( iterable[, dtype], clbk[, thisArg] ) - Creates a filled array from an iterable according to a provided callback - function. - - Parameters - ---------- - iterable: Iterable - Iterable from which to generate an array. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias:@stdlib/iter/constant}}( 3.0, {'iter': 3} ); - > var arr2 = {{alias}}( arr1, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( buffer[, byteOffset[, length]][, dtype], clbk[, thisArg] ) - Returns a filled typed array view of an ArrayBuffer according to a provided - callback function. - - The 'generic' array data type is *not* supported. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( buf, 0, 4, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0, 1.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index bb876ed..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,606 +0,0 @@ -/* -* @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. -*/ - -/// - -import { IterableIterator } from '@stdlib/types/iter'; -import filledarrayBy = require( './index' ); - - -/** -* Returns an iterator protocol-compliant object. -* -* @returns iterator protocol-compliant object -*/ -function iterator(): IterableIterator { - const obj: IterableIterator = { - [Symbol.iterator]: iterator, - 'next': next - }; - return obj; -} - -/** -* Implements the iterator protocol `next` method. -* -* @returns iterator protocol-compliant object -*/ -function next(): any { - return { - 'value': 1.0, - 'done': false - }; -} - -/** -* Callback function. -* -* @param i - current array index -* @returns return value -*/ -function clbk( i: number ): number { - return i; -} - - -// TESTS // - -// The function returns an array or typed array... -{ - filledarrayBy(); // $ExpectType ArrayOrTypedArray - filledarrayBy( 'float32' ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( 10, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( 10, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( 10, 'int32', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( 10, 'int32', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const x = new Float64Array( 10 ); - filledarrayBy( x, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( x, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( x, 'uint8', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( x, 'uint8', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const y = [ 2.0, 2.0, 2.0 ]; - filledarrayBy( y, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( y, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( y, 'float64', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( y, 'float64', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const it = iterator(); - filledarrayBy( it, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( it, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( it, 'uint8c', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( it, 'uint8c', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const buf = new ArrayBuffer( 32 ); - filledarrayBy( buf, clbk ); // $ExpectType RealOrComplexTypedArray | BooleanArray - filledarrayBy( buf, clbk, {} ); // $ExpectType RealOrComplexTypedArray | BooleanArray - - filledarrayBy( buf, 'uint32', clbk ); // $ExpectType RealOrComplexTypedArray | BooleanArray - filledarrayBy( buf, 'uint32', clbk, {} ); // $ExpectType RealOrComplexTypedArray | BooleanArray - - filledarrayBy( buf, 8, clbk ); // $ExpectType RealOrComplexTypedArray | BooleanArray - filledarrayBy( buf, 8, clbk, {} ); // $ExpectType RealOrComplexTypedArray | BooleanArray - - filledarrayBy( buf, 8, 'uint16', clbk ); // $ExpectType RealOrComplexTypedArray | BooleanArray - filledarrayBy( buf, 8, 'uint16', clbk, {} ); // $ExpectType RealOrComplexTypedArray | BooleanArray - - filledarrayBy( buf, 8, 2, clbk ); // $ExpectType RealOrComplexTypedArray | BooleanArray - filledarrayBy( buf, 8, 2, clbk, {} ); // $ExpectType RealOrComplexTypedArray | BooleanArray - - filledarrayBy( buf, 8, 2, 'int16', clbk ); // $ExpectType RealOrComplexTypedArray | BooleanArray - filledarrayBy( buf, 8, 2, 'int16', clbk, {} ); // $ExpectType RealOrComplexTypedArray | BooleanArray -} - -// The compiler throws an error if a callback function argument is not a function... -{ - filledarrayBy( 'float64', '5' ); // $ExpectError - filledarrayBy( 'float64', 1.0 ); // $ExpectError - filledarrayBy( 'float64', false ); // $ExpectError - filledarrayBy( 'float64', true ); // $ExpectError - filledarrayBy( 'float64', null ); // $ExpectError - filledarrayBy( 'float64', undefined ); // $ExpectError - filledarrayBy( 'float64', [] ); // $ExpectError - filledarrayBy( 'float64', {} ); // $ExpectError - - filledarrayBy( 'float64', '5', {} ); // $ExpectError - filledarrayBy( 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( 'float64', false, {} ); // $ExpectError - filledarrayBy( 'float64', true, {} ); // $ExpectError - filledarrayBy( 'float64', null, {} ); // $ExpectError - filledarrayBy( 'float64', undefined, {} ); // $ExpectError - filledarrayBy( 'float64', [], {} ); // $ExpectError - filledarrayBy( 'float64', {}, {} ); // $ExpectError - - filledarrayBy( 10, '5' ); // $ExpectError - filledarrayBy( 10, 1.0 ); // $ExpectError - filledarrayBy( 10, false ); // $ExpectError - filledarrayBy( 10, true ); // $ExpectError - filledarrayBy( 10, null ); // $ExpectError - filledarrayBy( 10, undefined ); // $ExpectError - filledarrayBy( 10, [] ); // $ExpectError - filledarrayBy( 10, {} ); // $ExpectError - - filledarrayBy( 10, '5', {} ); // $ExpectError - filledarrayBy( 10, 1.0, {} ); // $ExpectError - filledarrayBy( 10, false, {} ); // $ExpectError - filledarrayBy( 10, true, {} ); // $ExpectError - filledarrayBy( 10, null, {} ); // $ExpectError - filledarrayBy( 10, undefined, {} ); // $ExpectError - filledarrayBy( 10, [], {} ); // $ExpectError - filledarrayBy( 10, {}, {} ); // $ExpectError - - filledarrayBy( 10, 'float64', '5' ); // $ExpectError - filledarrayBy( 10, 'float64', 1.0 ); // $ExpectError - filledarrayBy( 10, 'float64', false ); // $ExpectError - filledarrayBy( 10, 'float64', true ); // $ExpectError - filledarrayBy( 10, 'float64', null ); // $ExpectError - filledarrayBy( 10, 'float64', undefined ); // $ExpectError - filledarrayBy( 10, 'float64', [] ); // $ExpectError - filledarrayBy( 10, 'float64', {} ); // $ExpectError - - filledarrayBy( 10, 'float64', '5', {} ); // $ExpectError - filledarrayBy( 10, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( 10, 'float64', false, {} ); // $ExpectError - filledarrayBy( 10, 'float64', true, {} ); // $ExpectError - filledarrayBy( 10, 'float64', null, {} ); // $ExpectError - filledarrayBy( 10, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( 10, 'float64', [], {} ); // $ExpectError - filledarrayBy( 10, 'float64', {}, {} ); // $ExpectError - - const x = new Float64Array( 10 ); - filledarrayBy( x, '5' ); // $ExpectError - filledarrayBy( x, 1.0 ); // $ExpectError - filledarrayBy( x, false ); // $ExpectError - filledarrayBy( x, true ); // $ExpectError - filledarrayBy( x, null ); // $ExpectError - filledarrayBy( x, undefined ); // $ExpectError - filledarrayBy( x, [] ); // $ExpectError - filledarrayBy( x, {} ); // $ExpectError - - filledarrayBy( x, '5', {} ); // $ExpectError - filledarrayBy( x, 1.0, {} ); // $ExpectError - filledarrayBy( x, false, {} ); // $ExpectError - filledarrayBy( x, true, {} ); // $ExpectError - filledarrayBy( x, null, {} ); // $ExpectError - filledarrayBy( x, undefined, {} ); // $ExpectError - filledarrayBy( x, [], {} ); // $ExpectError - filledarrayBy( x, {}, {} ); // $ExpectError - - filledarrayBy( x, 'float64', '5' ); // $ExpectError - filledarrayBy( x, 'float64', 1.0 ); // $ExpectError - filledarrayBy( x, 'float64', false ); // $ExpectError - filledarrayBy( x, 'float64', true ); // $ExpectError - filledarrayBy( x, 'float64', null ); // $ExpectError - filledarrayBy( x, 'float64', undefined ); // $ExpectError - filledarrayBy( x, 'float64', [] ); // $ExpectError - filledarrayBy( x, 'float64', {} ); // $ExpectError - - filledarrayBy( x, 'float64', '5', {} ); // $ExpectError - filledarrayBy( x, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( x, 'float64', false, {} ); // $ExpectError - filledarrayBy( x, 'float64', true, {} ); // $ExpectError - filledarrayBy( x, 'float64', null, {} ); // $ExpectError - filledarrayBy( x, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( x, 'float64', [], {} ); // $ExpectError - filledarrayBy( x, 'float64', {}, {} ); // $ExpectError - - const y = [ 2.0, 2.0, 2.0 ]; - filledarrayBy( y, '5' ); // $ExpectError - filledarrayBy( y, 1.0 ); // $ExpectError - filledarrayBy( y, false ); // $ExpectError - filledarrayBy( y, true ); // $ExpectError - filledarrayBy( y, null ); // $ExpectError - filledarrayBy( y, undefined ); // $ExpectError - filledarrayBy( y, [] ); // $ExpectError - filledarrayBy( y, {} ); // $ExpectError - - filledarrayBy( y, '5', {} ); // $ExpectError - filledarrayBy( y, 1.0, {} ); // $ExpectError - filledarrayBy( y, false, {} ); // $ExpectError - filledarrayBy( y, true, {} ); // $ExpectError - filledarrayBy( y, null, {} ); // $ExpectError - filledarrayBy( y, undefined, {} ); // $ExpectError - filledarrayBy( y, [], {} ); // $ExpectError - filledarrayBy( y, {}, {} ); // $ExpectError - - filledarrayBy( y, 'float64', '5' ); // $ExpectError - filledarrayBy( y, 'float64', 1.0 ); // $ExpectError - filledarrayBy( y, 'float64', false ); // $ExpectError - filledarrayBy( y, 'float64', true ); // $ExpectError - filledarrayBy( y, 'float64', null ); // $ExpectError - filledarrayBy( y, 'float64', undefined ); // $ExpectError - filledarrayBy( y, 'float64', [] ); // $ExpectError - filledarrayBy( y, 'float64', {} ); // $ExpectError - - filledarrayBy( y, 'float64', '5', {} ); // $ExpectError - filledarrayBy( y, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( y, 'float64', false, {} ); // $ExpectError - filledarrayBy( y, 'float64', true, {} ); // $ExpectError - filledarrayBy( y, 'float64', null, {} ); // $ExpectError - filledarrayBy( y, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( y, 'float64', [], {} ); // $ExpectError - filledarrayBy( y, 'float64', {}, {} ); // $ExpectError - - const it = iterator(); - filledarrayBy( it, '5' ); // $ExpectError - filledarrayBy( it, 1.0 ); // $ExpectError - filledarrayBy( it, false ); // $ExpectError - filledarrayBy( it, true ); // $ExpectError - filledarrayBy( it, null ); // $ExpectError - filledarrayBy( it, undefined ); // $ExpectError - filledarrayBy( it, [] ); // $ExpectError - filledarrayBy( it, {} ); // $ExpectError - - filledarrayBy( it, '5', {} ); // $ExpectError - filledarrayBy( it, 1.0, {} ); // $ExpectError - filledarrayBy( it, false, {} ); // $ExpectError - filledarrayBy( it, true, {} ); // $ExpectError - filledarrayBy( it, null, {} ); // $ExpectError - filledarrayBy( it, undefined, {} ); // $ExpectError - filledarrayBy( it, [], {} ); // $ExpectError - filledarrayBy( it, {}, {} ); // $ExpectError - - filledarrayBy( it, 'float64', '5' ); // $ExpectError - filledarrayBy( it, 'float64', 1.0 ); // $ExpectError - filledarrayBy( it, 'float64', false ); // $ExpectError - filledarrayBy( it, 'float64', true ); // $ExpectError - filledarrayBy( it, 'float64', null ); // $ExpectError - filledarrayBy( it, 'float64', undefined ); // $ExpectError - filledarrayBy( it, 'float64', [] ); // $ExpectError - filledarrayBy( it, 'float64', {} ); // $ExpectError - - filledarrayBy( it, 'float64', '5', {} ); // $ExpectError - filledarrayBy( it, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( it, 'float64', false, {} ); // $ExpectError - filledarrayBy( it, 'float64', true, {} ); // $ExpectError - filledarrayBy( it, 'float64', null, {} ); // $ExpectError - filledarrayBy( it, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( it, 'float64', [], {} ); // $ExpectError - filledarrayBy( it, 'float64', {}, {} ); // $ExpectError - - const buf = new ArrayBuffer( 32 ); - filledarrayBy( buf, '5' ); // $ExpectError - filledarrayBy( buf, 1.0 ); // $ExpectError - filledarrayBy( buf, false ); // $ExpectError - filledarrayBy( buf, true ); // $ExpectError - filledarrayBy( buf, null ); // $ExpectError - filledarrayBy( buf, undefined ); // $ExpectError - filledarrayBy( buf, [] ); // $ExpectError - filledarrayBy( buf, {} ); // $ExpectError - - filledarrayBy( buf, '5', {} ); // $ExpectError - filledarrayBy( buf, 1.0, {} ); // $ExpectError - filledarrayBy( buf, false, {} ); // $ExpectError - filledarrayBy( buf, true, {} ); // $ExpectError - filledarrayBy( buf, null, {} ); // $ExpectError - filledarrayBy( buf, undefined, {} ); // $ExpectError - filledarrayBy( buf, [], {} ); // $ExpectError - filledarrayBy( buf, {}, {} ); // $ExpectError - - filledarrayBy( buf, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 'float64', false ); // $ExpectError - filledarrayBy( buf, 'float64', true ); // $ExpectError - filledarrayBy( buf, 'float64', null ); // $ExpectError - filledarrayBy( buf, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 'float64', {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5' ); // $ExpectError - filledarrayBy( buf, 8, 1.0 ); // $ExpectError - filledarrayBy( buf, 8, false ); // $ExpectError - filledarrayBy( buf, 8, true ); // $ExpectError - filledarrayBy( buf, 8, null ); // $ExpectError - filledarrayBy( buf, 8, undefined ); // $ExpectError - filledarrayBy( buf, 8, [] ); // $ExpectError - filledarrayBy( buf, 8, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, false, {} ); // $ExpectError - filledarrayBy( buf, 8, true, {} ); // $ExpectError - filledarrayBy( buf, 8, null, {} ); // $ExpectError - filledarrayBy( buf, 8, undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, [], {} ); // $ExpectError - filledarrayBy( buf, 8, {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 8, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 'float64', false ); // $ExpectError - filledarrayBy( buf, 8, 'float64', true ); // $ExpectError - filledarrayBy( buf, 8, 'float64', null ); // $ExpectError - filledarrayBy( buf, 8, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 8, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 8, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 8, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, '5' ); // $ExpectError - filledarrayBy( buf, 8, 2, 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 2, false ); // $ExpectError - filledarrayBy( buf, 8, 2, true ); // $ExpectError - filledarrayBy( buf, 8, 2, null ); // $ExpectError - filledarrayBy( buf, 8, 2, undefined ); // $ExpectError - filledarrayBy( buf, 8, 2, [] ); // $ExpectError - filledarrayBy( buf, 8, 2, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, false, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, true, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, null, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, [], {} ); // $ExpectError - filledarrayBy( buf, 8, 2, {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', false ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', true ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', null ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', {}, {} ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid length, typed array, array-like object, `ArrayBuffer`, or iterable argument... -{ - filledarrayBy( false, clbk ); // $ExpectError - filledarrayBy( true, clbk ); // $ExpectError - filledarrayBy( null, clbk ); // $ExpectError - filledarrayBy( {}, clbk ); // $ExpectError - - filledarrayBy( false, clbk, {} ); // $ExpectError - filledarrayBy( true, clbk, {} ); // $ExpectError - filledarrayBy( null, clbk, {} ); // $ExpectError - filledarrayBy( {}, clbk, {} ); // $ExpectError - - filledarrayBy( false, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 'float64', clbk ); // $ExpectError - - filledarrayBy( false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, clbk ); // $ExpectError - filledarrayBy( 1.0, 8, clbk ); // $ExpectError - filledarrayBy( false, 8, clbk ); // $ExpectError - filledarrayBy( true, 8, clbk ); // $ExpectError - filledarrayBy( null, 8, clbk ); // $ExpectError - filledarrayBy( undefined, 8, clbk ); // $ExpectError - filledarrayBy( [], 8, clbk ); // $ExpectError - filledarrayBy( {}, 8, clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, clbk ); // $ExpectError - - filledarrayBy( '5', 8, clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, clbk, {} ); // $ExpectError - filledarrayBy( false, 8, clbk, {} ); // $ExpectError - filledarrayBy( true, 8, clbk, {} ); // $ExpectError - filledarrayBy( null, 8, clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, clbk, {} ); // $ExpectError - filledarrayBy( [], 8, clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 'float64', clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( false, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( [], 8, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 'float64', clbk ); // $ExpectError - - filledarrayBy( '5', 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 2, clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 2, clbk ); // $ExpectError - filledarrayBy( false, 8, 2, clbk ); // $ExpectError - filledarrayBy( true, 8, 2, clbk ); // $ExpectError - filledarrayBy( null, 8, 2, clbk ); // $ExpectError - filledarrayBy( undefined, 8, 2, clbk ); // $ExpectError - filledarrayBy( [], 8, 2, clbk ); // $ExpectError - filledarrayBy( {}, 8, 2, clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, clbk ); // $ExpectError - - filledarrayBy( '5', 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( false, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( [], 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, 'float64', clbk ); // $ExpectError - - filledarrayBy( '5', 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a byte offset argument which is not a number... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, false, clbk ); // $ExpectError - filledarrayBy( buf, true, clbk ); // $ExpectError - filledarrayBy( buf, null, clbk ); // $ExpectError - filledarrayBy( buf, [], clbk ); // $ExpectError - filledarrayBy( buf, {}, clbk ); // $ExpectError - - filledarrayBy( buf, false, clbk, {} ); // $ExpectError - filledarrayBy( buf, true, clbk, {} ); // $ExpectError - filledarrayBy( buf, null, clbk, {} ); // $ExpectError - filledarrayBy( buf, [], clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, clbk, {} ); // $ExpectError - - filledarrayBy( buf, '5', 'float64', clbk ); // $ExpectError - filledarrayBy( buf, false, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, true, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, null, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, [], 'float64', clbk ); // $ExpectError - filledarrayBy( buf, {}, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, '5', 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( buf, false, 2, clbk ); // $ExpectError - filledarrayBy( buf, true, 2, clbk ); // $ExpectError - filledarrayBy( buf, null, 2, clbk ); // $ExpectError - filledarrayBy( buf, [], 2, clbk ); // $ExpectError - filledarrayBy( buf, {}, 2, clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, clbk ); // $ExpectError - - filledarrayBy( buf, false, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, clbk, {} ); // $ExpectError - - filledarrayBy( buf, '5', 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, false, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, true, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, null, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, undefined, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, [], 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, {}, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, '5', 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, false, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, undefined, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a view length argument which is not a number... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, 8, false, clbk ); // $ExpectError - filledarrayBy( buf, 8, true, clbk ); // $ExpectError - filledarrayBy( buf, 8, null, clbk ); // $ExpectError - filledarrayBy( buf, 8, [], clbk ); // $ExpectError - filledarrayBy( buf, 8, {}, clbk ); // $ExpectError - - filledarrayBy( buf, 8, false, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, true, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, null, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, [], clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, {}, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, clbk, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5', 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, false, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, true, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, null, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, [], 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, {}, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, 8, '5', 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, [], 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, {}, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided too many arguments... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, 8, 2, 'float64', 1, clbk, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 997a381..0000000 --- a/examples/index.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ).factory; -var dtypes = require( '@stdlib/array-typed-real-dtypes' ); -var filledarrayBy = require( './../lib' ); - -// Create a pseudorandom number generator: -var rand = discreteUniform( 0, 100 ); - -// Get a list of array data types: -var dt = dtypes(); - -// Generate filled arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = filledarrayBy( 10, dt[ i ], rand ); - console.log( arr ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 764e40e..cb63cd1 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, RealOrComplexTypedArray, BooleanArray, DataType } from '@stdlib/types/array'; import { IterableIterator } from '@stdlib/types/iter'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..6f157fa --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.3-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.3-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@v0.0.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.3-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.3-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.3-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-ctors@v0.3.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill-by@v0.2.3-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled-by@v0.2.3-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.2.3-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.3-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@v0.2.3-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.4.1-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";var v=f(),g=j.get("dtypes.default");function c(){var f,j,c,b,y,x,u,E;if(0===(j=arguments.length))return new(y=d(g))(0);if(r(c=arguments[0])){if(j>1)throw new TypeError(w("00h05"));if(null===(y=d(c)))throw new TypeError(w("00h2Y",c));return new y(0)}if(j<2)throw new TypeError(w("00h05"));if(h(arguments[j-=1]))if(h(arguments[j-1])){if(f=arguments[j],b=arguments[j-=1],0===j)throw new TypeError(w("00h05"))}else b=arguments[j];else{if(!(j>=2))throw new TypeError(w("00h05"));if(f=arguments[j],!h(b=arguments[j-=1]))throw new TypeError(w("00h2b",b))}if((j-=1)>=0&&r(arguments[j])?(c=arguments[j],j-=1):c=g,null===(y=d(c)))throw new TypeError(w("00h2Y",c));if("generic"===c){if(E=arguments[0],0===j){if(e(E)?u=E:i(E)&&(u=E.length),void 0!==u)return m(u,b,f);if(n(E))throw new Error(w("00h04"));if(o(E)){if(!1===v)throw new TypeError(w("00h2Z",E));if(!h(E[p]))throw new TypeError(w("00h2a",E));if(E=E[p](),!h(E.next))throw new TypeError(w("00h2a",E));return function(r,e,t){var s,i;for(s=[],i=-1;!r.next().done;)i+=1,s.push(e.call(t,i));return s}(E,b,f)}throw new TypeError(w("00h2a",E))}if(n(E))throw new Error(w("00h04"));throw new TypeError(w("00h2a",E))}if(0===j)if(i(E=arguments[0]))x=new y(E.length);else if(n(E))x=new y(E);else if(e(E))x=new y(E);else{if(!o(E))throw new TypeError(w("00h2a",E));if(!1===v)throw new TypeError(w("00h2Z",E));if(!h(E[p]))throw new TypeError(w("00h2a",E));if(E=E[p](),!h(E.next))throw new TypeError(w("00h2a",E));x=new y(a(E))}else x=1===j?new y(arguments[0],arguments[1]):new y(arguments[0],arguments[1],arguments[2]);return x.length>0&&(t(c)||s(c)?function(r,e,t){var s;for(s=0;s\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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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( format('00h05') );\n\t\t}\n\t\tctor = ctors( dtype );\n\t\tif ( ctor === null ) {\n\t\t\tthrow new TypeError( format( '00h2Y', 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( format('00h05') );\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( format('00h05') );\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( '00h2b', clbk ) );\n\t\t}\n\t}\n\t// If we 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( format('00h05') );\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( '00h2Y', 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( format('00h04') );\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( '00h2Z', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00h2a', 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( '00h2a', 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( '00h2a', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format('00h04') );\n\t\t}\n\t\tthrow new TypeError( format( '00h2a', 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( '00h2Z', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00h2a', 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( '00h2a', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00h2a', 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\nexport default filledarrayBy;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","DEFAULT_DTYPE","defaults","get","filledarrayBy","thisArg","nargs","dtype","clbk","ctor","arr","len","arg","arguments","length","ctors","isString","TypeError","format","isFunction","isNonNegativeInteger","isCollection","filledArray","isArrayBuffer","Error","isObject","ITERATOR_SYMBOL","next","it","i","done","push","call","filledArrayIterator","iterLength","isComplexDataType","isBooleanDataType","set","filledAccessors","gfillBy","value","aidx"],"mappings":";;sjDA0CA,IAAIA,EAAsBC,IACtBC,EAAgBC,EAASC,IAAK,kBA2MlC,SAASC,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAKJ,GAAe,KAHfN,EAAQO,UAAUC,QAKjB,OAAO,IADPL,EAAOM,EAAOd,IACG,GAIlB,GAAKe,EADLT,EAAQM,UAAW,IACM,CAExB,GAAKP,EAAQ,EACZ,MAAM,IAAIW,UAAWC,EAAO,UAG7B,GAAc,QADdT,EAAOM,EAAOR,IAEb,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,OAAO,IAAIE,EAAM,EACjB,CAED,GAAKH,EAAQ,EACZ,MAAM,IAAIW,UAAWC,EAAO,UAM7B,GAAKC,EAAYN,UAHjBP,GAAS,IAKR,GAAKa,EAAYN,UAAWP,EAAM,KAMjC,GALAD,EAAUQ,UAAWP,GAErBE,EAAOK,UADPP,GAAS,GAIM,IAAVA,EACJ,MAAM,IAAIW,UAAWC,EAAO,eAI7BV,EAAOK,UAAWP,OAIf,MAAKA,GAAS,GAUlB,MAAM,IAAIW,UAAWC,EAAO,UAN5B,GAHAb,EAAUQ,UAAWP,IAGfa,EADNX,EAAOK,UADPP,GAAS,IAGR,MAAM,IAAIW,UAAWC,EAAQ,QAASV,GAMvC,CAUD,IARAF,GAAS,IACK,GAAKU,EAAUH,UAAWP,KACvCC,EAAQM,UAAWP,GACnBA,GAAS,GAETC,EAAQN,EAGK,QADdQ,EAAOM,EAAOR,IAEb,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,GAAe,YAAVA,EAAsB,CAE1B,GADAK,EAAMC,UAAW,GACF,IAAVP,EAAc,CAMlB,GALKc,EAAsBR,GAC1BD,EAAMC,EACKS,EAAcT,KACzBD,EAAMC,EAAIE,aAEE,IAARH,EACJ,OAAOW,EAAaX,EAAKH,EAAMH,GAEhC,GAAKkB,EAAeX,GACnB,MAAM,IAAIY,MAAON,EAAO,UAEzB,GAAKO,EAAUb,GAAQ,CACtB,IAA6B,IAAxBb,EACJ,MAAM,IAAIkB,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAYP,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLP,EAAYP,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvC,OAvSJ,SAA8BgB,EAAIpB,EAAMH,GACvC,IAAIK,EACAmB,EAKJ,IAFAnB,EAAM,GACNmB,GAAK,GAEAD,EAAGD,OACAG,MAGPD,GAAK,EACLnB,EAAIqB,KAAMvB,EAAKwB,KAAM3B,EAASwB,IAE/B,OAAOnB,CACR,CAuRWuB,CAAqBrB,EAAKJ,EAAMH,EACvC,CACD,MAAM,IAAIY,UAAWC,EAAQ,QAASN,GACzC,CAAS,GAAKW,EAAeX,GAC1B,MAAM,IAAIY,MAAON,EAAO,UAEzB,MAAM,IAAID,UAAWC,EAAQ,QAASN,GACtC,CACD,GAAe,IAAVN,EAEJ,GAAKe,EADLT,EAAMC,UAAW,IAEhBH,EAAM,IAAID,EAAMG,EAAIE,aACd,GAAKS,EAAeX,GAC1BF,EAAM,IAAID,EAAMG,QACV,GAAKQ,EAAsBR,GACjCF,EAAM,IAAID,EAAMG,OACV,KAAKa,EAAUb,GAarB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAZtC,IAA6B,IAAxBb,EACJ,MAAM,IAAIkB,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAYP,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLP,EAAYP,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvCF,EAAM,IAAID,EAAMyB,EAAYtB,GAG5B,MAEDF,EADqB,IAAVJ,EACL,IAAIG,EAAMI,UAAU,GAAIA,UAAU,IAElC,IAAIJ,EAAMI,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKH,EAAII,OAAS,IACZqB,EAAmB5B,IAAW6B,EAAmB7B,GAjTxD,SAA0BG,EAAKF,EAAMH,GACpC,IAAIwB,EACJ,IAAMA,EAAI,EAAGA,EAAInB,EAAII,OAAQe,IAC5BnB,EAAI2B,IAAK7B,EAAKwB,KAAM3B,EAASwB,GAAKA,EAGpC,CA4SGS,CAAiB5B,EAAKF,EAAMH,GAE5BkC,EAAS7B,EAAII,OAAQJ,EAAK,GAe5B,SAAmB8B,EAAOC,GACzB,OAAOjC,EAAKwB,KAAM3B,EAASoC,EAC3B,KAdM/B,CAeR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d115cf0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,192 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -/** -* Create a filled array according to a provided callback function. -* -* @module @stdlib/array-filled-by -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* var arr = filledarrayBy(); -* // returns -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'generic', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( [ 0.5, 0.5 ], clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1; -* } -* -* var arr = filledarrayBy( [ 5, -3 ], 'int32', clbk ); -* // returns [ 1, 1 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk1() { -* return 10; -* } -* -* function clbk2() { -* return 1.0; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, clbk2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk1() { -* return 1.0; -* } -* -* function clbk2() { -* return 2; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, 'uint32', clbk2 ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 'float32', clbk ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, clbk ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, 'int32', clbk ); -* // returns [ 1, 1 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 32b6545..0000000 --- a/lib/main.js +++ /dev/null @@ -1,416 +0,0 @@ -/** -* @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 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' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var ctors = require( '@stdlib/array-ctors' ); -var gfillBy = require( '@stdlib/blas-ext-base-gfill-by' ); -var filledArray = require( '@stdlib/array-base-filled-by' ); -var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var iterLength = require( '@stdlib/iter-length' ); -var defaults = require( '@stdlib/array-defaults' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport(); -var DEFAULT_DTYPE = defaults.get( 'dtypes.default' ); - - -// FUNCTIONS // - -/** -* Creates a filled "generic" array from an iterator. -* -* @private -* @param {Iterable} it - iterator -* @param {Callback} clbk - callback function -* @param {*} thisArg - callback function execution context -* @returns {Array} filled array -*/ -function filledArrayIterator( it, clbk, thisArg ) { - var arr; - var i; - var v; - - arr = []; - i = -1; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - i += 1; - arr.push( clbk.call( thisArg, i ) ); - } - return arr; -} - -/** -* Fills an array exposing accessors for getting and setting array elements. -* -* @private -* @param {Collection} arr - input array -* @param {Callback} clbk - callback function -* @param {*} thisArg - callback function execution context -* @returns {Collection} input array -*/ -function filledAccessors( arr, clbk, thisArg ) { - var i; - for ( i = 0; i < arr.length; i++ ) { - arr.set( clbk.call( thisArg, i ), i ); - } - return arr; -} - - -// MAIN // - -/** -* Creates a filled array according to a provided callback function. -* -* @param {(NonNegativeInteger|TypedArray|ArrayLikeObject|ArrayBuffer|Iterable)} [arg] - a length, typed array, array-like object, buffer, or iterable -* @param {NonNegativeInteger} [byteOffset=0] - byte offset -* @param {NonNegativeInteger} [length] - view length -* @param {string} [dtype="float64"] - data type -* @param {Callback} [clbk] - callback to invoke -* @param {*} [thisArg] - callback execution context -* @throws {TypeError} must provide a recognized data type -* @throws {TypeError} must provide a length, typed array, array-like object, buffer, or iterable -* @throws {TypeError} callback argument must be a function. -* @throws {Error} creating a generic array from an `ArrayBuffer` is not supported -* @returns {(TypedArray|Array)} array or typed array -* -* @example -* var arr = filledarrayBy(); -* // returns -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'generic', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( [ 0.5, 0.5 ], clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1; -* } -* -* var arr = filledarrayBy( [ 5, -3 ], 'int32', clbk ); -* // returns [ 1, 1 ] -* -* @example -* function clbk1() { -* return 10; -* } -* -* function clbk2() { -* return 1.0; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, clbk2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk1() { -* return 1.0; -* } -* -* function clbk2() { -* return 2; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, 'uint32', clbk2 ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 'float32', clbk ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, clbk ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, 'int32', clbk ); -* // returns [ 1, 1 ] -*/ -function filledarrayBy() { - var thisArg; - var nargs; - var dtype; - var clbk; - var ctor; - var arr; - var len; - var arg; - - nargs = arguments.length; - - // If we weren't provided any arguments, return an empty array... - if ( nargs === 0 ) { - ctor = ctors( DEFAULT_DTYPE ); - return new ctor( 0 ); - } - // Check if we were provided a dtype as the first argument... - dtype = arguments[ 0 ]; - if ( isString( dtype ) ) { - // Invoking this function with arguments `f( dtype, clbk[, thisArg] )` is not allowed (otherwise, we'd need to also allow `f( clbk[, thisArg] )`)... - if ( nargs > 1 ) { - throw new TypeError( format('00h05') ); - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '00h2Y', dtype ) ); - } - // Return an empty array having the specified dtype: - return new ctor( 0 ); - } - // For all other supported invocations, we need at least two arguments... - if ( nargs < 2 ) { - throw new TypeError( format('00h05') ); - } - // At this point, we need to do some argument juggling... - nargs -= 1; // henceforth, the number of available arguments is `nargs+1` - - // Determine whether the last argument is a callback or "this" context... - if ( isFunction( arguments[ nargs ] ) ) { - // 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... - if ( isFunction( arguments[ nargs-1 ] ) ) { - thisArg = arguments[ nargs ]; - nargs -= 1; - clbk = arguments[ nargs ]; - - // Check if we were provided only a callback and a "this" context.. - if ( nargs === 0 ) { - throw new TypeError( format('00h05') ); - } - } else { - // "this" context is left undefined... - clbk = arguments[ nargs ]; - } - } - // 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... - else if ( nargs >= 2 ) { - thisArg = arguments[ nargs ]; - nargs -= 1; - clbk = arguments[ nargs ]; - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '00h2b', clbk ) ); - } - } - // If we were only provided 2 arguments and the last argument was not a function, we've been provided an insufficient number of arguments... - else { - throw new TypeError( format('00h05') ); - } - // Now that we've processed the callback arguments, let's continue working backward to see if we've been provided a `dtype` argument... - nargs -= 1; - if ( nargs >= 0 && isString( arguments[ nargs ] ) ) { - dtype = arguments[ nargs ]; - nargs -= 1; - } else { - dtype = DEFAULT_DTYPE; - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '00h2Y', dtype ) ); - } - // At this point, we've resolved the output array data type, and now we can actually create the output array... - if ( dtype === 'generic' ) { - arg = arguments[ 0 ]; - if ( nargs === 0 ) { - if ( isNonNegativeInteger( arg ) ) { - len = arg; - } else if ( isCollection( arg ) ) { - len = arg.length; - } - if ( len !== void 0 ) { - return filledArray( len, clbk, thisArg ); - } - if ( isArrayBuffer( arg ) ) { - throw new Error( format('00h04') ); - } - if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( '00h2Z', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00h2a', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00h2a', arg ) ); - } - return filledArrayIterator( arg, clbk, thisArg ); - } - throw new TypeError( format( '00h2a', arg ) ); - } else if ( isArrayBuffer( arg ) ) { - throw new Error( format('00h04') ); - } - throw new TypeError( format( '00h2a', arg ) ); - } - if ( nargs === 0 ) { // length || array-like || ArrayBuffer || iterable - arg = arguments[ 0 ]; - if ( isCollection( arg ) ) { - arr = new ctor( arg.length ); - } else if ( isArrayBuffer( arg ) ) { - arr = new ctor( arg ); - } else if ( isNonNegativeInteger( arg ) ) { - arr = new ctor( arg ); - } else if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( '00h2Z', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00h2a', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00h2a', arg ) ); - } - arr = new ctor( iterLength( arg ) ); - } else { - throw new TypeError( format( '00h2a', arg ) ); - } - } else if ( nargs === 1 ) { - arr = new ctor( arguments[0], arguments[1] ); // (ArrayBuffer, byteOffset) - } else { - arr = new ctor( arguments[0], arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset, length) - } - if ( arr.length > 0 ) { - if ( isComplexDataType( dtype ) || isBooleanDataType( dtype ) ) { - filledAccessors( arr, clbk, thisArg ); - } else { - gfillBy( arr.length, arr, 1, callback ); - } - } - return arr; - - /** - * Callback which wraps a provided callback and is invoked for each array element. - * - * @private - * @param {*} value - element value - * @param {NonNegativeInteger} aidx - array index - * @param {NonNegativeInteger} sidx - strided index - * @param {Collection} array - input array/collection - * @returns {*} callback return value - */ - function callback( value, aidx ) { - return clbk.call( thisArg, aidx ); - } -} - - -// EXPORTS // - -module.exports = filledarrayBy; diff --git a/package.json b/package.json index ecbe58e..026d062 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.3.1", "description": "Create a filled array according to a provided callback function.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,75 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-assert-is-boolean-data-type": "^0.0.2", - "@stdlib/array-base-assert-is-complex-floating-point-data-type": "^0.2.2", - "@stdlib/array-base-filled-by": "^0.2.3", - "@stdlib/array-ctors": "^0.3.1", - "@stdlib/array-defaults": "^0.4.1", - "@stdlib/assert-has-iterator-symbol-support": "^0.2.3", - "@stdlib/assert-is-arraybuffer": "^0.2.3", - "@stdlib/assert-is-collection": "^0.2.3", - "@stdlib/assert-is-function": "^0.2.3", - "@stdlib/assert-is-nonnegative-integer": "^0.2.3", - "@stdlib/assert-is-object": "^0.2.3", - "@stdlib/assert-is-string": "^0.2.3", - "@stdlib/blas-ext-base-gfill-by": "^0.2.3", - "@stdlib/iter-length": "^0.2.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3", - "@stdlib/symbol-iterator": "^0.2.3", - "@stdlib/types": "^0.4.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3" - }, - "devDependencies": { - "@stdlib/array-bool": "^0.1.2", - "@stdlib/array-buffer": "^0.2.3", - "@stdlib/array-complex128": "^0.3.2", - "@stdlib/array-complex64": "^0.3.2", - "@stdlib/array-float32": "^0.2.3", - "@stdlib/array-float64": "^0.2.3", - "@stdlib/array-int16": "^0.2.3", - "@stdlib/array-int32": "^0.2.3", - "@stdlib/array-int8": "^0.2.3", - "@stdlib/array-typed-real-dtypes": "^0.2.3", - "@stdlib/array-uint16": "^0.2.3", - "@stdlib/array-uint32": "^0.2.3", - "@stdlib/array-uint8": "^0.2.3", - "@stdlib/array-uint8c": "^0.2.3", - "@stdlib/assert-instance-of": "^0.3.1", - "@stdlib/assert-is-array": "^0.2.3", - "@stdlib/assert-is-typed-array": "^0.2.3", - "@stdlib/assert-is-typed-array-like": "^0.2.3", - "@stdlib/complex-float32-ctor": "^0.1.1", - "@stdlib/complex-float64-ctor": "^0.1.2", - "@stdlib/iter-constant": "^0.2.3", - "@stdlib/math-base-special-pow": "^0.3.1", - "@stdlib/random-base-discrete-uniform": "^0.2.2", - "@stdlib/strided-base-reinterpret-boolean": "^0.0.3", - "@stdlib/strided-base-reinterpret-complex128": "^0.2.3", - "@stdlib/strided-base-reinterpret-complex64": "^0.2.2", - "@stdlib/utils-constant-function": "^0.2.3", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.3" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..dabf69c --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index ca0cf25..0000000 --- a/test/test.js +++ /dev/null @@ -1,4397 +0,0 @@ -/** -* @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. -*/ - -/* eslint-disable max-len */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -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' ); -var iterConstant = require( '@stdlib/iter-constant' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var filledarrayBy = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': !hasIteratorSymbolSupport() -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof filledarrayBy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if only provided callback arguments', function test( t ) { - t.throws( clbk1, TypeError, 'throws an error' ); - t.throws( clbk2, TypeError, 'throws an error' ); - t.throws( clbk3, TypeError, 'throws an error' ); - t.end(); - - function clbk1() { - filledarrayBy( constantFunction( 1.0 ) ); - } - - function clbk2() { - filledarrayBy( constantFunction( 1.0 ), {} ); - } - - function clbk3() { - filledarrayBy( constantFunction( 1.0 ), constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (only argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (typed array; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (array-like object)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (array-like object; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 8 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 8 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, 1, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (iterator)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( iterConstant( 1.0 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (iterator; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( iterConstant( 1.0 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if only provided data type and callback arguments', function test( t ) { - t.throws( clbk1, TypeError, 'throws an error' ); - t.throws( clbk2, TypeError, 'throws an error' ); - t.throws( clbk3, TypeError, 'throws an error' ); - t.end(); - - function clbk1() { - filledarrayBy( 'float64', constantFunction( 1.0 ) ); - } - - function clbk2() { - filledarrayBy( 'float64', constantFunction( 1.0 ), {} ); - } - - function clbk3() { - filledarrayBy( 'float64', constantFunction( 1.0 ), constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (array-like object)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (array-like object; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, 1, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, 1, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (no iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (no iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (non-function iterator symbol property)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (non-function iterator symbol property; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (`next` property is not a function)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ) ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (`next` property is not a function; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ), {} ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (no iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (no iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (non-function iterator symbol property)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (non-function iterator symbol property; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (`next` property is not a function)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ) ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (`next` property is not a function; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ), {} ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 1, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 1, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function returns a filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - arr = filledarrayBy(); - - t.strictEqual( instanceOf( arr, Float64Array ), 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=float64)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - arr = filledarrayBy( 'float64' ); - - t.strictEqual( instanceOf( arr, Float64Array ), 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=float32)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( 0 ); - arr = filledarrayBy( 'float32' ); - - t.strictEqual( instanceOf( arr, Float32Array ), 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=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; - - expected = new Complex128Array( 0 ); - arr = filledarrayBy( 'complex128' ); - - t.strictEqual( instanceOf( arr, Complex128Array ), 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=complex64)', function test( t ) { - var expected; - var arr; - - expected = new Complex64Array( 0 ); - arr = filledarrayBy( 'complex64' ); - - t.strictEqual( instanceOf( arr, Complex64Array ), 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=int32)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( 0 ); - arr = filledarrayBy( 'int32' ); - - t.strictEqual( instanceOf( arr, Int32Array ), 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=uint32)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( 0 ); - arr = filledarrayBy( 'uint32' ); - - t.strictEqual( instanceOf( arr, Uint32Array ), 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=int16)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( 0 ); - arr = filledarrayBy( 'int16' ); - - t.strictEqual( instanceOf( arr, Int16Array ), 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=uint16)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( 0 ); - arr = filledarrayBy( 'uint16' ); - - t.strictEqual( instanceOf( arr, Uint16Array ), 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=int8)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( 0 ); - arr = filledarrayBy( 'int8' ); - - t.strictEqual( instanceOf( arr, Int8Array ), 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=uint8)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( 0 ); - arr = filledarrayBy( 'uint8' ); - - t.strictEqual( instanceOf( arr, Uint8Array ), 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=uint8c)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( 0 ); - arr = filledarrayBy( 'uint8c' ); - - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), 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=generic)', function test( t ) { - var expected; - var arr; - - expected = []; - arr = filledarrayBy( 'generic' ); - - t.strictEqual( instanceOf( arr, Array ), 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 (default, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, length=0)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array(); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 0, clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, clbk, ctx ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (default, length; thisArg=function)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, clbk, context ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this(); // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } - - function context() { - ctx.count += 1; - } -}); - -tape( 'the function returns a filled array (dtype=float64, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, 'float64', clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, length; thisArg=function)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, 'float64', clbk, context ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this(); // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } - - function context() { - ctx.count += 1; - } -}); - -tape( 'the function returns a filled array (dtype=float32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, 'float32', clbk ); - - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - 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; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = filledarrayBy( 5, 'complex128', clbk ); - - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = filledarrayBy( 5, 'complex64', clbk ); - - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int32Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int32', clbk ); - - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint32Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint32', clbk ); - - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int16Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int16', clbk ); - - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint16', clbk ); - - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int8Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int8', clbk ); - - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint8', clbk ); - - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint8c', clbk ); - - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = [ 1, 1, 1, 1, 1 ]; - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'generic', clbk ); - - t.strictEqual( instanceOf( arr, Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - 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; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = [ 1.0, 2.0 ]; - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = [ 1.0, 2.0 ]; - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int32', clbk ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, typed array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, typed array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - 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; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = new Float64Array( [ 1.0, 2.0 ] ); - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = new Float64Array( [ 1.0, 2.0 ] ); - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (default, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - 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; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer, byteoffset; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer, byteoffset; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - 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; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 48 ); - out = filledarrayBy( buf, 16, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 24 ); - out = filledarrayBy( buf, 8, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int32', clbk ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint8c', clbk ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - 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; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 64 ); - out = filledarrayBy( buf, 16, 2, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset, length)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 1, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 1, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled array (default, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, iterator; thisArg)', opts, function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - ctx = { - 'count': 0 - }; - indices = []; - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, iterator; thisArg)', opts, function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - ctx = { - 'count': 0 - }; - indices = []; - out = filledarrayBy( arr, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - 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; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = iterConstant( new Complex128( 3.0, 3.0 ), { - 'iter': 2 - }); - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = iterConstant( new Complex64( 3.0, 3.0 ), { - 'iter': 2 - }); - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); From 1c428e0c34b7112fa801879999b04d2ae7d4fdf7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 16 Jun 2026 20:43:46 +0000 Subject: [PATCH 109/117] Transform error messages --- lib/main.js | 38 +++++++++++++++++++------------------- package.json | 2 +- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/lib/main.js b/lib/main.js index d2128f5..32b6545 100644 --- a/lib/main.js +++ b/lib/main.js @@ -35,7 +35,7 @@ var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-supp var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); var iterLength = require( '@stdlib/iter-length' ); var defaults = require( '@stdlib/array-defaults' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -266,18 +266,18 @@ function filledarrayBy() { if ( isString( dtype ) ) { // Invoking this function with arguments `f( dtype, clbk[, thisArg] )` is not allowed (otherwise, we'd need to also allow `f( clbk[, thisArg] )`)... if ( nargs > 1 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format('00h05') ); } ctor = ctors( dtype ); if ( ctor === null ) { - throw new TypeError( format( 'invalid argument. Must provide a recognized data type. Value: `%s`.', dtype ) ); + throw new TypeError( format( '00h2Y', dtype ) ); } // Return an empty array having the specified dtype: return new ctor( 0 ); } // For all other supported invocations, we need at least two arguments... if ( nargs < 2 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format('00h05') ); } // At this point, we need to do some argument juggling... nargs -= 1; // henceforth, the number of available arguments is `nargs+1` @@ -292,7 +292,7 @@ function filledarrayBy() { // Check if we were provided only a callback and a "this" context.. if ( nargs === 0 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format('00h05') ); } } else { // "this" context is left undefined... @@ -305,12 +305,12 @@ function filledarrayBy() { nargs -= 1; clbk = arguments[ nargs ]; if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '00h2b', clbk ) ); } } // If we were only provided 2 arguments and the last argument was not a function, we've been provided an insufficient number of arguments... else { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format('00h05') ); } // Now that we've processed the callback arguments, let's continue working backward to see if we've been provided a `dtype` argument... nargs -= 1; @@ -322,7 +322,7 @@ function filledarrayBy() { } ctor = ctors( dtype ); if ( ctor === null ) { - throw new TypeError( format( 'invalid argument. Must provide a recognized data type. Value: `%s`.', dtype ) ); + throw new TypeError( format( '00h2Y', dtype ) ); } // At this point, we've resolved the output array data type, and now we can actually create the output array... if ( dtype === 'generic' ) { @@ -337,26 +337,26 @@ function filledarrayBy() { return filledArray( len, clbk, thisArg ); } if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format('00h04') ); } if ( isObject( arg ) ) { if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2Z', arg ) ); } if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } arg = arg[ ITERATOR_SYMBOL ](); if ( !isFunction( arg.next ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } return filledArrayIterator( arg, clbk, thisArg ); } - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } else if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format('00h04') ); } - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } if ( nargs === 0 ) { // length || array-like || ArrayBuffer || iterable arg = arguments[ 0 ]; @@ -368,18 +368,18 @@ function filledarrayBy() { arr = new ctor( arg ); } else if ( isObject( arg ) ) { if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2Z', arg ) ); } if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } arg = arg[ ITERATOR_SYMBOL ](); if ( !isFunction( arg.next ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } arr = new ctor( iterLength( arg ) ); } else { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } } else if ( nargs === 1 ) { arr = new ctor( arguments[0], arguments[1] ); // (ArrayBuffer, byteOffset) diff --git a/package.json b/package.json index b1d16c6..a1a5078 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "@stdlib/assert-is-string": "^0.2.3", "@stdlib/blas-ext-base-gfill-by": "^0.2.3", "@stdlib/iter-length": "^0.2.3", - "@stdlib/string-format": "^0.2.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.3", "@stdlib/symbol-iterator": "^0.2.3", "@stdlib/types": "^0.5.1", "@stdlib/error-tools-fmtprodmsg": "^0.2.3" From 94858046f95ff424bac4a8963029226a0514d338 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 16 Jun 2026 20:45:21 +0000 Subject: [PATCH 110/117] Remove files --- index.d.ts | 322 ---- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5169 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index cb63cd1..0000000 --- a/index.d.ts +++ /dev/null @@ -1,322 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, RealOrComplexTypedArray, BooleanArray, DataType } from '@stdlib/types/array'; -import { IterableIterator } from '@stdlib/types/iter'; - -/** -* Array or typed array. -*/ -type ArrayOrTypedArray = Array | RealOrComplexTypedArray | BooleanArray; - -/** -* Nullary callback function. -* -* @returns fill value -*/ -type Nullary = () => any; - -/** -* Unary callback function. -* -* @param i - current array index -* @returns fill value -*/ -type Unary = ( i: number ) => any; - -/** -* Callback function. -* -* @param i - current array index -* @returns fill value -*/ -type Callback = Nullary | Unary; - -/** -* Creates a filled array according to a provided callback function and having a specified data type. -* -* @param dtype - data type -* @returns filled array -* -* @example -* var arr = filledarrayBy(); -* // returns -* -* @example -* var arr = filledarrayBy( 'float32' ); -* // returns -*/ -declare function filledarrayBy( dtype?: DataType ): ArrayOrTypedArray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Creates a filled array according to a provided callback function and having a specified `length`. -* -* @param length - array length -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* -* var arr = filledarrayBy( 5, constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( length: number, clbk: Callback, thisArg?: any ): ArrayOrTypedArray; - -/** -* Creates a filled array according to a provided callback function and having a specified `length`. -* -* @param length - array length -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* -* var arr = filledarrayBy( 5, 'float64', constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( length: number, dtype: DataType, clbk: Callback, thisArg?: any ): ArrayOrTypedArray; - -/** -* Creates a filled array from another `array` according to a provided callback function. -* -* @param array - typed array or array-like object -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* -* 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; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Creates a filled array from another `array` according to a provided callback function. -* -* @param array - typed array or array-like object -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* -* 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; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Creates a filled array from an iterable according to a callback function. -* -* @param iterable - iterable -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var iterConstant = require( '@stdlib/iter-constant' ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarrayBy( it, constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( iterable: IterableIterator, clbk: Callback, thisArg?: any ): ArrayOrTypedArray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Creates a filled array from an iterable according to a callback function. -* -* @param iterable - iterable -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var iterConstant = require( '@stdlib/iter-constant' ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarrayBy( it, 'float64', constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( iterable: IterableIterator, dtype: DataType, clbk: 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. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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 | BooleanArray; - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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 | BooleanArray; - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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 | BooleanArray; - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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 | BooleanArray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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 | BooleanArray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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 | BooleanArray; // eslint-disable-line @typescript-eslint/unified-signatures - - -// EXPORTS // - -export = filledarrayBy; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 6f157fa..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.3-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.3-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@v0.0.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.3-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.3-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.3-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-ctors@v0.3.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill-by@v0.2.3-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled-by@v0.2.3-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.2.3-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.3-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@v0.2.3-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.4.1-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";var v=f(),g=j.get("dtypes.default");function c(){var f,j,c,b,y,x,u,E;if(0===(j=arguments.length))return new(y=d(g))(0);if(r(c=arguments[0])){if(j>1)throw new TypeError(w("00h05"));if(null===(y=d(c)))throw new TypeError(w("00h2Y",c));return new y(0)}if(j<2)throw new TypeError(w("00h05"));if(h(arguments[j-=1]))if(h(arguments[j-1])){if(f=arguments[j],b=arguments[j-=1],0===j)throw new TypeError(w("00h05"))}else b=arguments[j];else{if(!(j>=2))throw new TypeError(w("00h05"));if(f=arguments[j],!h(b=arguments[j-=1]))throw new TypeError(w("00h2b",b))}if((j-=1)>=0&&r(arguments[j])?(c=arguments[j],j-=1):c=g,null===(y=d(c)))throw new TypeError(w("00h2Y",c));if("generic"===c){if(E=arguments[0],0===j){if(e(E)?u=E:i(E)&&(u=E.length),void 0!==u)return m(u,b,f);if(n(E))throw new Error(w("00h04"));if(o(E)){if(!1===v)throw new TypeError(w("00h2Z",E));if(!h(E[p]))throw new TypeError(w("00h2a",E));if(E=E[p](),!h(E.next))throw new TypeError(w("00h2a",E));return function(r,e,t){var s,i;for(s=[],i=-1;!r.next().done;)i+=1,s.push(e.call(t,i));return s}(E,b,f)}throw new TypeError(w("00h2a",E))}if(n(E))throw new Error(w("00h04"));throw new TypeError(w("00h2a",E))}if(0===j)if(i(E=arguments[0]))x=new y(E.length);else if(n(E))x=new y(E);else if(e(E))x=new y(E);else{if(!o(E))throw new TypeError(w("00h2a",E));if(!1===v)throw new TypeError(w("00h2Z",E));if(!h(E[p]))throw new TypeError(w("00h2a",E));if(E=E[p](),!h(E.next))throw new TypeError(w("00h2a",E));x=new y(a(E))}else x=1===j?new y(arguments[0],arguments[1]):new y(arguments[0],arguments[1],arguments[2]);return x.length>0&&(t(c)||s(c)?function(r,e,t){var s;for(s=0;s\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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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( format('00h05') );\n\t\t}\n\t\tctor = ctors( dtype );\n\t\tif ( ctor === null ) {\n\t\t\tthrow new TypeError( format( '00h2Y', 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( format('00h05') );\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( format('00h05') );\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( '00h2b', clbk ) );\n\t\t}\n\t}\n\t// If we 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( format('00h05') );\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( '00h2Y', 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( format('00h04') );\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( '00h2Z', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00h2a', 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( '00h2a', 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( '00h2a', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format('00h04') );\n\t\t}\n\t\tthrow new TypeError( format( '00h2a', 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( '00h2Z', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00h2a', 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( '00h2a', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00h2a', 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\nexport default filledarrayBy;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","DEFAULT_DTYPE","defaults","get","filledarrayBy","thisArg","nargs","dtype","clbk","ctor","arr","len","arg","arguments","length","ctors","isString","TypeError","format","isFunction","isNonNegativeInteger","isCollection","filledArray","isArrayBuffer","Error","isObject","ITERATOR_SYMBOL","next","it","i","done","push","call","filledArrayIterator","iterLength","isComplexDataType","isBooleanDataType","set","filledAccessors","gfillBy","value","aidx"],"mappings":";;sjDA0CA,IAAIA,EAAsBC,IACtBC,EAAgBC,EAASC,IAAK,kBA2MlC,SAASC,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAKJ,GAAe,KAHfN,EAAQO,UAAUC,QAKjB,OAAO,IADPL,EAAOM,EAAOd,IACG,GAIlB,GAAKe,EADLT,EAAQM,UAAW,IACM,CAExB,GAAKP,EAAQ,EACZ,MAAM,IAAIW,UAAWC,EAAO,UAG7B,GAAc,QADdT,EAAOM,EAAOR,IAEb,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,OAAO,IAAIE,EAAM,EACjB,CAED,GAAKH,EAAQ,EACZ,MAAM,IAAIW,UAAWC,EAAO,UAM7B,GAAKC,EAAYN,UAHjBP,GAAS,IAKR,GAAKa,EAAYN,UAAWP,EAAM,KAMjC,GALAD,EAAUQ,UAAWP,GAErBE,EAAOK,UADPP,GAAS,GAIM,IAAVA,EACJ,MAAM,IAAIW,UAAWC,EAAO,eAI7BV,EAAOK,UAAWP,OAIf,MAAKA,GAAS,GAUlB,MAAM,IAAIW,UAAWC,EAAO,UAN5B,GAHAb,EAAUQ,UAAWP,IAGfa,EADNX,EAAOK,UADPP,GAAS,IAGR,MAAM,IAAIW,UAAWC,EAAQ,QAASV,GAMvC,CAUD,IARAF,GAAS,IACK,GAAKU,EAAUH,UAAWP,KACvCC,EAAQM,UAAWP,GACnBA,GAAS,GAETC,EAAQN,EAGK,QADdQ,EAAOM,EAAOR,IAEb,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,GAAe,YAAVA,EAAsB,CAE1B,GADAK,EAAMC,UAAW,GACF,IAAVP,EAAc,CAMlB,GALKc,EAAsBR,GAC1BD,EAAMC,EACKS,EAAcT,KACzBD,EAAMC,EAAIE,aAEE,IAARH,EACJ,OAAOW,EAAaX,EAAKH,EAAMH,GAEhC,GAAKkB,EAAeX,GACnB,MAAM,IAAIY,MAAON,EAAO,UAEzB,GAAKO,EAAUb,GAAQ,CACtB,IAA6B,IAAxBb,EACJ,MAAM,IAAIkB,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAYP,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLP,EAAYP,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvC,OAvSJ,SAA8BgB,EAAIpB,EAAMH,GACvC,IAAIK,EACAmB,EAKJ,IAFAnB,EAAM,GACNmB,GAAK,GAEAD,EAAGD,OACAG,MAGPD,GAAK,EACLnB,EAAIqB,KAAMvB,EAAKwB,KAAM3B,EAASwB,IAE/B,OAAOnB,CACR,CAuRWuB,CAAqBrB,EAAKJ,EAAMH,EACvC,CACD,MAAM,IAAIY,UAAWC,EAAQ,QAASN,GACzC,CAAS,GAAKW,EAAeX,GAC1B,MAAM,IAAIY,MAAON,EAAO,UAEzB,MAAM,IAAID,UAAWC,EAAQ,QAASN,GACtC,CACD,GAAe,IAAVN,EAEJ,GAAKe,EADLT,EAAMC,UAAW,IAEhBH,EAAM,IAAID,EAAMG,EAAIE,aACd,GAAKS,EAAeX,GAC1BF,EAAM,IAAID,EAAMG,QACV,GAAKQ,EAAsBR,GACjCF,EAAM,IAAID,EAAMG,OACV,KAAKa,EAAUb,GAarB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAZtC,IAA6B,IAAxBb,EACJ,MAAM,IAAIkB,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAYP,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLP,EAAYP,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvCF,EAAM,IAAID,EAAMyB,EAAYtB,GAG5B,MAEDF,EADqB,IAAVJ,EACL,IAAIG,EAAMI,UAAU,GAAIA,UAAU,IAElC,IAAIJ,EAAMI,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKH,EAAII,OAAS,IACZqB,EAAmB5B,IAAW6B,EAAmB7B,GAjTxD,SAA0BG,EAAKF,EAAMH,GACpC,IAAIwB,EACJ,IAAMA,EAAI,EAAGA,EAAInB,EAAII,OAAQe,IAC5BnB,EAAI2B,IAAK7B,EAAKwB,KAAM3B,EAASwB,GAAKA,EAGpC,CA4SGS,CAAiB5B,EAAKF,EAAMH,GAE5BkC,EAAS7B,EAAII,OAAQJ,EAAK,GAe5B,SAAmB8B,EAAOC,GACzB,OAAOjC,EAAKwB,KAAM3B,EAASoC,EAC3B,KAdM/B,CAeR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index dabf69c..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 11ab618195b3a4fa99dd0050a13b17f89d50a0d1 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 16 Jun 2026 20:45:48 +0000 Subject: [PATCH 111/117] Auto-generated commit --- .editorconfig | 189 - .eslintrc.js | 1 - .gitattributes | 68 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 101 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 204 - .npmignore | 229 - .npmrc | 44 - CHANGELOG.md | 239 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 49 +- SECURITY.md | 5 - benchmark/benchmark.js | 342 -- benchmark/benchmark.length.bool.js | 98 - benchmark/benchmark.length.complex128.js | 99 - benchmark/benchmark.length.complex64.js | 99 - benchmark/benchmark.length.float32.js | 98 - benchmark/benchmark.length.float64.js | 98 - benchmark/benchmark.length.generic.js | 98 - benchmark/benchmark.length.int16.js | 98 - benchmark/benchmark.length.int32.js | 98 - benchmark/benchmark.length.int8.js | 98 - benchmark/benchmark.length.uint16.js | 98 - benchmark/benchmark.length.uint32.js | 98 - benchmark/benchmark.length.uint8.js | 98 - benchmark/benchmark.length.uint8c.js | 98 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 36 - dist/index.js.map | 7 - docs/repl.txt | 157 - docs/types/test.ts | 606 --- examples/index.js | 37 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 192 - lib/main.js | 416 -- package.json | 96 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 4397 ---------------- 56 files changed, 4870 insertions(+), 11336 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.length.bool.js delete mode 100644 benchmark/benchmark.length.complex128.js delete mode 100644 benchmark/benchmark.length.complex64.js delete mode 100644 benchmark/benchmark.length.float32.js delete mode 100644 benchmark/benchmark.length.float64.js delete mode 100644 benchmark/benchmark.length.generic.js delete mode 100644 benchmark/benchmark.length.int16.js delete mode 100644 benchmark/benchmark.length.int32.js delete mode 100644 benchmark/benchmark.length.int8.js delete mode 100644 benchmark/benchmark.length.uint16.js delete mode 100644 benchmark/benchmark.length.uint32.js delete mode 100644 benchmark/benchmark.length.uint8.js delete mode 100644 benchmark/benchmark.length.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 80f3fca..0000000 --- a/.editorconfig +++ /dev/null @@ -1,189 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Ignore generated lock files for GitHub Agentic Workflows: -[*.lock.yml] -charset = unset -end_of_line = unset -indent_style = unset -indent_size = unset -trim_trailing_whitespace = unset -insert_final_newline = unset - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 24b327f..0000000 --- a/.gitattributes +++ /dev/null @@ -1,68 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation - -.github/workflows/*.lock.yml linguist-generated=true merge=ours diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 2d6aaee..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/contributing/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index f988046..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index b2c1f9c..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '42 6 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 83d50c4..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,821 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send notification to Zulip if job fails: - - name: 'Send notification to Zulip in case of failure' - # Pin action to full length commit SHA - uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 - if: failure() - with: - api-key: ${{ secrets.ZULIP_API_KEY }} - email: 'github-actions-bot@stdlib.zulipchat.com' - organization-url: 'https://stdlib.zulipchat.com' - to: 'workflows-standalone' - type: 'stream' - topic: ${{ github.event.repository.name }} - content: | - :cross_mark: **${{ github.workflow }}** workflow failed - - **Repository:** [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) - **Run:** [View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -278,7 +269,7 @@ for ( i = 0; i < dt.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -347,13 +338,13 @@ Copyright © 2016-2026. 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/dtypes]: https://github.com/stdlib-js/array-dtypes/tree/esm -[@stdlib/array/filled]: https://github.com/stdlib-js/array-filled +[@stdlib/array/filled]: https://github.com/stdlib-js/array-filled/tree/esm -[@stdlib/array/typed]: https://github.com/stdlib-js/array-typed +[@stdlib/array/typed]: https://github.com/stdlib-js/array-typed/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 6fba606..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,342 +0,0 @@ -/** -* @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 isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); -var isArray = require( '@stdlib/assert-is-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var Complex64 = require( '@stdlib/complex-float32-ctor' ); -var Complex128 = require( '@stdlib/complex-float64-ctor' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var filledarrayBy = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 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( format( '%s:dtype=float64', pkg ), function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'float64', 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( format( '%s:dtype=float32', pkg ), function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'float32', 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( format( '%s:dtype=bool', pkg ), 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( format( '%s:dtype=complex128', pkg ), function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( new Complex128( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'complex128', 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( format( '%s:dtype=complex64', pkg ), function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( new Complex64( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'complex64', 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( format( '%s:dtype=int32', pkg ), function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int32', 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( format( '%s:dtype=uint32', pkg ), function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint32', 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( format( '%s:dtype=int16', pkg ), function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int16', 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( format( '%s:dtype=uint16', pkg ), function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint16', 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( format( '%s:dtype=int8', pkg ), function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int8', 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( format( '%s:dtype=uint8', pkg ), function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint8', 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( format( '%s:dtype=uint8c', pkg ), function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint8c', 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( format( '%s:dtype=generic', pkg ), function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'generic', clbk ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.length.bool.js b/benchmark/benchmark.length.bool.js deleted file mode 100644 index 52b3237..0000000 --- a/benchmark/benchmark.length.bool.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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 format = require( '@stdlib/string-format' ); -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( format( '%s:dtype=bool,len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.complex128.js b/benchmark/benchmark.length.complex128.js deleted file mode 100644 index 63c0843..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,99 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 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 Complex128 = require( '@stdlib/complex-float64-ctor' ); -var format = require( '@stdlib/string-format' ); -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( new Complex128( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'complex128', 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( format( '%s:dtype=complex128,len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.complex64.js b/benchmark/benchmark.length.complex64.js deleted file mode 100644 index 186f811..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,99 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 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 Complex64 = require( '@stdlib/complex-float32-ctor' ); -var format = require( '@stdlib/string-format' ); -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( new Complex64( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'complex64', 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( format( '%s:dtype=complex64,len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.float32.js b/benchmark/benchmark.length.float32.js deleted file mode 100644 index 5ba3130..0000000 --- a/benchmark/benchmark.length.float32.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/string-format' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'float32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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( format( '%s:dtype=float32,len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.float64.js b/benchmark/benchmark.length.float64.js deleted file mode 100644 index 4a2be6c..0000000 --- a/benchmark/benchmark.length.float64.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/string-format' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'float64', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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( format( '%s:dtype=float64,len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.generic.js b/benchmark/benchmark.length.generic.js deleted file mode 100644 index 6522748..0000000 --- a/benchmark/benchmark.length.generic.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isArray = require( '@stdlib/assert-is-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/string-format' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'generic', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isArray( 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( format( '%s:dtype=generic,len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int16.js b/benchmark/benchmark.length.int16.js deleted file mode 100644 index 9ac94e9..0000000 --- a/benchmark/benchmark.length.int16.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/string-format' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int16', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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( format( '%s:dtype=int16,len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int32.js b/benchmark/benchmark.length.int32.js deleted file mode 100644 index a5ce4d0..0000000 --- a/benchmark/benchmark.length.int32.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/string-format' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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( format( '%s:dtype=int32,len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int8.js b/benchmark/benchmark.length.int8.js deleted file mode 100644 index 6104616..0000000 --- a/benchmark/benchmark.length.int8.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/string-format' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int8', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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( format( '%s:dtype=int8,len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint16.js b/benchmark/benchmark.length.uint16.js deleted file mode 100644 index 3108633..0000000 --- a/benchmark/benchmark.length.uint16.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/string-format' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint16', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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( format( '%s:dtype=uint16,len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint32.js b/benchmark/benchmark.length.uint32.js deleted file mode 100644 index 602e232..0000000 --- a/benchmark/benchmark.length.uint32.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/string-format' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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( format( '%s:dtype=uint32,len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint8.js b/benchmark/benchmark.length.uint8.js deleted file mode 100644 index 8664da3..0000000 --- a/benchmark/benchmark.length.uint8.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/string-format' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint8', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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( format( '%s:dtype=uint8,len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint8c.js b/benchmark/benchmark.length.uint8c.js deleted file mode 100644 index 76645b9..0000000 --- a/benchmark/benchmark.length.uint8c.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/string-format' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint8c', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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( format( '%s:dtype=uint8c,len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index c138144..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by" -%% click B href "https://github.com/stdlib-js/array-filled-by/tree/main" -%% click C href "https://github.com/stdlib-js/array-filled-by/tree/production" -%% click D href "https://github.com/stdlib-js/array-filled-by/tree/esm" -%% click E href "https://github.com/stdlib-js/array-filled-by/tree/deno" -%% click F href "https://github.com/stdlib-js/array-filled-by/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by -[production-url]: https://github.com/stdlib-js/array-filled-by/tree/production -[deno-url]: https://github.com/stdlib-js/array-filled-by/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-filled-by/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-filled-by/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-filled-by/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-filled-by/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-filled-by/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 188fc9b..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import filledarrayBy from '../docs/types/index'; -export = filledarrayBy; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 4049a13..0000000 --- a/dist/index.js +++ /dev/null @@ -1,36 +0,0 @@ -"use strict";var k=function(n,e){return function(){try{return e||n((e={exports:{}}).exports,e),e.exports}catch(t){throw e=0,t}}};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,t){var a,i,l;for(a=[],i=-1;l=n.next(),!l.done;)i+=1,a.push(e.call(t,i));return a}function C(n,e,t){var a;for(a=0;a1)throw new TypeError("invalid arguments. Must provide a length, typed array, array-like object, or an iterable.");if(i=v(t),i===null)throw new TypeError(o("invalid argument. Must provide a recognized data type. Value: `%s`.",t));return new i(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])?(t=arguments[e],e-=1):t=h,i=v(t),i===null)throw new TypeError(o("invalid argument. Must provide a recognized data type. Value: `%s`.",t));if(t==="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 i(r.length);else if(g(r))l=new i(r);else if(d(r))l=new i(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 i(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 i(arguments[0],arguments[1]):l=new i(arguments[0],arguments[1],arguments[2]);return l.length>0&&(q(t)||M(t)?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 deleted file mode 100644 index 8a898ec..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "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 we 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": "iIAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAuB,QAAS,uCAAwC,EAAE,YAC1EC,EAAoB,QAAS,+DAAgE,EAC7FC,EAAoB,QAAS,gDAAiD,EAC9EC,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,EACA,EACAC,EAIJ,IAFAD,EAAM,CAAC,EACP,EAAI,GAEHC,EAAIJ,EAAG,KAAK,EACP,CAAAI,EAAE,MAGP,GAAK,EACLD,EAAI,KAAMF,EAAK,KAAMC,EAAS,CAAE,CAAE,EAEnC,OAAOC,CACR,CAWA,SAASE,EAAiBF,EAAKF,EAAMC,EAAU,CAC9C,IAAII,EACJ,IAAMA,EAAI,EAAGA,EAAIH,EAAI,OAAQG,IAC5BH,EAAI,IAAKF,EAAK,KAAMC,EAASI,CAAE,EAAGA,CAAE,EAErC,OAAOH,CACR,CA4JA,SAASI,GAAgB,CACxB,IAAIL,EACAM,EACAC,EACAR,EACAS,EACAP,EACAQ,EACAC,EAKJ,GAHAJ,EAAQ,UAAU,OAGbA,IAAU,EACd,OAAAE,EAAOrB,EAAOS,CAAc,EACrB,IAAIY,EAAM,CAAE,EAIpB,GADAD,EAAQ,UAAW,CAAE,EAChB5B,EAAU4B,CAAM,EAAI,CAExB,GAAKD,EAAQ,EACZ,MAAM,IAAI,UAAW,2FAA4F,EAGlH,GADAE,EAAOrB,EAAOoB,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWd,EAAQ,sEAAuEa,CAAM,CAAE,EAG7G,OAAO,IAAIC,EAAM,CAAE,CACpB,CAEA,GAAKF,EAAQ,EACZ,MAAM,IAAI,UAAW,2FAA4F,EAMlH,GAHAA,GAAS,EAGJpB,EAAY,UAAWoB,CAAM,CAAE,EAEnC,GAAKpB,EAAY,UAAWoB,EAAM,CAAE,CAAE,GAMrC,GALAN,EAAU,UAAWM,CAAM,EAC3BA,GAAS,EACTP,EAAO,UAAWO,CAAM,EAGnBA,IAAU,EACd,MAAM,IAAI,UAAW,2FAA4F,OAIlHP,EAAO,UAAWO,CAAM,UAIhBA,GAAS,GAIlB,GAHAN,EAAU,UAAWM,CAAM,EAC3BA,GAAS,EACTP,EAAO,UAAWO,CAAM,EACnB,CAACpB,EAAYa,CAAK,EACtB,MAAM,IAAI,UAAWL,EAAQ,uEAAwEK,CAAK,CAAE,MAK7G,OAAM,IAAI,UAAW,2FAA4F,EAWlH,GARAO,GAAS,EACJA,GAAS,GAAK3B,EAAU,UAAW2B,CAAM,CAAE,GAC/CC,EAAQ,UAAWD,CAAM,EACzBA,GAAS,GAETC,EAAQX,EAETY,EAAOrB,EAAOoB,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWd,EAAQ,sEAAuEa,CAAM,CAAE,EAG7G,GAAKA,IAAU,UAAY,CAE1B,GADAG,EAAM,UAAW,CAAE,EACdJ,IAAU,EAAI,CAMlB,GALK1B,EAAsB8B,CAAI,EAC9BD,EAAMC,EACK3B,EAAc2B,CAAI,IAC7BD,EAAMC,EAAI,QAEND,IAAQ,OACZ,OAAOpB,EAAaoB,EAAKV,EAAMC,CAAQ,EAExC,GAAKhB,EAAe0B,CAAI,EACvB,MAAM,IAAI,MAAO,mFAAoF,EAEtG,GAAKzB,EAAUyB,CAAI,EAAI,CACtB,GAAKf,IAAwB,GAC5B,MAAM,IAAI,UAAWD,EAAQ,sIAAuIgB,CAAI,CAAE,EAE3K,GAAK,CAACxB,EAAYwB,EAAKnB,CAAgB,CAAE,EACxC,MAAM,IAAI,UAAWG,EAAQ,wGAAyGgB,CAAI,CAAE,EAG7I,GADAA,EAAMA,EAAKnB,CAAgB,EAAE,EACxB,CAACL,EAAYwB,EAAI,IAAK,EAC1B,MAAM,IAAI,UAAWhB,EAAQ,wGAAyGgB,CAAI,CAAE,EAE7I,OAAOb,EAAqBa,EAAKX,EAAMC,CAAQ,CAChD,CACA,MAAM,IAAI,UAAWN,EAAQ,wGAAyGgB,CAAI,CAAE,CAC7I,SAAY1B,EAAe0B,CAAI,EAC9B,MAAM,IAAI,MAAO,mFAAoF,EAEtG,MAAM,IAAI,UAAWhB,EAAQ,wGAAyGgB,CAAI,CAAE,CAC7I,CACA,GAAKJ,IAAU,EAEd,GADAI,EAAM,UAAW,CAAE,EACd3B,EAAc2B,CAAI,EACtBT,EAAM,IAAIO,EAAME,EAAI,MAAO,UAChB1B,EAAe0B,CAAI,EAC9BT,EAAM,IAAIO,EAAME,CAAI,UACT9B,EAAsB8B,CAAI,EACrCT,EAAM,IAAIO,EAAME,CAAI,UACTzB,EAAUyB,CAAI,EAAI,CAC7B,GAAKf,IAAwB,GAC5B,MAAM,IAAI,UAAWD,EAAQ,sIAAuIgB,CAAI,CAAE,EAE3K,GAAK,CAACxB,EAAYwB,EAAKnB,CAAgB,CAAE,EACxC,MAAM,IAAI,UAAWG,EAAQ,wGAAyGgB,CAAI,CAAE,EAG7I,GADAA,EAAMA,EAAKnB,CAAgB,EAAE,EACxB,CAACL,EAAYwB,EAAI,IAAK,EAC1B,MAAM,IAAI,UAAWhB,EAAQ,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,IACZpB,EAAmB0B,CAAM,GAAKzB,EAAmByB,CAAM,EAC3DJ,EAAiBF,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", "v", "filledAccessors", "i", "filledarrayBy", "nargs", "dtype", "ctor", "len", "arg", "callback", "value", "aidx", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 06f3146..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,157 +0,0 @@ - -{{alias}}( [dtype] ) - Creates a filled array. - - Parameters - ---------- - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr = {{alias}}() - - > arr = {{alias}}( 'float32' ) - - - -{{alias}}( length[, dtype], clbk[, thisArg] ) - Returns a filled array according to a provided callback function and having - a specified length. - - Parameters - ---------- - length: integer - Array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > function clbk() { return 1.0; }; - > var arr = {{alias}}( 5, clbk ) - [ 1.0, 1.0, 1.0, 1.0, 1.0 ] - > arr = {{alias}}( 5, 'int32', clbk ) - [ 1, 1, 1, 1, 1 ] - - -{{alias}}( array[, dtype], clbk[, thisArg] ) - Creates a filled array from another array (or array-like object) according - to a provided callback function. - - Parameters - ---------- - array: ArrayLikeObject - Array from which to generate another array. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias}}( [ 0.5, 0.5, 0.5 ], {{alias:@stdlib/utils/constant-function}}( 2.0 ) ) - [ 2.0, 2.0, 2.0 ] - > var arr2 = {{alias}}( arr1, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( iterable[, dtype], clbk[, thisArg] ) - Creates a filled array from an iterable according to a provided callback - function. - - Parameters - ---------- - iterable: Iterable - Iterable from which to generate an array. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias:@stdlib/iter/constant}}( 3.0, {'iter': 3} ); - > var arr2 = {{alias}}( arr1, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( buffer[, byteOffset[, length]][, dtype], clbk[, thisArg] ) - Returns a filled typed array view of an ArrayBuffer according to a provided - callback function. - - The 'generic' array data type is *not* supported. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( buf, 0, 4, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0, 1.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index bb876ed..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,606 +0,0 @@ -/* -* @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. -*/ - -/// - -import { IterableIterator } from '@stdlib/types/iter'; -import filledarrayBy = require( './index' ); - - -/** -* Returns an iterator protocol-compliant object. -* -* @returns iterator protocol-compliant object -*/ -function iterator(): IterableIterator { - const obj: IterableIterator = { - [Symbol.iterator]: iterator, - 'next': next - }; - return obj; -} - -/** -* Implements the iterator protocol `next` method. -* -* @returns iterator protocol-compliant object -*/ -function next(): any { - return { - 'value': 1.0, - 'done': false - }; -} - -/** -* Callback function. -* -* @param i - current array index -* @returns return value -*/ -function clbk( i: number ): number { - return i; -} - - -// TESTS // - -// The function returns an array or typed array... -{ - filledarrayBy(); // $ExpectType ArrayOrTypedArray - filledarrayBy( 'float32' ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( 10, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( 10, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( 10, 'int32', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( 10, 'int32', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const x = new Float64Array( 10 ); - filledarrayBy( x, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( x, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( x, 'uint8', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( x, 'uint8', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const y = [ 2.0, 2.0, 2.0 ]; - filledarrayBy( y, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( y, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( y, 'float64', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( y, 'float64', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const it = iterator(); - filledarrayBy( it, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( it, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( it, 'uint8c', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( it, 'uint8c', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const buf = new ArrayBuffer( 32 ); - filledarrayBy( buf, clbk ); // $ExpectType RealOrComplexTypedArray | BooleanArray - filledarrayBy( buf, clbk, {} ); // $ExpectType RealOrComplexTypedArray | BooleanArray - - filledarrayBy( buf, 'uint32', clbk ); // $ExpectType RealOrComplexTypedArray | BooleanArray - filledarrayBy( buf, 'uint32', clbk, {} ); // $ExpectType RealOrComplexTypedArray | BooleanArray - - filledarrayBy( buf, 8, clbk ); // $ExpectType RealOrComplexTypedArray | BooleanArray - filledarrayBy( buf, 8, clbk, {} ); // $ExpectType RealOrComplexTypedArray | BooleanArray - - filledarrayBy( buf, 8, 'uint16', clbk ); // $ExpectType RealOrComplexTypedArray | BooleanArray - filledarrayBy( buf, 8, 'uint16', clbk, {} ); // $ExpectType RealOrComplexTypedArray | BooleanArray - - filledarrayBy( buf, 8, 2, clbk ); // $ExpectType RealOrComplexTypedArray | BooleanArray - filledarrayBy( buf, 8, 2, clbk, {} ); // $ExpectType RealOrComplexTypedArray | BooleanArray - - filledarrayBy( buf, 8, 2, 'int16', clbk ); // $ExpectType RealOrComplexTypedArray | BooleanArray - filledarrayBy( buf, 8, 2, 'int16', clbk, {} ); // $ExpectType RealOrComplexTypedArray | BooleanArray -} - -// The compiler throws an error if a callback function argument is not a function... -{ - filledarrayBy( 'float64', '5' ); // $ExpectError - filledarrayBy( 'float64', 1.0 ); // $ExpectError - filledarrayBy( 'float64', false ); // $ExpectError - filledarrayBy( 'float64', true ); // $ExpectError - filledarrayBy( 'float64', null ); // $ExpectError - filledarrayBy( 'float64', undefined ); // $ExpectError - filledarrayBy( 'float64', [] ); // $ExpectError - filledarrayBy( 'float64', {} ); // $ExpectError - - filledarrayBy( 'float64', '5', {} ); // $ExpectError - filledarrayBy( 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( 'float64', false, {} ); // $ExpectError - filledarrayBy( 'float64', true, {} ); // $ExpectError - filledarrayBy( 'float64', null, {} ); // $ExpectError - filledarrayBy( 'float64', undefined, {} ); // $ExpectError - filledarrayBy( 'float64', [], {} ); // $ExpectError - filledarrayBy( 'float64', {}, {} ); // $ExpectError - - filledarrayBy( 10, '5' ); // $ExpectError - filledarrayBy( 10, 1.0 ); // $ExpectError - filledarrayBy( 10, false ); // $ExpectError - filledarrayBy( 10, true ); // $ExpectError - filledarrayBy( 10, null ); // $ExpectError - filledarrayBy( 10, undefined ); // $ExpectError - filledarrayBy( 10, [] ); // $ExpectError - filledarrayBy( 10, {} ); // $ExpectError - - filledarrayBy( 10, '5', {} ); // $ExpectError - filledarrayBy( 10, 1.0, {} ); // $ExpectError - filledarrayBy( 10, false, {} ); // $ExpectError - filledarrayBy( 10, true, {} ); // $ExpectError - filledarrayBy( 10, null, {} ); // $ExpectError - filledarrayBy( 10, undefined, {} ); // $ExpectError - filledarrayBy( 10, [], {} ); // $ExpectError - filledarrayBy( 10, {}, {} ); // $ExpectError - - filledarrayBy( 10, 'float64', '5' ); // $ExpectError - filledarrayBy( 10, 'float64', 1.0 ); // $ExpectError - filledarrayBy( 10, 'float64', false ); // $ExpectError - filledarrayBy( 10, 'float64', true ); // $ExpectError - filledarrayBy( 10, 'float64', null ); // $ExpectError - filledarrayBy( 10, 'float64', undefined ); // $ExpectError - filledarrayBy( 10, 'float64', [] ); // $ExpectError - filledarrayBy( 10, 'float64', {} ); // $ExpectError - - filledarrayBy( 10, 'float64', '5', {} ); // $ExpectError - filledarrayBy( 10, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( 10, 'float64', false, {} ); // $ExpectError - filledarrayBy( 10, 'float64', true, {} ); // $ExpectError - filledarrayBy( 10, 'float64', null, {} ); // $ExpectError - filledarrayBy( 10, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( 10, 'float64', [], {} ); // $ExpectError - filledarrayBy( 10, 'float64', {}, {} ); // $ExpectError - - const x = new Float64Array( 10 ); - filledarrayBy( x, '5' ); // $ExpectError - filledarrayBy( x, 1.0 ); // $ExpectError - filledarrayBy( x, false ); // $ExpectError - filledarrayBy( x, true ); // $ExpectError - filledarrayBy( x, null ); // $ExpectError - filledarrayBy( x, undefined ); // $ExpectError - filledarrayBy( x, [] ); // $ExpectError - filledarrayBy( x, {} ); // $ExpectError - - filledarrayBy( x, '5', {} ); // $ExpectError - filledarrayBy( x, 1.0, {} ); // $ExpectError - filledarrayBy( x, false, {} ); // $ExpectError - filledarrayBy( x, true, {} ); // $ExpectError - filledarrayBy( x, null, {} ); // $ExpectError - filledarrayBy( x, undefined, {} ); // $ExpectError - filledarrayBy( x, [], {} ); // $ExpectError - filledarrayBy( x, {}, {} ); // $ExpectError - - filledarrayBy( x, 'float64', '5' ); // $ExpectError - filledarrayBy( x, 'float64', 1.0 ); // $ExpectError - filledarrayBy( x, 'float64', false ); // $ExpectError - filledarrayBy( x, 'float64', true ); // $ExpectError - filledarrayBy( x, 'float64', null ); // $ExpectError - filledarrayBy( x, 'float64', undefined ); // $ExpectError - filledarrayBy( x, 'float64', [] ); // $ExpectError - filledarrayBy( x, 'float64', {} ); // $ExpectError - - filledarrayBy( x, 'float64', '5', {} ); // $ExpectError - filledarrayBy( x, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( x, 'float64', false, {} ); // $ExpectError - filledarrayBy( x, 'float64', true, {} ); // $ExpectError - filledarrayBy( x, 'float64', null, {} ); // $ExpectError - filledarrayBy( x, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( x, 'float64', [], {} ); // $ExpectError - filledarrayBy( x, 'float64', {}, {} ); // $ExpectError - - const y = [ 2.0, 2.0, 2.0 ]; - filledarrayBy( y, '5' ); // $ExpectError - filledarrayBy( y, 1.0 ); // $ExpectError - filledarrayBy( y, false ); // $ExpectError - filledarrayBy( y, true ); // $ExpectError - filledarrayBy( y, null ); // $ExpectError - filledarrayBy( y, undefined ); // $ExpectError - filledarrayBy( y, [] ); // $ExpectError - filledarrayBy( y, {} ); // $ExpectError - - filledarrayBy( y, '5', {} ); // $ExpectError - filledarrayBy( y, 1.0, {} ); // $ExpectError - filledarrayBy( y, false, {} ); // $ExpectError - filledarrayBy( y, true, {} ); // $ExpectError - filledarrayBy( y, null, {} ); // $ExpectError - filledarrayBy( y, undefined, {} ); // $ExpectError - filledarrayBy( y, [], {} ); // $ExpectError - filledarrayBy( y, {}, {} ); // $ExpectError - - filledarrayBy( y, 'float64', '5' ); // $ExpectError - filledarrayBy( y, 'float64', 1.0 ); // $ExpectError - filledarrayBy( y, 'float64', false ); // $ExpectError - filledarrayBy( y, 'float64', true ); // $ExpectError - filledarrayBy( y, 'float64', null ); // $ExpectError - filledarrayBy( y, 'float64', undefined ); // $ExpectError - filledarrayBy( y, 'float64', [] ); // $ExpectError - filledarrayBy( y, 'float64', {} ); // $ExpectError - - filledarrayBy( y, 'float64', '5', {} ); // $ExpectError - filledarrayBy( y, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( y, 'float64', false, {} ); // $ExpectError - filledarrayBy( y, 'float64', true, {} ); // $ExpectError - filledarrayBy( y, 'float64', null, {} ); // $ExpectError - filledarrayBy( y, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( y, 'float64', [], {} ); // $ExpectError - filledarrayBy( y, 'float64', {}, {} ); // $ExpectError - - const it = iterator(); - filledarrayBy( it, '5' ); // $ExpectError - filledarrayBy( it, 1.0 ); // $ExpectError - filledarrayBy( it, false ); // $ExpectError - filledarrayBy( it, true ); // $ExpectError - filledarrayBy( it, null ); // $ExpectError - filledarrayBy( it, undefined ); // $ExpectError - filledarrayBy( it, [] ); // $ExpectError - filledarrayBy( it, {} ); // $ExpectError - - filledarrayBy( it, '5', {} ); // $ExpectError - filledarrayBy( it, 1.0, {} ); // $ExpectError - filledarrayBy( it, false, {} ); // $ExpectError - filledarrayBy( it, true, {} ); // $ExpectError - filledarrayBy( it, null, {} ); // $ExpectError - filledarrayBy( it, undefined, {} ); // $ExpectError - filledarrayBy( it, [], {} ); // $ExpectError - filledarrayBy( it, {}, {} ); // $ExpectError - - filledarrayBy( it, 'float64', '5' ); // $ExpectError - filledarrayBy( it, 'float64', 1.0 ); // $ExpectError - filledarrayBy( it, 'float64', false ); // $ExpectError - filledarrayBy( it, 'float64', true ); // $ExpectError - filledarrayBy( it, 'float64', null ); // $ExpectError - filledarrayBy( it, 'float64', undefined ); // $ExpectError - filledarrayBy( it, 'float64', [] ); // $ExpectError - filledarrayBy( it, 'float64', {} ); // $ExpectError - - filledarrayBy( it, 'float64', '5', {} ); // $ExpectError - filledarrayBy( it, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( it, 'float64', false, {} ); // $ExpectError - filledarrayBy( it, 'float64', true, {} ); // $ExpectError - filledarrayBy( it, 'float64', null, {} ); // $ExpectError - filledarrayBy( it, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( it, 'float64', [], {} ); // $ExpectError - filledarrayBy( it, 'float64', {}, {} ); // $ExpectError - - const buf = new ArrayBuffer( 32 ); - filledarrayBy( buf, '5' ); // $ExpectError - filledarrayBy( buf, 1.0 ); // $ExpectError - filledarrayBy( buf, false ); // $ExpectError - filledarrayBy( buf, true ); // $ExpectError - filledarrayBy( buf, null ); // $ExpectError - filledarrayBy( buf, undefined ); // $ExpectError - filledarrayBy( buf, [] ); // $ExpectError - filledarrayBy( buf, {} ); // $ExpectError - - filledarrayBy( buf, '5', {} ); // $ExpectError - filledarrayBy( buf, 1.0, {} ); // $ExpectError - filledarrayBy( buf, false, {} ); // $ExpectError - filledarrayBy( buf, true, {} ); // $ExpectError - filledarrayBy( buf, null, {} ); // $ExpectError - filledarrayBy( buf, undefined, {} ); // $ExpectError - filledarrayBy( buf, [], {} ); // $ExpectError - filledarrayBy( buf, {}, {} ); // $ExpectError - - filledarrayBy( buf, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 'float64', false ); // $ExpectError - filledarrayBy( buf, 'float64', true ); // $ExpectError - filledarrayBy( buf, 'float64', null ); // $ExpectError - filledarrayBy( buf, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 'float64', {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5' ); // $ExpectError - filledarrayBy( buf, 8, 1.0 ); // $ExpectError - filledarrayBy( buf, 8, false ); // $ExpectError - filledarrayBy( buf, 8, true ); // $ExpectError - filledarrayBy( buf, 8, null ); // $ExpectError - filledarrayBy( buf, 8, undefined ); // $ExpectError - filledarrayBy( buf, 8, [] ); // $ExpectError - filledarrayBy( buf, 8, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, false, {} ); // $ExpectError - filledarrayBy( buf, 8, true, {} ); // $ExpectError - filledarrayBy( buf, 8, null, {} ); // $ExpectError - filledarrayBy( buf, 8, undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, [], {} ); // $ExpectError - filledarrayBy( buf, 8, {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 8, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 'float64', false ); // $ExpectError - filledarrayBy( buf, 8, 'float64', true ); // $ExpectError - filledarrayBy( buf, 8, 'float64', null ); // $ExpectError - filledarrayBy( buf, 8, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 8, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 8, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 8, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, '5' ); // $ExpectError - filledarrayBy( buf, 8, 2, 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 2, false ); // $ExpectError - filledarrayBy( buf, 8, 2, true ); // $ExpectError - filledarrayBy( buf, 8, 2, null ); // $ExpectError - filledarrayBy( buf, 8, 2, undefined ); // $ExpectError - filledarrayBy( buf, 8, 2, [] ); // $ExpectError - filledarrayBy( buf, 8, 2, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, false, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, true, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, null, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, [], {} ); // $ExpectError - filledarrayBy( buf, 8, 2, {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', false ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', true ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', null ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', {}, {} ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid length, typed array, array-like object, `ArrayBuffer`, or iterable argument... -{ - filledarrayBy( false, clbk ); // $ExpectError - filledarrayBy( true, clbk ); // $ExpectError - filledarrayBy( null, clbk ); // $ExpectError - filledarrayBy( {}, clbk ); // $ExpectError - - filledarrayBy( false, clbk, {} ); // $ExpectError - filledarrayBy( true, clbk, {} ); // $ExpectError - filledarrayBy( null, clbk, {} ); // $ExpectError - filledarrayBy( {}, clbk, {} ); // $ExpectError - - filledarrayBy( false, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 'float64', clbk ); // $ExpectError - - filledarrayBy( false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, clbk ); // $ExpectError - filledarrayBy( 1.0, 8, clbk ); // $ExpectError - filledarrayBy( false, 8, clbk ); // $ExpectError - filledarrayBy( true, 8, clbk ); // $ExpectError - filledarrayBy( null, 8, clbk ); // $ExpectError - filledarrayBy( undefined, 8, clbk ); // $ExpectError - filledarrayBy( [], 8, clbk ); // $ExpectError - filledarrayBy( {}, 8, clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, clbk ); // $ExpectError - - filledarrayBy( '5', 8, clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, clbk, {} ); // $ExpectError - filledarrayBy( false, 8, clbk, {} ); // $ExpectError - filledarrayBy( true, 8, clbk, {} ); // $ExpectError - filledarrayBy( null, 8, clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, clbk, {} ); // $ExpectError - filledarrayBy( [], 8, clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 'float64', clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( false, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( [], 8, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 'float64', clbk ); // $ExpectError - - filledarrayBy( '5', 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 2, clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 2, clbk ); // $ExpectError - filledarrayBy( false, 8, 2, clbk ); // $ExpectError - filledarrayBy( true, 8, 2, clbk ); // $ExpectError - filledarrayBy( null, 8, 2, clbk ); // $ExpectError - filledarrayBy( undefined, 8, 2, clbk ); // $ExpectError - filledarrayBy( [], 8, 2, clbk ); // $ExpectError - filledarrayBy( {}, 8, 2, clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, clbk ); // $ExpectError - - filledarrayBy( '5', 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( false, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( [], 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, 'float64', clbk ); // $ExpectError - - filledarrayBy( '5', 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a byte offset argument which is not a number... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, false, clbk ); // $ExpectError - filledarrayBy( buf, true, clbk ); // $ExpectError - filledarrayBy( buf, null, clbk ); // $ExpectError - filledarrayBy( buf, [], clbk ); // $ExpectError - filledarrayBy( buf, {}, clbk ); // $ExpectError - - filledarrayBy( buf, false, clbk, {} ); // $ExpectError - filledarrayBy( buf, true, clbk, {} ); // $ExpectError - filledarrayBy( buf, null, clbk, {} ); // $ExpectError - filledarrayBy( buf, [], clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, clbk, {} ); // $ExpectError - - filledarrayBy( buf, '5', 'float64', clbk ); // $ExpectError - filledarrayBy( buf, false, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, true, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, null, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, [], 'float64', clbk ); // $ExpectError - filledarrayBy( buf, {}, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, '5', 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( buf, false, 2, clbk ); // $ExpectError - filledarrayBy( buf, true, 2, clbk ); // $ExpectError - filledarrayBy( buf, null, 2, clbk ); // $ExpectError - filledarrayBy( buf, [], 2, clbk ); // $ExpectError - filledarrayBy( buf, {}, 2, clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, clbk ); // $ExpectError - - filledarrayBy( buf, false, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, clbk, {} ); // $ExpectError - - filledarrayBy( buf, '5', 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, false, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, true, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, null, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, undefined, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, [], 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, {}, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, '5', 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, false, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, undefined, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a view length argument which is not a number... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, 8, false, clbk ); // $ExpectError - filledarrayBy( buf, 8, true, clbk ); // $ExpectError - filledarrayBy( buf, 8, null, clbk ); // $ExpectError - filledarrayBy( buf, 8, [], clbk ); // $ExpectError - filledarrayBy( buf, 8, {}, clbk ); // $ExpectError - - filledarrayBy( buf, 8, false, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, true, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, null, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, [], clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, {}, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, clbk, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5', 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, false, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, true, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, null, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, [], 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, {}, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, 8, '5', 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, [], 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, {}, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided too many arguments... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, 8, 2, 'float64', 1, clbk, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 997a381..0000000 --- a/examples/index.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ).factory; -var dtypes = require( '@stdlib/array-typed-real-dtypes' ); -var filledarrayBy = require( './../lib' ); - -// Create a pseudorandom number generator: -var rand = discreteUniform( 0, 100 ); - -// Get a list of array data types: -var dt = dtypes(); - -// Generate filled arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = filledarrayBy( 10, dt[ i ], rand ); - console.log( arr ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 606ef7c..fde6688 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, RealOrComplexTypedArray, BooleanArray, DataType } from '@stdlib/types/array'; import { IterableIterator } from '@stdlib/types/iter'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..6f157fa --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.3-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.3-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@v0.0.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.3-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.3-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.3-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-ctors@v0.3.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill-by@v0.2.3-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled-by@v0.2.3-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.2.3-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.3-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@v0.2.3-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.4.1-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";var v=f(),g=j.get("dtypes.default");function c(){var f,j,c,b,y,x,u,E;if(0===(j=arguments.length))return new(y=d(g))(0);if(r(c=arguments[0])){if(j>1)throw new TypeError(w("00h05"));if(null===(y=d(c)))throw new TypeError(w("00h2Y",c));return new y(0)}if(j<2)throw new TypeError(w("00h05"));if(h(arguments[j-=1]))if(h(arguments[j-1])){if(f=arguments[j],b=arguments[j-=1],0===j)throw new TypeError(w("00h05"))}else b=arguments[j];else{if(!(j>=2))throw new TypeError(w("00h05"));if(f=arguments[j],!h(b=arguments[j-=1]))throw new TypeError(w("00h2b",b))}if((j-=1)>=0&&r(arguments[j])?(c=arguments[j],j-=1):c=g,null===(y=d(c)))throw new TypeError(w("00h2Y",c));if("generic"===c){if(E=arguments[0],0===j){if(e(E)?u=E:i(E)&&(u=E.length),void 0!==u)return m(u,b,f);if(n(E))throw new Error(w("00h04"));if(o(E)){if(!1===v)throw new TypeError(w("00h2Z",E));if(!h(E[p]))throw new TypeError(w("00h2a",E));if(E=E[p](),!h(E.next))throw new TypeError(w("00h2a",E));return function(r,e,t){var s,i;for(s=[],i=-1;!r.next().done;)i+=1,s.push(e.call(t,i));return s}(E,b,f)}throw new TypeError(w("00h2a",E))}if(n(E))throw new Error(w("00h04"));throw new TypeError(w("00h2a",E))}if(0===j)if(i(E=arguments[0]))x=new y(E.length);else if(n(E))x=new y(E);else if(e(E))x=new y(E);else{if(!o(E))throw new TypeError(w("00h2a",E));if(!1===v)throw new TypeError(w("00h2Z",E));if(!h(E[p]))throw new TypeError(w("00h2a",E));if(E=E[p](),!h(E.next))throw new TypeError(w("00h2a",E));x=new y(a(E))}else x=1===j?new y(arguments[0],arguments[1]):new y(arguments[0],arguments[1],arguments[2]);return x.length>0&&(t(c)||s(c)?function(r,e,t){var s;for(s=0;s\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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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( format('00h05') );\n\t\t}\n\t\tctor = ctors( dtype );\n\t\tif ( ctor === null ) {\n\t\t\tthrow new TypeError( format( '00h2Y', 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( format('00h05') );\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( format('00h05') );\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( '00h2b', clbk ) );\n\t\t}\n\t}\n\t// If we 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( format('00h05') );\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( '00h2Y', 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( format('00h04') );\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( '00h2Z', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00h2a', 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( '00h2a', 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( '00h2a', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format('00h04') );\n\t\t}\n\t\tthrow new TypeError( format( '00h2a', 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( '00h2Z', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00h2a', 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( '00h2a', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00h2a', 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\nexport default filledarrayBy;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","DEFAULT_DTYPE","defaults","get","filledarrayBy","thisArg","nargs","dtype","clbk","ctor","arr","len","arg","arguments","length","ctors","isString","TypeError","format","isFunction","isNonNegativeInteger","isCollection","filledArray","isArrayBuffer","Error","isObject","ITERATOR_SYMBOL","next","it","i","done","push","call","filledArrayIterator","iterLength","isComplexDataType","isBooleanDataType","set","filledAccessors","gfillBy","value","aidx"],"mappings":";;sjDA0CA,IAAIA,EAAsBC,IACtBC,EAAgBC,EAASC,IAAK,kBA2MlC,SAASC,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAKJ,GAAe,KAHfN,EAAQO,UAAUC,QAKjB,OAAO,IADPL,EAAOM,EAAOd,IACG,GAIlB,GAAKe,EADLT,EAAQM,UAAW,IACM,CAExB,GAAKP,EAAQ,EACZ,MAAM,IAAIW,UAAWC,EAAO,UAG7B,GAAc,QADdT,EAAOM,EAAOR,IAEb,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,OAAO,IAAIE,EAAM,EACjB,CAED,GAAKH,EAAQ,EACZ,MAAM,IAAIW,UAAWC,EAAO,UAM7B,GAAKC,EAAYN,UAHjBP,GAAS,IAKR,GAAKa,EAAYN,UAAWP,EAAM,KAMjC,GALAD,EAAUQ,UAAWP,GAErBE,EAAOK,UADPP,GAAS,GAIM,IAAVA,EACJ,MAAM,IAAIW,UAAWC,EAAO,eAI7BV,EAAOK,UAAWP,OAIf,MAAKA,GAAS,GAUlB,MAAM,IAAIW,UAAWC,EAAO,UAN5B,GAHAb,EAAUQ,UAAWP,IAGfa,EADNX,EAAOK,UADPP,GAAS,IAGR,MAAM,IAAIW,UAAWC,EAAQ,QAASV,GAMvC,CAUD,IARAF,GAAS,IACK,GAAKU,EAAUH,UAAWP,KACvCC,EAAQM,UAAWP,GACnBA,GAAS,GAETC,EAAQN,EAGK,QADdQ,EAAOM,EAAOR,IAEb,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,GAAe,YAAVA,EAAsB,CAE1B,GADAK,EAAMC,UAAW,GACF,IAAVP,EAAc,CAMlB,GALKc,EAAsBR,GAC1BD,EAAMC,EACKS,EAAcT,KACzBD,EAAMC,EAAIE,aAEE,IAARH,EACJ,OAAOW,EAAaX,EAAKH,EAAMH,GAEhC,GAAKkB,EAAeX,GACnB,MAAM,IAAIY,MAAON,EAAO,UAEzB,GAAKO,EAAUb,GAAQ,CACtB,IAA6B,IAAxBb,EACJ,MAAM,IAAIkB,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAYP,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLP,EAAYP,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvC,OAvSJ,SAA8BgB,EAAIpB,EAAMH,GACvC,IAAIK,EACAmB,EAKJ,IAFAnB,EAAM,GACNmB,GAAK,GAEAD,EAAGD,OACAG,MAGPD,GAAK,EACLnB,EAAIqB,KAAMvB,EAAKwB,KAAM3B,EAASwB,IAE/B,OAAOnB,CACR,CAuRWuB,CAAqBrB,EAAKJ,EAAMH,EACvC,CACD,MAAM,IAAIY,UAAWC,EAAQ,QAASN,GACzC,CAAS,GAAKW,EAAeX,GAC1B,MAAM,IAAIY,MAAON,EAAO,UAEzB,MAAM,IAAID,UAAWC,EAAQ,QAASN,GACtC,CACD,GAAe,IAAVN,EAEJ,GAAKe,EADLT,EAAMC,UAAW,IAEhBH,EAAM,IAAID,EAAMG,EAAIE,aACd,GAAKS,EAAeX,GAC1BF,EAAM,IAAID,EAAMG,QACV,GAAKQ,EAAsBR,GACjCF,EAAM,IAAID,EAAMG,OACV,KAAKa,EAAUb,GAarB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAZtC,IAA6B,IAAxBb,EACJ,MAAM,IAAIkB,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAYP,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLP,EAAYP,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvCF,EAAM,IAAID,EAAMyB,EAAYtB,GAG5B,MAEDF,EADqB,IAAVJ,EACL,IAAIG,EAAMI,UAAU,GAAIA,UAAU,IAElC,IAAIJ,EAAMI,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKH,EAAII,OAAS,IACZqB,EAAmB5B,IAAW6B,EAAmB7B,GAjTxD,SAA0BG,EAAKF,EAAMH,GACpC,IAAIwB,EACJ,IAAMA,EAAI,EAAGA,EAAInB,EAAII,OAAQe,IAC5BnB,EAAI2B,IAAK7B,EAAKwB,KAAM3B,EAASwB,GAAKA,EAGpC,CA4SGS,CAAiB5B,EAAKF,EAAMH,GAE5BkC,EAAS7B,EAAII,OAAQJ,EAAK,GAe5B,SAAmB8B,EAAOC,GACzB,OAAOjC,EAAKwB,KAAM3B,EAASoC,EAC3B,KAdM/B,CAeR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d115cf0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,192 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -/** -* Create a filled array according to a provided callback function. -* -* @module @stdlib/array-filled-by -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* var arr = filledarrayBy(); -* // returns -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'generic', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( [ 0.5, 0.5 ], clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1; -* } -* -* var arr = filledarrayBy( [ 5, -3 ], 'int32', clbk ); -* // returns [ 1, 1 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk1() { -* return 10; -* } -* -* function clbk2() { -* return 1.0; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, clbk2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk1() { -* return 1.0; -* } -* -* function clbk2() { -* return 2; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, 'uint32', clbk2 ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 'float32', clbk ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, clbk ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, 'int32', clbk ); -* // returns [ 1, 1 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 32b6545..0000000 --- a/lib/main.js +++ /dev/null @@ -1,416 +0,0 @@ -/** -* @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 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' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var ctors = require( '@stdlib/array-ctors' ); -var gfillBy = require( '@stdlib/blas-ext-base-gfill-by' ); -var filledArray = require( '@stdlib/array-base-filled-by' ); -var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var iterLength = require( '@stdlib/iter-length' ); -var defaults = require( '@stdlib/array-defaults' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport(); -var DEFAULT_DTYPE = defaults.get( 'dtypes.default' ); - - -// FUNCTIONS // - -/** -* Creates a filled "generic" array from an iterator. -* -* @private -* @param {Iterable} it - iterator -* @param {Callback} clbk - callback function -* @param {*} thisArg - callback function execution context -* @returns {Array} filled array -*/ -function filledArrayIterator( it, clbk, thisArg ) { - var arr; - var i; - var v; - - arr = []; - i = -1; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - i += 1; - arr.push( clbk.call( thisArg, i ) ); - } - return arr; -} - -/** -* Fills an array exposing accessors for getting and setting array elements. -* -* @private -* @param {Collection} arr - input array -* @param {Callback} clbk - callback function -* @param {*} thisArg - callback function execution context -* @returns {Collection} input array -*/ -function filledAccessors( arr, clbk, thisArg ) { - var i; - for ( i = 0; i < arr.length; i++ ) { - arr.set( clbk.call( thisArg, i ), i ); - } - return arr; -} - - -// MAIN // - -/** -* Creates a filled array according to a provided callback function. -* -* @param {(NonNegativeInteger|TypedArray|ArrayLikeObject|ArrayBuffer|Iterable)} [arg] - a length, typed array, array-like object, buffer, or iterable -* @param {NonNegativeInteger} [byteOffset=0] - byte offset -* @param {NonNegativeInteger} [length] - view length -* @param {string} [dtype="float64"] - data type -* @param {Callback} [clbk] - callback to invoke -* @param {*} [thisArg] - callback execution context -* @throws {TypeError} must provide a recognized data type -* @throws {TypeError} must provide a length, typed array, array-like object, buffer, or iterable -* @throws {TypeError} callback argument must be a function. -* @throws {Error} creating a generic array from an `ArrayBuffer` is not supported -* @returns {(TypedArray|Array)} array or typed array -* -* @example -* var arr = filledarrayBy(); -* // returns -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'generic', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( [ 0.5, 0.5 ], clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1; -* } -* -* var arr = filledarrayBy( [ 5, -3 ], 'int32', clbk ); -* // returns [ 1, 1 ] -* -* @example -* function clbk1() { -* return 10; -* } -* -* function clbk2() { -* return 1.0; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, clbk2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk1() { -* return 1.0; -* } -* -* function clbk2() { -* return 2; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, 'uint32', clbk2 ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 'float32', clbk ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, clbk ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, 'int32', clbk ); -* // returns [ 1, 1 ] -*/ -function filledarrayBy() { - var thisArg; - var nargs; - var dtype; - var clbk; - var ctor; - var arr; - var len; - var arg; - - nargs = arguments.length; - - // If we weren't provided any arguments, return an empty array... - if ( nargs === 0 ) { - ctor = ctors( DEFAULT_DTYPE ); - return new ctor( 0 ); - } - // Check if we were provided a dtype as the first argument... - dtype = arguments[ 0 ]; - if ( isString( dtype ) ) { - // Invoking this function with arguments `f( dtype, clbk[, thisArg] )` is not allowed (otherwise, we'd need to also allow `f( clbk[, thisArg] )`)... - if ( nargs > 1 ) { - throw new TypeError( format('00h05') ); - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '00h2Y', dtype ) ); - } - // Return an empty array having the specified dtype: - return new ctor( 0 ); - } - // For all other supported invocations, we need at least two arguments... - if ( nargs < 2 ) { - throw new TypeError( format('00h05') ); - } - // At this point, we need to do some argument juggling... - nargs -= 1; // henceforth, the number of available arguments is `nargs+1` - - // Determine whether the last argument is a callback or "this" context... - if ( isFunction( arguments[ nargs ] ) ) { - // 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... - if ( isFunction( arguments[ nargs-1 ] ) ) { - thisArg = arguments[ nargs ]; - nargs -= 1; - clbk = arguments[ nargs ]; - - // Check if we were provided only a callback and a "this" context.. - if ( nargs === 0 ) { - throw new TypeError( format('00h05') ); - } - } else { - // "this" context is left undefined... - clbk = arguments[ nargs ]; - } - } - // 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... - else if ( nargs >= 2 ) { - thisArg = arguments[ nargs ]; - nargs -= 1; - clbk = arguments[ nargs ]; - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '00h2b', clbk ) ); - } - } - // If we were only provided 2 arguments and the last argument was not a function, we've been provided an insufficient number of arguments... - else { - throw new TypeError( format('00h05') ); - } - // Now that we've processed the callback arguments, let's continue working backward to see if we've been provided a `dtype` argument... - nargs -= 1; - if ( nargs >= 0 && isString( arguments[ nargs ] ) ) { - dtype = arguments[ nargs ]; - nargs -= 1; - } else { - dtype = DEFAULT_DTYPE; - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '00h2Y', dtype ) ); - } - // At this point, we've resolved the output array data type, and now we can actually create the output array... - if ( dtype === 'generic' ) { - arg = arguments[ 0 ]; - if ( nargs === 0 ) { - if ( isNonNegativeInteger( arg ) ) { - len = arg; - } else if ( isCollection( arg ) ) { - len = arg.length; - } - if ( len !== void 0 ) { - return filledArray( len, clbk, thisArg ); - } - if ( isArrayBuffer( arg ) ) { - throw new Error( format('00h04') ); - } - if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( '00h2Z', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00h2a', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00h2a', arg ) ); - } - return filledArrayIterator( arg, clbk, thisArg ); - } - throw new TypeError( format( '00h2a', arg ) ); - } else if ( isArrayBuffer( arg ) ) { - throw new Error( format('00h04') ); - } - throw new TypeError( format( '00h2a', arg ) ); - } - if ( nargs === 0 ) { // length || array-like || ArrayBuffer || iterable - arg = arguments[ 0 ]; - if ( isCollection( arg ) ) { - arr = new ctor( arg.length ); - } else if ( isArrayBuffer( arg ) ) { - arr = new ctor( arg ); - } else if ( isNonNegativeInteger( arg ) ) { - arr = new ctor( arg ); - } else if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( '00h2Z', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00h2a', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00h2a', arg ) ); - } - arr = new ctor( iterLength( arg ) ); - } else { - throw new TypeError( format( '00h2a', arg ) ); - } - } else if ( nargs === 1 ) { - arr = new ctor( arguments[0], arguments[1] ); // (ArrayBuffer, byteOffset) - } else { - arr = new ctor( arguments[0], arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset, length) - } - if ( arr.length > 0 ) { - if ( isComplexDataType( dtype ) || isBooleanDataType( dtype ) ) { - filledAccessors( arr, clbk, thisArg ); - } else { - gfillBy( arr.length, arr, 1, callback ); - } - } - return arr; - - /** - * Callback which wraps a provided callback and is invoked for each array element. - * - * @private - * @param {*} value - element value - * @param {NonNegativeInteger} aidx - array index - * @param {NonNegativeInteger} sidx - strided index - * @param {Collection} array - input array/collection - * @returns {*} callback return value - */ - function callback( value, aidx ) { - return clbk.call( thisArg, aidx ); - } -} - - -// EXPORTS // - -module.exports = filledarrayBy; diff --git a/package.json b/package.json index a1a5078..026d062 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.3.1", "description": "Create a filled array according to a provided callback function.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,75 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-assert-is-boolean-data-type": "^0.0.2", - "@stdlib/array-base-assert-is-complex-floating-point-data-type": "^0.2.2", - "@stdlib/array-base-filled-by": "^0.2.3", - "@stdlib/array-ctors": "^0.3.1", - "@stdlib/array-defaults": "^0.4.1", - "@stdlib/assert-has-iterator-symbol-support": "^0.2.3", - "@stdlib/assert-is-arraybuffer": "^0.2.3", - "@stdlib/assert-is-collection": "^0.2.3", - "@stdlib/assert-is-function": "^0.2.3", - "@stdlib/assert-is-nonnegative-integer": "^0.2.3", - "@stdlib/assert-is-object": "^0.2.3", - "@stdlib/assert-is-string": "^0.2.3", - "@stdlib/blas-ext-base-gfill-by": "^0.2.3", - "@stdlib/iter-length": "^0.2.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3", - "@stdlib/symbol-iterator": "^0.2.3", - "@stdlib/types": "^0.5.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3" - }, - "devDependencies": { - "@stdlib/array-bool": "^0.1.2", - "@stdlib/array-buffer": "^0.2.3", - "@stdlib/array-complex128": "^0.3.2", - "@stdlib/array-complex64": "^0.3.2", - "@stdlib/array-float32": "^0.2.3", - "@stdlib/array-float64": "^0.2.3", - "@stdlib/array-int16": "^0.2.3", - "@stdlib/array-int32": "^0.2.3", - "@stdlib/array-int8": "^0.2.3", - "@stdlib/array-typed-real-dtypes": "^0.2.3", - "@stdlib/array-uint16": "^0.2.3", - "@stdlib/array-uint32": "^0.2.3", - "@stdlib/array-uint8": "^0.2.3", - "@stdlib/array-uint8c": "^0.2.3", - "@stdlib/assert-instance-of": "^0.3.1", - "@stdlib/assert-is-array": "^0.2.3", - "@stdlib/assert-is-typed-array": "^0.2.3", - "@stdlib/assert-is-typed-array-like": "^0.2.3", - "@stdlib/complex-float32-ctor": "^0.1.1", - "@stdlib/complex-float64-ctor": "^0.1.2", - "@stdlib/iter-constant": "^0.2.3", - "@stdlib/math-base-special-pow": "^0.3.1", - "@stdlib/random-base-discrete-uniform": "^0.2.2", - "@stdlib/strided-base-reinterpret-boolean": "^0.0.3", - "@stdlib/strided-base-reinterpret-complex128": "^0.2.3", - "@stdlib/strided-base-reinterpret-complex64": "^0.2.2", - "@stdlib/utils-constant-function": "^0.2.3", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.3" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..dabf69c --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index ca0cf25..0000000 --- a/test/test.js +++ /dev/null @@ -1,4397 +0,0 @@ -/** -* @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. -*/ - -/* eslint-disable max-len */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -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' ); -var iterConstant = require( '@stdlib/iter-constant' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var filledarrayBy = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': !hasIteratorSymbolSupport() -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof filledarrayBy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if only provided callback arguments', function test( t ) { - t.throws( clbk1, TypeError, 'throws an error' ); - t.throws( clbk2, TypeError, 'throws an error' ); - t.throws( clbk3, TypeError, 'throws an error' ); - t.end(); - - function clbk1() { - filledarrayBy( constantFunction( 1.0 ) ); - } - - function clbk2() { - filledarrayBy( constantFunction( 1.0 ), {} ); - } - - function clbk3() { - filledarrayBy( constantFunction( 1.0 ), constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (only argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (typed array; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (array-like object)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (array-like object; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 8 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 8 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, 1, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (iterator)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( iterConstant( 1.0 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (iterator; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( iterConstant( 1.0 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if only provided data type and callback arguments', function test( t ) { - t.throws( clbk1, TypeError, 'throws an error' ); - t.throws( clbk2, TypeError, 'throws an error' ); - t.throws( clbk3, TypeError, 'throws an error' ); - t.end(); - - function clbk1() { - filledarrayBy( 'float64', constantFunction( 1.0 ) ); - } - - function clbk2() { - filledarrayBy( 'float64', constantFunction( 1.0 ), {} ); - } - - function clbk3() { - filledarrayBy( 'float64', constantFunction( 1.0 ), constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (array-like object)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (array-like object; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, 1, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, 1, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (no iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (no iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (non-function iterator symbol property)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (non-function iterator symbol property; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (`next` property is not a function)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ) ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (`next` property is not a function; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ), {} ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (no iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (no iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (non-function iterator symbol property)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (non-function iterator symbol property; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (`next` property is not a function)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ) ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (`next` property is not a function; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ), {} ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 1, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 1, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function returns a filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - arr = filledarrayBy(); - - t.strictEqual( instanceOf( arr, Float64Array ), 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=float64)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - arr = filledarrayBy( 'float64' ); - - t.strictEqual( instanceOf( arr, Float64Array ), 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=float32)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( 0 ); - arr = filledarrayBy( 'float32' ); - - t.strictEqual( instanceOf( arr, Float32Array ), 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=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; - - expected = new Complex128Array( 0 ); - arr = filledarrayBy( 'complex128' ); - - t.strictEqual( instanceOf( arr, Complex128Array ), 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=complex64)', function test( t ) { - var expected; - var arr; - - expected = new Complex64Array( 0 ); - arr = filledarrayBy( 'complex64' ); - - t.strictEqual( instanceOf( arr, Complex64Array ), 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=int32)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( 0 ); - arr = filledarrayBy( 'int32' ); - - t.strictEqual( instanceOf( arr, Int32Array ), 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=uint32)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( 0 ); - arr = filledarrayBy( 'uint32' ); - - t.strictEqual( instanceOf( arr, Uint32Array ), 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=int16)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( 0 ); - arr = filledarrayBy( 'int16' ); - - t.strictEqual( instanceOf( arr, Int16Array ), 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=uint16)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( 0 ); - arr = filledarrayBy( 'uint16' ); - - t.strictEqual( instanceOf( arr, Uint16Array ), 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=int8)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( 0 ); - arr = filledarrayBy( 'int8' ); - - t.strictEqual( instanceOf( arr, Int8Array ), 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=uint8)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( 0 ); - arr = filledarrayBy( 'uint8' ); - - t.strictEqual( instanceOf( arr, Uint8Array ), 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=uint8c)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( 0 ); - arr = filledarrayBy( 'uint8c' ); - - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), 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=generic)', function test( t ) { - var expected; - var arr; - - expected = []; - arr = filledarrayBy( 'generic' ); - - t.strictEqual( instanceOf( arr, Array ), 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 (default, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, length=0)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array(); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 0, clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, clbk, ctx ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (default, length; thisArg=function)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, clbk, context ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this(); // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } - - function context() { - ctx.count += 1; - } -}); - -tape( 'the function returns a filled array (dtype=float64, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, 'float64', clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, length; thisArg=function)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, 'float64', clbk, context ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this(); // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } - - function context() { - ctx.count += 1; - } -}); - -tape( 'the function returns a filled array (dtype=float32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, 'float32', clbk ); - - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - 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; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = filledarrayBy( 5, 'complex128', clbk ); - - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = filledarrayBy( 5, 'complex64', clbk ); - - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int32Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int32', clbk ); - - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint32Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint32', clbk ); - - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int16Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int16', clbk ); - - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint16', clbk ); - - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int8Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int8', clbk ); - - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint8', clbk ); - - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint8c', clbk ); - - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = [ 1, 1, 1, 1, 1 ]; - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'generic', clbk ); - - t.strictEqual( instanceOf( arr, Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - 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; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = [ 1.0, 2.0 ]; - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = [ 1.0, 2.0 ]; - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int32', clbk ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, typed array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, typed array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - 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; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = new Float64Array( [ 1.0, 2.0 ] ); - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = new Float64Array( [ 1.0, 2.0 ] ); - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (default, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - 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; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer, byteoffset; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer, byteoffset; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - 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; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 48 ); - out = filledarrayBy( buf, 16, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 24 ); - out = filledarrayBy( buf, 8, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int32', clbk ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint8c', clbk ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - 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; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 64 ); - out = filledarrayBy( buf, 16, 2, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset, length)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 1, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 1, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled array (default, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, iterator; thisArg)', opts, function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - ctx = { - 'count': 0 - }; - indices = []; - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, iterator; thisArg)', opts, function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - ctx = { - 'count': 0 - }; - indices = []; - out = filledarrayBy( arr, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - 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; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = iterConstant( new Complex128( 3.0, 3.0 ), { - 'iter': 2 - }); - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = iterConstant( new Complex64( 3.0, 3.0 ), { - 'iter': 2 - }); - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); From fb8cc25fa23f5f870890597e179b60b54d467998 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 27 Jun 2026 03:47:04 +0000 Subject: [PATCH 112/117] Transform error messages --- lib/main.js | 38 +++++++++++++++++++------------------- package.json | 2 +- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/lib/main.js b/lib/main.js index d2128f5..32b6545 100644 --- a/lib/main.js +++ b/lib/main.js @@ -35,7 +35,7 @@ var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-supp var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); var iterLength = require( '@stdlib/iter-length' ); var defaults = require( '@stdlib/array-defaults' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -266,18 +266,18 @@ function filledarrayBy() { if ( isString( dtype ) ) { // Invoking this function with arguments `f( dtype, clbk[, thisArg] )` is not allowed (otherwise, we'd need to also allow `f( clbk[, thisArg] )`)... if ( nargs > 1 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format('00h05') ); } ctor = ctors( dtype ); if ( ctor === null ) { - throw new TypeError( format( 'invalid argument. Must provide a recognized data type. Value: `%s`.', dtype ) ); + throw new TypeError( format( '00h2Y', dtype ) ); } // Return an empty array having the specified dtype: return new ctor( 0 ); } // For all other supported invocations, we need at least two arguments... if ( nargs < 2 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format('00h05') ); } // At this point, we need to do some argument juggling... nargs -= 1; // henceforth, the number of available arguments is `nargs+1` @@ -292,7 +292,7 @@ function filledarrayBy() { // Check if we were provided only a callback and a "this" context.. if ( nargs === 0 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format('00h05') ); } } else { // "this" context is left undefined... @@ -305,12 +305,12 @@ function filledarrayBy() { nargs -= 1; clbk = arguments[ nargs ]; if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '00h2b', clbk ) ); } } // If we were only provided 2 arguments and the last argument was not a function, we've been provided an insufficient number of arguments... else { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format('00h05') ); } // Now that we've processed the callback arguments, let's continue working backward to see if we've been provided a `dtype` argument... nargs -= 1; @@ -322,7 +322,7 @@ function filledarrayBy() { } ctor = ctors( dtype ); if ( ctor === null ) { - throw new TypeError( format( 'invalid argument. Must provide a recognized data type. Value: `%s`.', dtype ) ); + throw new TypeError( format( '00h2Y', dtype ) ); } // At this point, we've resolved the output array data type, and now we can actually create the output array... if ( dtype === 'generic' ) { @@ -337,26 +337,26 @@ function filledarrayBy() { return filledArray( len, clbk, thisArg ); } if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format('00h04') ); } if ( isObject( arg ) ) { if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2Z', arg ) ); } if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } arg = arg[ ITERATOR_SYMBOL ](); if ( !isFunction( arg.next ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } return filledArrayIterator( arg, clbk, thisArg ); } - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } else if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format('00h04') ); } - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } if ( nargs === 0 ) { // length || array-like || ArrayBuffer || iterable arg = arguments[ 0 ]; @@ -368,18 +368,18 @@ function filledarrayBy() { arr = new ctor( arg ); } else if ( isObject( arg ) ) { if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2Z', arg ) ); } if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } arg = arg[ ITERATOR_SYMBOL ](); if ( !isFunction( arg.next ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } arr = new ctor( iterLength( arg ) ); } else { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } } else if ( nargs === 1 ) { arr = new ctor( arguments[0], arguments[1] ); // (ArrayBuffer, byteOffset) diff --git a/package.json b/package.json index b1d16c6..a1a5078 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "@stdlib/assert-is-string": "^0.2.3", "@stdlib/blas-ext-base-gfill-by": "^0.2.3", "@stdlib/iter-length": "^0.2.3", - "@stdlib/string-format": "^0.2.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.3", "@stdlib/symbol-iterator": "^0.2.3", "@stdlib/types": "^0.5.1", "@stdlib/error-tools-fmtprodmsg": "^0.2.3" From 37b70befcf6c19d8004cacd5e4401fa00b0ae95c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 27 Jun 2026 03:57:28 +0000 Subject: [PATCH 113/117] Remove files --- index.d.ts | 322 ---- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5169 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index fde6688..0000000 --- a/index.d.ts +++ /dev/null @@ -1,322 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, RealOrComplexTypedArray, BooleanArray, DataType } from '@stdlib/types/array'; -import { IterableIterator } from '@stdlib/types/iter'; - -/** -* Array or typed array. -*/ -type ArrayOrTypedArray = Array | RealOrComplexTypedArray | BooleanArray; - -/** -* Nullary callback function. -* -* @returns fill value -*/ -type Nullary = () => any; - -/** -* Unary callback function. -* -* @param i - current array index -* @returns fill value -*/ -type Unary = ( i: number ) => any; - -/** -* Callback function. -* -* @param i - current array index -* @returns fill value -*/ -type Callback = Nullary | Unary; - -/** -* Creates a filled array having a specified data type. -* -* @param dtype - data type -* @returns filled array -* -* @example -* var arr = filledarrayBy(); -* // returns -* -* @example -* var arr = filledarrayBy( 'float32' ); -* // returns -*/ -declare function filledarrayBy( dtype?: DataType ): ArrayOrTypedArray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Creates a filled array according to a provided callback function and having a specified `length`. -* -* @param length - array length -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* -* var arr = filledarrayBy( 5, constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( length: number, clbk: Callback, thisArg?: any ): ArrayOrTypedArray; - -/** -* Creates a filled array according to a provided callback function and having a specified `length`. -* -* @param length - array length -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* -* var arr = filledarrayBy( 5, 'float64', constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( length: number, dtype: DataType, clbk: Callback, thisArg?: any ): ArrayOrTypedArray; - -/** -* Creates a filled array from another `array` according to a provided callback function. -* -* @param array - typed array or array-like object -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* -* 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; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Creates a filled array from another `array` according to a provided callback function. -* -* @param array - typed array or array-like object -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* -* 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; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Creates a filled array from an iterable according to a callback function. -* -* @param iterable - iterable -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var iterConstant = require( '@stdlib/iter-constant' ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarrayBy( it, constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( iterable: IterableIterator, clbk: Callback, thisArg?: any ): ArrayOrTypedArray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Creates a filled array from an iterable according to a callback function. -* -* @param iterable - iterable -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var iterConstant = require( '@stdlib/iter-constant' ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarrayBy( it, 'float64', constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( iterable: IterableIterator, dtype: DataType, clbk: 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. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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 | BooleanArray; - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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 | BooleanArray; - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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 | BooleanArray; - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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 | BooleanArray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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 | BooleanArray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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 | BooleanArray; // eslint-disable-line @typescript-eslint/unified-signatures - - -// EXPORTS // - -export = filledarrayBy; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 6f157fa..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.3-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.3-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@v0.0.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.3-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.3-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.3-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-ctors@v0.3.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill-by@v0.2.3-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled-by@v0.2.3-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.2.3-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.3-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@v0.2.3-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.4.1-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";var v=f(),g=j.get("dtypes.default");function c(){var f,j,c,b,y,x,u,E;if(0===(j=arguments.length))return new(y=d(g))(0);if(r(c=arguments[0])){if(j>1)throw new TypeError(w("00h05"));if(null===(y=d(c)))throw new TypeError(w("00h2Y",c));return new y(0)}if(j<2)throw new TypeError(w("00h05"));if(h(arguments[j-=1]))if(h(arguments[j-1])){if(f=arguments[j],b=arguments[j-=1],0===j)throw new TypeError(w("00h05"))}else b=arguments[j];else{if(!(j>=2))throw new TypeError(w("00h05"));if(f=arguments[j],!h(b=arguments[j-=1]))throw new TypeError(w("00h2b",b))}if((j-=1)>=0&&r(arguments[j])?(c=arguments[j],j-=1):c=g,null===(y=d(c)))throw new TypeError(w("00h2Y",c));if("generic"===c){if(E=arguments[0],0===j){if(e(E)?u=E:i(E)&&(u=E.length),void 0!==u)return m(u,b,f);if(n(E))throw new Error(w("00h04"));if(o(E)){if(!1===v)throw new TypeError(w("00h2Z",E));if(!h(E[p]))throw new TypeError(w("00h2a",E));if(E=E[p](),!h(E.next))throw new TypeError(w("00h2a",E));return function(r,e,t){var s,i;for(s=[],i=-1;!r.next().done;)i+=1,s.push(e.call(t,i));return s}(E,b,f)}throw new TypeError(w("00h2a",E))}if(n(E))throw new Error(w("00h04"));throw new TypeError(w("00h2a",E))}if(0===j)if(i(E=arguments[0]))x=new y(E.length);else if(n(E))x=new y(E);else if(e(E))x=new y(E);else{if(!o(E))throw new TypeError(w("00h2a",E));if(!1===v)throw new TypeError(w("00h2Z",E));if(!h(E[p]))throw new TypeError(w("00h2a",E));if(E=E[p](),!h(E.next))throw new TypeError(w("00h2a",E));x=new y(a(E))}else x=1===j?new y(arguments[0],arguments[1]):new y(arguments[0],arguments[1],arguments[2]);return x.length>0&&(t(c)||s(c)?function(r,e,t){var s;for(s=0;s\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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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( format('00h05') );\n\t\t}\n\t\tctor = ctors( dtype );\n\t\tif ( ctor === null ) {\n\t\t\tthrow new TypeError( format( '00h2Y', 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( format('00h05') );\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( format('00h05') );\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( '00h2b', clbk ) );\n\t\t}\n\t}\n\t// If we 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( format('00h05') );\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( '00h2Y', 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( format('00h04') );\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( '00h2Z', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00h2a', 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( '00h2a', 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( '00h2a', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format('00h04') );\n\t\t}\n\t\tthrow new TypeError( format( '00h2a', 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( '00h2Z', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00h2a', 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( '00h2a', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00h2a', 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\nexport default filledarrayBy;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","DEFAULT_DTYPE","defaults","get","filledarrayBy","thisArg","nargs","dtype","clbk","ctor","arr","len","arg","arguments","length","ctors","isString","TypeError","format","isFunction","isNonNegativeInteger","isCollection","filledArray","isArrayBuffer","Error","isObject","ITERATOR_SYMBOL","next","it","i","done","push","call","filledArrayIterator","iterLength","isComplexDataType","isBooleanDataType","set","filledAccessors","gfillBy","value","aidx"],"mappings":";;sjDA0CA,IAAIA,EAAsBC,IACtBC,EAAgBC,EAASC,IAAK,kBA2MlC,SAASC,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAKJ,GAAe,KAHfN,EAAQO,UAAUC,QAKjB,OAAO,IADPL,EAAOM,EAAOd,IACG,GAIlB,GAAKe,EADLT,EAAQM,UAAW,IACM,CAExB,GAAKP,EAAQ,EACZ,MAAM,IAAIW,UAAWC,EAAO,UAG7B,GAAc,QADdT,EAAOM,EAAOR,IAEb,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,OAAO,IAAIE,EAAM,EACjB,CAED,GAAKH,EAAQ,EACZ,MAAM,IAAIW,UAAWC,EAAO,UAM7B,GAAKC,EAAYN,UAHjBP,GAAS,IAKR,GAAKa,EAAYN,UAAWP,EAAM,KAMjC,GALAD,EAAUQ,UAAWP,GAErBE,EAAOK,UADPP,GAAS,GAIM,IAAVA,EACJ,MAAM,IAAIW,UAAWC,EAAO,eAI7BV,EAAOK,UAAWP,OAIf,MAAKA,GAAS,GAUlB,MAAM,IAAIW,UAAWC,EAAO,UAN5B,GAHAb,EAAUQ,UAAWP,IAGfa,EADNX,EAAOK,UADPP,GAAS,IAGR,MAAM,IAAIW,UAAWC,EAAQ,QAASV,GAMvC,CAUD,IARAF,GAAS,IACK,GAAKU,EAAUH,UAAWP,KACvCC,EAAQM,UAAWP,GACnBA,GAAS,GAETC,EAAQN,EAGK,QADdQ,EAAOM,EAAOR,IAEb,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,GAAe,YAAVA,EAAsB,CAE1B,GADAK,EAAMC,UAAW,GACF,IAAVP,EAAc,CAMlB,GALKc,EAAsBR,GAC1BD,EAAMC,EACKS,EAAcT,KACzBD,EAAMC,EAAIE,aAEE,IAARH,EACJ,OAAOW,EAAaX,EAAKH,EAAMH,GAEhC,GAAKkB,EAAeX,GACnB,MAAM,IAAIY,MAAON,EAAO,UAEzB,GAAKO,EAAUb,GAAQ,CACtB,IAA6B,IAAxBb,EACJ,MAAM,IAAIkB,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAYP,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLP,EAAYP,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvC,OAvSJ,SAA8BgB,EAAIpB,EAAMH,GACvC,IAAIK,EACAmB,EAKJ,IAFAnB,EAAM,GACNmB,GAAK,GAEAD,EAAGD,OACAG,MAGPD,GAAK,EACLnB,EAAIqB,KAAMvB,EAAKwB,KAAM3B,EAASwB,IAE/B,OAAOnB,CACR,CAuRWuB,CAAqBrB,EAAKJ,EAAMH,EACvC,CACD,MAAM,IAAIY,UAAWC,EAAQ,QAASN,GACzC,CAAS,GAAKW,EAAeX,GAC1B,MAAM,IAAIY,MAAON,EAAO,UAEzB,MAAM,IAAID,UAAWC,EAAQ,QAASN,GACtC,CACD,GAAe,IAAVN,EAEJ,GAAKe,EADLT,EAAMC,UAAW,IAEhBH,EAAM,IAAID,EAAMG,EAAIE,aACd,GAAKS,EAAeX,GAC1BF,EAAM,IAAID,EAAMG,QACV,GAAKQ,EAAsBR,GACjCF,EAAM,IAAID,EAAMG,OACV,KAAKa,EAAUb,GAarB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAZtC,IAA6B,IAAxBb,EACJ,MAAM,IAAIkB,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAYP,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLP,EAAYP,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvCF,EAAM,IAAID,EAAMyB,EAAYtB,GAG5B,MAEDF,EADqB,IAAVJ,EACL,IAAIG,EAAMI,UAAU,GAAIA,UAAU,IAElC,IAAIJ,EAAMI,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKH,EAAII,OAAS,IACZqB,EAAmB5B,IAAW6B,EAAmB7B,GAjTxD,SAA0BG,EAAKF,EAAMH,GACpC,IAAIwB,EACJ,IAAMA,EAAI,EAAGA,EAAInB,EAAII,OAAQe,IAC5BnB,EAAI2B,IAAK7B,EAAKwB,KAAM3B,EAASwB,GAAKA,EAGpC,CA4SGS,CAAiB5B,EAAKF,EAAMH,GAE5BkC,EAAS7B,EAAII,OAAQJ,EAAK,GAe5B,SAAmB8B,EAAOC,GACzB,OAAOjC,EAAKwB,KAAM3B,EAASoC,EAC3B,KAdM/B,CAeR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index dabf69c..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 2b7706b812257143c60b60373e65c646ff2d7307 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 27 Jun 2026 03:57:49 +0000 Subject: [PATCH 114/117] Auto-generated commit --- .editorconfig | 189 - .eslintrc.js | 1 - .gitattributes | 68 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 101 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 204 - .npmignore | 229 - .npmrc | 44 - CHANGELOG.md | 239 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 49 +- SECURITY.md | 5 - benchmark/benchmark.js | 342 -- benchmark/benchmark.length.bool.js | 98 - benchmark/benchmark.length.complex128.js | 99 - benchmark/benchmark.length.complex64.js | 99 - benchmark/benchmark.length.float32.js | 98 - benchmark/benchmark.length.float64.js | 98 - benchmark/benchmark.length.generic.js | 98 - benchmark/benchmark.length.int16.js | 98 - benchmark/benchmark.length.int32.js | 98 - benchmark/benchmark.length.int8.js | 98 - benchmark/benchmark.length.uint16.js | 98 - benchmark/benchmark.length.uint32.js | 98 - benchmark/benchmark.length.uint8.js | 98 - benchmark/benchmark.length.uint8c.js | 98 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 36 - dist/index.js.map | 7 - docs/repl.txt | 157 - docs/types/test.ts | 606 --- examples/index.js | 37 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 192 - lib/main.js | 416 -- package.json | 96 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 4397 ---------------- 57 files changed, 4870 insertions(+), 11337 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.length.bool.js delete mode 100644 benchmark/benchmark.length.complex128.js delete mode 100644 benchmark/benchmark.length.complex64.js delete mode 100644 benchmark/benchmark.length.float32.js delete mode 100644 benchmark/benchmark.length.float64.js delete mode 100644 benchmark/benchmark.length.generic.js delete mode 100644 benchmark/benchmark.length.int16.js delete mode 100644 benchmark/benchmark.length.int32.js delete mode 100644 benchmark/benchmark.length.int8.js delete mode 100644 benchmark/benchmark.length.uint16.js delete mode 100644 benchmark/benchmark.length.uint32.js delete mode 100644 benchmark/benchmark.length.uint8.js delete mode 100644 benchmark/benchmark.length.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 80f3fca..0000000 --- a/.editorconfig +++ /dev/null @@ -1,189 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Ignore generated lock files for GitHub Agentic Workflows: -[*.lock.yml] -charset = unset -end_of_line = unset -indent_style = unset -indent_size = unset -trim_trailing_whitespace = unset -insert_final_newline = unset - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 24b327f..0000000 --- a/.gitattributes +++ /dev/null @@ -1,68 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation - -.github/workflows/*.lock.yml linguist-generated=true merge=ours diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 3cce453..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2026-06-27T03:35:24.771Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 2d6aaee..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/contributing/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index f988046..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index b2c1f9c..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '42 6 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 83d50c4..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,821 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send notification to Zulip if job fails: - - name: 'Send notification to Zulip in case of failure' - # Pin action to full length commit SHA - uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 - if: failure() - with: - api-key: ${{ secrets.ZULIP_API_KEY }} - email: 'github-actions-bot@stdlib.zulipchat.com' - organization-url: 'https://stdlib.zulipchat.com' - to: 'workflows-standalone' - type: 'stream' - topic: ${{ github.event.repository.name }} - content: | - :cross_mark: **${{ github.workflow }}** workflow failed - - **Repository:** [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) - **Run:** [View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -278,7 +269,7 @@ for ( i = 0; i < dt.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -347,13 +338,13 @@ Copyright © 2016-2026. 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/dtypes]: https://github.com/stdlib-js/array-dtypes/tree/esm -[@stdlib/array/filled]: https://github.com/stdlib-js/array-filled +[@stdlib/array/filled]: https://github.com/stdlib-js/array-filled/tree/esm -[@stdlib/array/typed]: https://github.com/stdlib-js/array-typed +[@stdlib/array/typed]: https://github.com/stdlib-js/array-typed/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 6fba606..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,342 +0,0 @@ -/** -* @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 isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); -var isArray = require( '@stdlib/assert-is-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var Complex64 = require( '@stdlib/complex-float32-ctor' ); -var Complex128 = require( '@stdlib/complex-float64-ctor' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var filledarrayBy = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 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( format( '%s:dtype=float64', pkg ), function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'float64', 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( format( '%s:dtype=float32', pkg ), function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'float32', 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( format( '%s:dtype=bool', pkg ), 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( format( '%s:dtype=complex128', pkg ), function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( new Complex128( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'complex128', 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( format( '%s:dtype=complex64', pkg ), function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( new Complex64( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'complex64', 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( format( '%s:dtype=int32', pkg ), function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int32', 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( format( '%s:dtype=uint32', pkg ), function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint32', 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( format( '%s:dtype=int16', pkg ), function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int16', 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( format( '%s:dtype=uint16', pkg ), function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint16', 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( format( '%s:dtype=int8', pkg ), function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int8', 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( format( '%s:dtype=uint8', pkg ), function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint8', 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( format( '%s:dtype=uint8c', pkg ), function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint8c', 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( format( '%s:dtype=generic', pkg ), function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'generic', clbk ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.length.bool.js b/benchmark/benchmark.length.bool.js deleted file mode 100644 index 52b3237..0000000 --- a/benchmark/benchmark.length.bool.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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 format = require( '@stdlib/string-format' ); -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( format( '%s:dtype=bool,len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.complex128.js b/benchmark/benchmark.length.complex128.js deleted file mode 100644 index 63c0843..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,99 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 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 Complex128 = require( '@stdlib/complex-float64-ctor' ); -var format = require( '@stdlib/string-format' ); -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( new Complex128( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'complex128', 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( format( '%s:dtype=complex128,len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.complex64.js b/benchmark/benchmark.length.complex64.js deleted file mode 100644 index 186f811..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,99 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 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 Complex64 = require( '@stdlib/complex-float32-ctor' ); -var format = require( '@stdlib/string-format' ); -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( new Complex64( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'complex64', 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( format( '%s:dtype=complex64,len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.float32.js b/benchmark/benchmark.length.float32.js deleted file mode 100644 index 5ba3130..0000000 --- a/benchmark/benchmark.length.float32.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/string-format' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'float32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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( format( '%s:dtype=float32,len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.float64.js b/benchmark/benchmark.length.float64.js deleted file mode 100644 index 4a2be6c..0000000 --- a/benchmark/benchmark.length.float64.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/string-format' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'float64', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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( format( '%s:dtype=float64,len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.generic.js b/benchmark/benchmark.length.generic.js deleted file mode 100644 index 6522748..0000000 --- a/benchmark/benchmark.length.generic.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isArray = require( '@stdlib/assert-is-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/string-format' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'generic', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isArray( 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( format( '%s:dtype=generic,len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int16.js b/benchmark/benchmark.length.int16.js deleted file mode 100644 index 9ac94e9..0000000 --- a/benchmark/benchmark.length.int16.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/string-format' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int16', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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( format( '%s:dtype=int16,len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int32.js b/benchmark/benchmark.length.int32.js deleted file mode 100644 index a5ce4d0..0000000 --- a/benchmark/benchmark.length.int32.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/string-format' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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( format( '%s:dtype=int32,len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int8.js b/benchmark/benchmark.length.int8.js deleted file mode 100644 index 6104616..0000000 --- a/benchmark/benchmark.length.int8.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/string-format' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int8', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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( format( '%s:dtype=int8,len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint16.js b/benchmark/benchmark.length.uint16.js deleted file mode 100644 index 3108633..0000000 --- a/benchmark/benchmark.length.uint16.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/string-format' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint16', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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( format( '%s:dtype=uint16,len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint32.js b/benchmark/benchmark.length.uint32.js deleted file mode 100644 index 602e232..0000000 --- a/benchmark/benchmark.length.uint32.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/string-format' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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( format( '%s:dtype=uint32,len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint8.js b/benchmark/benchmark.length.uint8.js deleted file mode 100644 index 8664da3..0000000 --- a/benchmark/benchmark.length.uint8.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/string-format' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint8', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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( format( '%s:dtype=uint8,len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint8c.js b/benchmark/benchmark.length.uint8c.js deleted file mode 100644 index 76645b9..0000000 --- a/benchmark/benchmark.length.uint8c.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/string-format' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint8c', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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( format( '%s:dtype=uint8c,len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index c138144..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by" -%% click B href "https://github.com/stdlib-js/array-filled-by/tree/main" -%% click C href "https://github.com/stdlib-js/array-filled-by/tree/production" -%% click D href "https://github.com/stdlib-js/array-filled-by/tree/esm" -%% click E href "https://github.com/stdlib-js/array-filled-by/tree/deno" -%% click F href "https://github.com/stdlib-js/array-filled-by/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by -[production-url]: https://github.com/stdlib-js/array-filled-by/tree/production -[deno-url]: https://github.com/stdlib-js/array-filled-by/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-filled-by/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-filled-by/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-filled-by/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-filled-by/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-filled-by/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 188fc9b..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import filledarrayBy from '../docs/types/index'; -export = filledarrayBy; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 4049a13..0000000 --- a/dist/index.js +++ /dev/null @@ -1,36 +0,0 @@ -"use strict";var k=function(n,e){return function(){try{return e||n((e={exports:{}}).exports,e),e.exports}catch(t){throw e=0,t}}};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,t){var a,i,l;for(a=[],i=-1;l=n.next(),!l.done;)i+=1,a.push(e.call(t,i));return a}function C(n,e,t){var a;for(a=0;a1)throw new TypeError("invalid arguments. Must provide a length, typed array, array-like object, or an iterable.");if(i=v(t),i===null)throw new TypeError(o("invalid argument. Must provide a recognized data type. Value: `%s`.",t));return new i(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])?(t=arguments[e],e-=1):t=h,i=v(t),i===null)throw new TypeError(o("invalid argument. Must provide a recognized data type. Value: `%s`.",t));if(t==="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 i(r.length);else if(g(r))l=new i(r);else if(d(r))l=new i(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 i(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 i(arguments[0],arguments[1]):l=new i(arguments[0],arguments[1],arguments[2]);return l.length>0&&(q(t)||M(t)?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 deleted file mode 100644 index 8a898ec..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "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 we 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": "iIAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAuB,QAAS,uCAAwC,EAAE,YAC1EC,EAAoB,QAAS,+DAAgE,EAC7FC,EAAoB,QAAS,gDAAiD,EAC9EC,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,EACA,EACAC,EAIJ,IAFAD,EAAM,CAAC,EACP,EAAI,GAEHC,EAAIJ,EAAG,KAAK,EACP,CAAAI,EAAE,MAGP,GAAK,EACLD,EAAI,KAAMF,EAAK,KAAMC,EAAS,CAAE,CAAE,EAEnC,OAAOC,CACR,CAWA,SAASE,EAAiBF,EAAKF,EAAMC,EAAU,CAC9C,IAAII,EACJ,IAAMA,EAAI,EAAGA,EAAIH,EAAI,OAAQG,IAC5BH,EAAI,IAAKF,EAAK,KAAMC,EAASI,CAAE,EAAGA,CAAE,EAErC,OAAOH,CACR,CA4JA,SAASI,GAAgB,CACxB,IAAIL,EACAM,EACAC,EACAR,EACAS,EACAP,EACAQ,EACAC,EAKJ,GAHAJ,EAAQ,UAAU,OAGbA,IAAU,EACd,OAAAE,EAAOrB,EAAOS,CAAc,EACrB,IAAIY,EAAM,CAAE,EAIpB,GADAD,EAAQ,UAAW,CAAE,EAChB5B,EAAU4B,CAAM,EAAI,CAExB,GAAKD,EAAQ,EACZ,MAAM,IAAI,UAAW,2FAA4F,EAGlH,GADAE,EAAOrB,EAAOoB,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWd,EAAQ,sEAAuEa,CAAM,CAAE,EAG7G,OAAO,IAAIC,EAAM,CAAE,CACpB,CAEA,GAAKF,EAAQ,EACZ,MAAM,IAAI,UAAW,2FAA4F,EAMlH,GAHAA,GAAS,EAGJpB,EAAY,UAAWoB,CAAM,CAAE,EAEnC,GAAKpB,EAAY,UAAWoB,EAAM,CAAE,CAAE,GAMrC,GALAN,EAAU,UAAWM,CAAM,EAC3BA,GAAS,EACTP,EAAO,UAAWO,CAAM,EAGnBA,IAAU,EACd,MAAM,IAAI,UAAW,2FAA4F,OAIlHP,EAAO,UAAWO,CAAM,UAIhBA,GAAS,GAIlB,GAHAN,EAAU,UAAWM,CAAM,EAC3BA,GAAS,EACTP,EAAO,UAAWO,CAAM,EACnB,CAACpB,EAAYa,CAAK,EACtB,MAAM,IAAI,UAAWL,EAAQ,uEAAwEK,CAAK,CAAE,MAK7G,OAAM,IAAI,UAAW,2FAA4F,EAWlH,GARAO,GAAS,EACJA,GAAS,GAAK3B,EAAU,UAAW2B,CAAM,CAAE,GAC/CC,EAAQ,UAAWD,CAAM,EACzBA,GAAS,GAETC,EAAQX,EAETY,EAAOrB,EAAOoB,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWd,EAAQ,sEAAuEa,CAAM,CAAE,EAG7G,GAAKA,IAAU,UAAY,CAE1B,GADAG,EAAM,UAAW,CAAE,EACdJ,IAAU,EAAI,CAMlB,GALK1B,EAAsB8B,CAAI,EAC9BD,EAAMC,EACK3B,EAAc2B,CAAI,IAC7BD,EAAMC,EAAI,QAEND,IAAQ,OACZ,OAAOpB,EAAaoB,EAAKV,EAAMC,CAAQ,EAExC,GAAKhB,EAAe0B,CAAI,EACvB,MAAM,IAAI,MAAO,mFAAoF,EAEtG,GAAKzB,EAAUyB,CAAI,EAAI,CACtB,GAAKf,IAAwB,GAC5B,MAAM,IAAI,UAAWD,EAAQ,sIAAuIgB,CAAI,CAAE,EAE3K,GAAK,CAACxB,EAAYwB,EAAKnB,CAAgB,CAAE,EACxC,MAAM,IAAI,UAAWG,EAAQ,wGAAyGgB,CAAI,CAAE,EAG7I,GADAA,EAAMA,EAAKnB,CAAgB,EAAE,EACxB,CAACL,EAAYwB,EAAI,IAAK,EAC1B,MAAM,IAAI,UAAWhB,EAAQ,wGAAyGgB,CAAI,CAAE,EAE7I,OAAOb,EAAqBa,EAAKX,EAAMC,CAAQ,CAChD,CACA,MAAM,IAAI,UAAWN,EAAQ,wGAAyGgB,CAAI,CAAE,CAC7I,SAAY1B,EAAe0B,CAAI,EAC9B,MAAM,IAAI,MAAO,mFAAoF,EAEtG,MAAM,IAAI,UAAWhB,EAAQ,wGAAyGgB,CAAI,CAAE,CAC7I,CACA,GAAKJ,IAAU,EAEd,GADAI,EAAM,UAAW,CAAE,EACd3B,EAAc2B,CAAI,EACtBT,EAAM,IAAIO,EAAME,EAAI,MAAO,UAChB1B,EAAe0B,CAAI,EAC9BT,EAAM,IAAIO,EAAME,CAAI,UACT9B,EAAsB8B,CAAI,EACrCT,EAAM,IAAIO,EAAME,CAAI,UACTzB,EAAUyB,CAAI,EAAI,CAC7B,GAAKf,IAAwB,GAC5B,MAAM,IAAI,UAAWD,EAAQ,sIAAuIgB,CAAI,CAAE,EAE3K,GAAK,CAACxB,EAAYwB,EAAKnB,CAAgB,CAAE,EACxC,MAAM,IAAI,UAAWG,EAAQ,wGAAyGgB,CAAI,CAAE,EAG7I,GADAA,EAAMA,EAAKnB,CAAgB,EAAE,EACxB,CAACL,EAAYwB,EAAI,IAAK,EAC1B,MAAM,IAAI,UAAWhB,EAAQ,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,IACZpB,EAAmB0B,CAAM,GAAKzB,EAAmByB,CAAM,EAC3DJ,EAAiBF,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", "v", "filledAccessors", "i", "filledarrayBy", "nargs", "dtype", "ctor", "len", "arg", "callback", "value", "aidx", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 06f3146..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,157 +0,0 @@ - -{{alias}}( [dtype] ) - Creates a filled array. - - Parameters - ---------- - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr = {{alias}}() - - > arr = {{alias}}( 'float32' ) - - - -{{alias}}( length[, dtype], clbk[, thisArg] ) - Returns a filled array according to a provided callback function and having - a specified length. - - Parameters - ---------- - length: integer - Array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > function clbk() { return 1.0; }; - > var arr = {{alias}}( 5, clbk ) - [ 1.0, 1.0, 1.0, 1.0, 1.0 ] - > arr = {{alias}}( 5, 'int32', clbk ) - [ 1, 1, 1, 1, 1 ] - - -{{alias}}( array[, dtype], clbk[, thisArg] ) - Creates a filled array from another array (or array-like object) according - to a provided callback function. - - Parameters - ---------- - array: ArrayLikeObject - Array from which to generate another array. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias}}( [ 0.5, 0.5, 0.5 ], {{alias:@stdlib/utils/constant-function}}( 2.0 ) ) - [ 2.0, 2.0, 2.0 ] - > var arr2 = {{alias}}( arr1, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( iterable[, dtype], clbk[, thisArg] ) - Creates a filled array from an iterable according to a provided callback - function. - - Parameters - ---------- - iterable: Iterable - Iterable from which to generate an array. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias:@stdlib/iter/constant}}( 3.0, {'iter': 3} ); - > var arr2 = {{alias}}( arr1, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( buffer[, byteOffset[, length]][, dtype], clbk[, thisArg] ) - Returns a filled typed array view of an ArrayBuffer according to a provided - callback function. - - The 'generic' array data type is *not* supported. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( buf, 0, 4, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0, 1.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index bb876ed..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,606 +0,0 @@ -/* -* @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. -*/ - -/// - -import { IterableIterator } from '@stdlib/types/iter'; -import filledarrayBy = require( './index' ); - - -/** -* Returns an iterator protocol-compliant object. -* -* @returns iterator protocol-compliant object -*/ -function iterator(): IterableIterator { - const obj: IterableIterator = { - [Symbol.iterator]: iterator, - 'next': next - }; - return obj; -} - -/** -* Implements the iterator protocol `next` method. -* -* @returns iterator protocol-compliant object -*/ -function next(): any { - return { - 'value': 1.0, - 'done': false - }; -} - -/** -* Callback function. -* -* @param i - current array index -* @returns return value -*/ -function clbk( i: number ): number { - return i; -} - - -// TESTS // - -// The function returns an array or typed array... -{ - filledarrayBy(); // $ExpectType ArrayOrTypedArray - filledarrayBy( 'float32' ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( 10, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( 10, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( 10, 'int32', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( 10, 'int32', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const x = new Float64Array( 10 ); - filledarrayBy( x, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( x, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( x, 'uint8', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( x, 'uint8', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const y = [ 2.0, 2.0, 2.0 ]; - filledarrayBy( y, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( y, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( y, 'float64', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( y, 'float64', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const it = iterator(); - filledarrayBy( it, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( it, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( it, 'uint8c', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( it, 'uint8c', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const buf = new ArrayBuffer( 32 ); - filledarrayBy( buf, clbk ); // $ExpectType RealOrComplexTypedArray | BooleanArray - filledarrayBy( buf, clbk, {} ); // $ExpectType RealOrComplexTypedArray | BooleanArray - - filledarrayBy( buf, 'uint32', clbk ); // $ExpectType RealOrComplexTypedArray | BooleanArray - filledarrayBy( buf, 'uint32', clbk, {} ); // $ExpectType RealOrComplexTypedArray | BooleanArray - - filledarrayBy( buf, 8, clbk ); // $ExpectType RealOrComplexTypedArray | BooleanArray - filledarrayBy( buf, 8, clbk, {} ); // $ExpectType RealOrComplexTypedArray | BooleanArray - - filledarrayBy( buf, 8, 'uint16', clbk ); // $ExpectType RealOrComplexTypedArray | BooleanArray - filledarrayBy( buf, 8, 'uint16', clbk, {} ); // $ExpectType RealOrComplexTypedArray | BooleanArray - - filledarrayBy( buf, 8, 2, clbk ); // $ExpectType RealOrComplexTypedArray | BooleanArray - filledarrayBy( buf, 8, 2, clbk, {} ); // $ExpectType RealOrComplexTypedArray | BooleanArray - - filledarrayBy( buf, 8, 2, 'int16', clbk ); // $ExpectType RealOrComplexTypedArray | BooleanArray - filledarrayBy( buf, 8, 2, 'int16', clbk, {} ); // $ExpectType RealOrComplexTypedArray | BooleanArray -} - -// The compiler throws an error if a callback function argument is not a function... -{ - filledarrayBy( 'float64', '5' ); // $ExpectError - filledarrayBy( 'float64', 1.0 ); // $ExpectError - filledarrayBy( 'float64', false ); // $ExpectError - filledarrayBy( 'float64', true ); // $ExpectError - filledarrayBy( 'float64', null ); // $ExpectError - filledarrayBy( 'float64', undefined ); // $ExpectError - filledarrayBy( 'float64', [] ); // $ExpectError - filledarrayBy( 'float64', {} ); // $ExpectError - - filledarrayBy( 'float64', '5', {} ); // $ExpectError - filledarrayBy( 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( 'float64', false, {} ); // $ExpectError - filledarrayBy( 'float64', true, {} ); // $ExpectError - filledarrayBy( 'float64', null, {} ); // $ExpectError - filledarrayBy( 'float64', undefined, {} ); // $ExpectError - filledarrayBy( 'float64', [], {} ); // $ExpectError - filledarrayBy( 'float64', {}, {} ); // $ExpectError - - filledarrayBy( 10, '5' ); // $ExpectError - filledarrayBy( 10, 1.0 ); // $ExpectError - filledarrayBy( 10, false ); // $ExpectError - filledarrayBy( 10, true ); // $ExpectError - filledarrayBy( 10, null ); // $ExpectError - filledarrayBy( 10, undefined ); // $ExpectError - filledarrayBy( 10, [] ); // $ExpectError - filledarrayBy( 10, {} ); // $ExpectError - - filledarrayBy( 10, '5', {} ); // $ExpectError - filledarrayBy( 10, 1.0, {} ); // $ExpectError - filledarrayBy( 10, false, {} ); // $ExpectError - filledarrayBy( 10, true, {} ); // $ExpectError - filledarrayBy( 10, null, {} ); // $ExpectError - filledarrayBy( 10, undefined, {} ); // $ExpectError - filledarrayBy( 10, [], {} ); // $ExpectError - filledarrayBy( 10, {}, {} ); // $ExpectError - - filledarrayBy( 10, 'float64', '5' ); // $ExpectError - filledarrayBy( 10, 'float64', 1.0 ); // $ExpectError - filledarrayBy( 10, 'float64', false ); // $ExpectError - filledarrayBy( 10, 'float64', true ); // $ExpectError - filledarrayBy( 10, 'float64', null ); // $ExpectError - filledarrayBy( 10, 'float64', undefined ); // $ExpectError - filledarrayBy( 10, 'float64', [] ); // $ExpectError - filledarrayBy( 10, 'float64', {} ); // $ExpectError - - filledarrayBy( 10, 'float64', '5', {} ); // $ExpectError - filledarrayBy( 10, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( 10, 'float64', false, {} ); // $ExpectError - filledarrayBy( 10, 'float64', true, {} ); // $ExpectError - filledarrayBy( 10, 'float64', null, {} ); // $ExpectError - filledarrayBy( 10, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( 10, 'float64', [], {} ); // $ExpectError - filledarrayBy( 10, 'float64', {}, {} ); // $ExpectError - - const x = new Float64Array( 10 ); - filledarrayBy( x, '5' ); // $ExpectError - filledarrayBy( x, 1.0 ); // $ExpectError - filledarrayBy( x, false ); // $ExpectError - filledarrayBy( x, true ); // $ExpectError - filledarrayBy( x, null ); // $ExpectError - filledarrayBy( x, undefined ); // $ExpectError - filledarrayBy( x, [] ); // $ExpectError - filledarrayBy( x, {} ); // $ExpectError - - filledarrayBy( x, '5', {} ); // $ExpectError - filledarrayBy( x, 1.0, {} ); // $ExpectError - filledarrayBy( x, false, {} ); // $ExpectError - filledarrayBy( x, true, {} ); // $ExpectError - filledarrayBy( x, null, {} ); // $ExpectError - filledarrayBy( x, undefined, {} ); // $ExpectError - filledarrayBy( x, [], {} ); // $ExpectError - filledarrayBy( x, {}, {} ); // $ExpectError - - filledarrayBy( x, 'float64', '5' ); // $ExpectError - filledarrayBy( x, 'float64', 1.0 ); // $ExpectError - filledarrayBy( x, 'float64', false ); // $ExpectError - filledarrayBy( x, 'float64', true ); // $ExpectError - filledarrayBy( x, 'float64', null ); // $ExpectError - filledarrayBy( x, 'float64', undefined ); // $ExpectError - filledarrayBy( x, 'float64', [] ); // $ExpectError - filledarrayBy( x, 'float64', {} ); // $ExpectError - - filledarrayBy( x, 'float64', '5', {} ); // $ExpectError - filledarrayBy( x, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( x, 'float64', false, {} ); // $ExpectError - filledarrayBy( x, 'float64', true, {} ); // $ExpectError - filledarrayBy( x, 'float64', null, {} ); // $ExpectError - filledarrayBy( x, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( x, 'float64', [], {} ); // $ExpectError - filledarrayBy( x, 'float64', {}, {} ); // $ExpectError - - const y = [ 2.0, 2.0, 2.0 ]; - filledarrayBy( y, '5' ); // $ExpectError - filledarrayBy( y, 1.0 ); // $ExpectError - filledarrayBy( y, false ); // $ExpectError - filledarrayBy( y, true ); // $ExpectError - filledarrayBy( y, null ); // $ExpectError - filledarrayBy( y, undefined ); // $ExpectError - filledarrayBy( y, [] ); // $ExpectError - filledarrayBy( y, {} ); // $ExpectError - - filledarrayBy( y, '5', {} ); // $ExpectError - filledarrayBy( y, 1.0, {} ); // $ExpectError - filledarrayBy( y, false, {} ); // $ExpectError - filledarrayBy( y, true, {} ); // $ExpectError - filledarrayBy( y, null, {} ); // $ExpectError - filledarrayBy( y, undefined, {} ); // $ExpectError - filledarrayBy( y, [], {} ); // $ExpectError - filledarrayBy( y, {}, {} ); // $ExpectError - - filledarrayBy( y, 'float64', '5' ); // $ExpectError - filledarrayBy( y, 'float64', 1.0 ); // $ExpectError - filledarrayBy( y, 'float64', false ); // $ExpectError - filledarrayBy( y, 'float64', true ); // $ExpectError - filledarrayBy( y, 'float64', null ); // $ExpectError - filledarrayBy( y, 'float64', undefined ); // $ExpectError - filledarrayBy( y, 'float64', [] ); // $ExpectError - filledarrayBy( y, 'float64', {} ); // $ExpectError - - filledarrayBy( y, 'float64', '5', {} ); // $ExpectError - filledarrayBy( y, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( y, 'float64', false, {} ); // $ExpectError - filledarrayBy( y, 'float64', true, {} ); // $ExpectError - filledarrayBy( y, 'float64', null, {} ); // $ExpectError - filledarrayBy( y, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( y, 'float64', [], {} ); // $ExpectError - filledarrayBy( y, 'float64', {}, {} ); // $ExpectError - - const it = iterator(); - filledarrayBy( it, '5' ); // $ExpectError - filledarrayBy( it, 1.0 ); // $ExpectError - filledarrayBy( it, false ); // $ExpectError - filledarrayBy( it, true ); // $ExpectError - filledarrayBy( it, null ); // $ExpectError - filledarrayBy( it, undefined ); // $ExpectError - filledarrayBy( it, [] ); // $ExpectError - filledarrayBy( it, {} ); // $ExpectError - - filledarrayBy( it, '5', {} ); // $ExpectError - filledarrayBy( it, 1.0, {} ); // $ExpectError - filledarrayBy( it, false, {} ); // $ExpectError - filledarrayBy( it, true, {} ); // $ExpectError - filledarrayBy( it, null, {} ); // $ExpectError - filledarrayBy( it, undefined, {} ); // $ExpectError - filledarrayBy( it, [], {} ); // $ExpectError - filledarrayBy( it, {}, {} ); // $ExpectError - - filledarrayBy( it, 'float64', '5' ); // $ExpectError - filledarrayBy( it, 'float64', 1.0 ); // $ExpectError - filledarrayBy( it, 'float64', false ); // $ExpectError - filledarrayBy( it, 'float64', true ); // $ExpectError - filledarrayBy( it, 'float64', null ); // $ExpectError - filledarrayBy( it, 'float64', undefined ); // $ExpectError - filledarrayBy( it, 'float64', [] ); // $ExpectError - filledarrayBy( it, 'float64', {} ); // $ExpectError - - filledarrayBy( it, 'float64', '5', {} ); // $ExpectError - filledarrayBy( it, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( it, 'float64', false, {} ); // $ExpectError - filledarrayBy( it, 'float64', true, {} ); // $ExpectError - filledarrayBy( it, 'float64', null, {} ); // $ExpectError - filledarrayBy( it, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( it, 'float64', [], {} ); // $ExpectError - filledarrayBy( it, 'float64', {}, {} ); // $ExpectError - - const buf = new ArrayBuffer( 32 ); - filledarrayBy( buf, '5' ); // $ExpectError - filledarrayBy( buf, 1.0 ); // $ExpectError - filledarrayBy( buf, false ); // $ExpectError - filledarrayBy( buf, true ); // $ExpectError - filledarrayBy( buf, null ); // $ExpectError - filledarrayBy( buf, undefined ); // $ExpectError - filledarrayBy( buf, [] ); // $ExpectError - filledarrayBy( buf, {} ); // $ExpectError - - filledarrayBy( buf, '5', {} ); // $ExpectError - filledarrayBy( buf, 1.0, {} ); // $ExpectError - filledarrayBy( buf, false, {} ); // $ExpectError - filledarrayBy( buf, true, {} ); // $ExpectError - filledarrayBy( buf, null, {} ); // $ExpectError - filledarrayBy( buf, undefined, {} ); // $ExpectError - filledarrayBy( buf, [], {} ); // $ExpectError - filledarrayBy( buf, {}, {} ); // $ExpectError - - filledarrayBy( buf, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 'float64', false ); // $ExpectError - filledarrayBy( buf, 'float64', true ); // $ExpectError - filledarrayBy( buf, 'float64', null ); // $ExpectError - filledarrayBy( buf, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 'float64', {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5' ); // $ExpectError - filledarrayBy( buf, 8, 1.0 ); // $ExpectError - filledarrayBy( buf, 8, false ); // $ExpectError - filledarrayBy( buf, 8, true ); // $ExpectError - filledarrayBy( buf, 8, null ); // $ExpectError - filledarrayBy( buf, 8, undefined ); // $ExpectError - filledarrayBy( buf, 8, [] ); // $ExpectError - filledarrayBy( buf, 8, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, false, {} ); // $ExpectError - filledarrayBy( buf, 8, true, {} ); // $ExpectError - filledarrayBy( buf, 8, null, {} ); // $ExpectError - filledarrayBy( buf, 8, undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, [], {} ); // $ExpectError - filledarrayBy( buf, 8, {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 8, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 'float64', false ); // $ExpectError - filledarrayBy( buf, 8, 'float64', true ); // $ExpectError - filledarrayBy( buf, 8, 'float64', null ); // $ExpectError - filledarrayBy( buf, 8, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 8, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 8, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 8, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, '5' ); // $ExpectError - filledarrayBy( buf, 8, 2, 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 2, false ); // $ExpectError - filledarrayBy( buf, 8, 2, true ); // $ExpectError - filledarrayBy( buf, 8, 2, null ); // $ExpectError - filledarrayBy( buf, 8, 2, undefined ); // $ExpectError - filledarrayBy( buf, 8, 2, [] ); // $ExpectError - filledarrayBy( buf, 8, 2, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, false, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, true, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, null, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, [], {} ); // $ExpectError - filledarrayBy( buf, 8, 2, {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', false ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', true ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', null ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', {}, {} ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid length, typed array, array-like object, `ArrayBuffer`, or iterable argument... -{ - filledarrayBy( false, clbk ); // $ExpectError - filledarrayBy( true, clbk ); // $ExpectError - filledarrayBy( null, clbk ); // $ExpectError - filledarrayBy( {}, clbk ); // $ExpectError - - filledarrayBy( false, clbk, {} ); // $ExpectError - filledarrayBy( true, clbk, {} ); // $ExpectError - filledarrayBy( null, clbk, {} ); // $ExpectError - filledarrayBy( {}, clbk, {} ); // $ExpectError - - filledarrayBy( false, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 'float64', clbk ); // $ExpectError - - filledarrayBy( false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, clbk ); // $ExpectError - filledarrayBy( 1.0, 8, clbk ); // $ExpectError - filledarrayBy( false, 8, clbk ); // $ExpectError - filledarrayBy( true, 8, clbk ); // $ExpectError - filledarrayBy( null, 8, clbk ); // $ExpectError - filledarrayBy( undefined, 8, clbk ); // $ExpectError - filledarrayBy( [], 8, clbk ); // $ExpectError - filledarrayBy( {}, 8, clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, clbk ); // $ExpectError - - filledarrayBy( '5', 8, clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, clbk, {} ); // $ExpectError - filledarrayBy( false, 8, clbk, {} ); // $ExpectError - filledarrayBy( true, 8, clbk, {} ); // $ExpectError - filledarrayBy( null, 8, clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, clbk, {} ); // $ExpectError - filledarrayBy( [], 8, clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 'float64', clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( false, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( [], 8, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 'float64', clbk ); // $ExpectError - - filledarrayBy( '5', 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 2, clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 2, clbk ); // $ExpectError - filledarrayBy( false, 8, 2, clbk ); // $ExpectError - filledarrayBy( true, 8, 2, clbk ); // $ExpectError - filledarrayBy( null, 8, 2, clbk ); // $ExpectError - filledarrayBy( undefined, 8, 2, clbk ); // $ExpectError - filledarrayBy( [], 8, 2, clbk ); // $ExpectError - filledarrayBy( {}, 8, 2, clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, clbk ); // $ExpectError - - filledarrayBy( '5', 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( false, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( [], 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, 'float64', clbk ); // $ExpectError - - filledarrayBy( '5', 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a byte offset argument which is not a number... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, false, clbk ); // $ExpectError - filledarrayBy( buf, true, clbk ); // $ExpectError - filledarrayBy( buf, null, clbk ); // $ExpectError - filledarrayBy( buf, [], clbk ); // $ExpectError - filledarrayBy( buf, {}, clbk ); // $ExpectError - - filledarrayBy( buf, false, clbk, {} ); // $ExpectError - filledarrayBy( buf, true, clbk, {} ); // $ExpectError - filledarrayBy( buf, null, clbk, {} ); // $ExpectError - filledarrayBy( buf, [], clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, clbk, {} ); // $ExpectError - - filledarrayBy( buf, '5', 'float64', clbk ); // $ExpectError - filledarrayBy( buf, false, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, true, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, null, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, [], 'float64', clbk ); // $ExpectError - filledarrayBy( buf, {}, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, '5', 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( buf, false, 2, clbk ); // $ExpectError - filledarrayBy( buf, true, 2, clbk ); // $ExpectError - filledarrayBy( buf, null, 2, clbk ); // $ExpectError - filledarrayBy( buf, [], 2, clbk ); // $ExpectError - filledarrayBy( buf, {}, 2, clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, clbk ); // $ExpectError - - filledarrayBy( buf, false, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, clbk, {} ); // $ExpectError - - filledarrayBy( buf, '5', 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, false, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, true, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, null, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, undefined, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, [], 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, {}, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, '5', 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, false, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, undefined, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a view length argument which is not a number... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, 8, false, clbk ); // $ExpectError - filledarrayBy( buf, 8, true, clbk ); // $ExpectError - filledarrayBy( buf, 8, null, clbk ); // $ExpectError - filledarrayBy( buf, 8, [], clbk ); // $ExpectError - filledarrayBy( buf, 8, {}, clbk ); // $ExpectError - - filledarrayBy( buf, 8, false, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, true, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, null, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, [], clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, {}, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, clbk, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5', 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, false, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, true, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, null, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, [], 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, {}, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, 8, '5', 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, [], 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, {}, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided too many arguments... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, 8, 2, 'float64', 1, clbk, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 997a381..0000000 --- a/examples/index.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ).factory; -var dtypes = require( '@stdlib/array-typed-real-dtypes' ); -var filledarrayBy = require( './../lib' ); - -// Create a pseudorandom number generator: -var rand = discreteUniform( 0, 100 ); - -// Get a list of array data types: -var dt = dtypes(); - -// Generate filled arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = filledarrayBy( 10, dt[ i ], rand ); - console.log( arr ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 606ef7c..fde6688 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, RealOrComplexTypedArray, BooleanArray, DataType } from '@stdlib/types/array'; import { IterableIterator } from '@stdlib/types/iter'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..6f157fa --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.3-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.3-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@v0.0.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.3-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.3-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.3-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-ctors@v0.3.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill-by@v0.2.3-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled-by@v0.2.3-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.2.3-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.3-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@v0.2.3-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.4.1-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";var v=f(),g=j.get("dtypes.default");function c(){var f,j,c,b,y,x,u,E;if(0===(j=arguments.length))return new(y=d(g))(0);if(r(c=arguments[0])){if(j>1)throw new TypeError(w("00h05"));if(null===(y=d(c)))throw new TypeError(w("00h2Y",c));return new y(0)}if(j<2)throw new TypeError(w("00h05"));if(h(arguments[j-=1]))if(h(arguments[j-1])){if(f=arguments[j],b=arguments[j-=1],0===j)throw new TypeError(w("00h05"))}else b=arguments[j];else{if(!(j>=2))throw new TypeError(w("00h05"));if(f=arguments[j],!h(b=arguments[j-=1]))throw new TypeError(w("00h2b",b))}if((j-=1)>=0&&r(arguments[j])?(c=arguments[j],j-=1):c=g,null===(y=d(c)))throw new TypeError(w("00h2Y",c));if("generic"===c){if(E=arguments[0],0===j){if(e(E)?u=E:i(E)&&(u=E.length),void 0!==u)return m(u,b,f);if(n(E))throw new Error(w("00h04"));if(o(E)){if(!1===v)throw new TypeError(w("00h2Z",E));if(!h(E[p]))throw new TypeError(w("00h2a",E));if(E=E[p](),!h(E.next))throw new TypeError(w("00h2a",E));return function(r,e,t){var s,i;for(s=[],i=-1;!r.next().done;)i+=1,s.push(e.call(t,i));return s}(E,b,f)}throw new TypeError(w("00h2a",E))}if(n(E))throw new Error(w("00h04"));throw new TypeError(w("00h2a",E))}if(0===j)if(i(E=arguments[0]))x=new y(E.length);else if(n(E))x=new y(E);else if(e(E))x=new y(E);else{if(!o(E))throw new TypeError(w("00h2a",E));if(!1===v)throw new TypeError(w("00h2Z",E));if(!h(E[p]))throw new TypeError(w("00h2a",E));if(E=E[p](),!h(E.next))throw new TypeError(w("00h2a",E));x=new y(a(E))}else x=1===j?new y(arguments[0],arguments[1]):new y(arguments[0],arguments[1],arguments[2]);return x.length>0&&(t(c)||s(c)?function(r,e,t){var s;for(s=0;s\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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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( format('00h05') );\n\t\t}\n\t\tctor = ctors( dtype );\n\t\tif ( ctor === null ) {\n\t\t\tthrow new TypeError( format( '00h2Y', 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( format('00h05') );\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( format('00h05') );\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( '00h2b', clbk ) );\n\t\t}\n\t}\n\t// If we 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( format('00h05') );\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( '00h2Y', 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( format('00h04') );\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( '00h2Z', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00h2a', 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( '00h2a', 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( '00h2a', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format('00h04') );\n\t\t}\n\t\tthrow new TypeError( format( '00h2a', 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( '00h2Z', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00h2a', 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( '00h2a', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00h2a', 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\nexport default filledarrayBy;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","DEFAULT_DTYPE","defaults","get","filledarrayBy","thisArg","nargs","dtype","clbk","ctor","arr","len","arg","arguments","length","ctors","isString","TypeError","format","isFunction","isNonNegativeInteger","isCollection","filledArray","isArrayBuffer","Error","isObject","ITERATOR_SYMBOL","next","it","i","done","push","call","filledArrayIterator","iterLength","isComplexDataType","isBooleanDataType","set","filledAccessors","gfillBy","value","aidx"],"mappings":";;sjDA0CA,IAAIA,EAAsBC,IACtBC,EAAgBC,EAASC,IAAK,kBA2MlC,SAASC,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAKJ,GAAe,KAHfN,EAAQO,UAAUC,QAKjB,OAAO,IADPL,EAAOM,EAAOd,IACG,GAIlB,GAAKe,EADLT,EAAQM,UAAW,IACM,CAExB,GAAKP,EAAQ,EACZ,MAAM,IAAIW,UAAWC,EAAO,UAG7B,GAAc,QADdT,EAAOM,EAAOR,IAEb,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,OAAO,IAAIE,EAAM,EACjB,CAED,GAAKH,EAAQ,EACZ,MAAM,IAAIW,UAAWC,EAAO,UAM7B,GAAKC,EAAYN,UAHjBP,GAAS,IAKR,GAAKa,EAAYN,UAAWP,EAAM,KAMjC,GALAD,EAAUQ,UAAWP,GAErBE,EAAOK,UADPP,GAAS,GAIM,IAAVA,EACJ,MAAM,IAAIW,UAAWC,EAAO,eAI7BV,EAAOK,UAAWP,OAIf,MAAKA,GAAS,GAUlB,MAAM,IAAIW,UAAWC,EAAO,UAN5B,GAHAb,EAAUQ,UAAWP,IAGfa,EADNX,EAAOK,UADPP,GAAS,IAGR,MAAM,IAAIW,UAAWC,EAAQ,QAASV,GAMvC,CAUD,IARAF,GAAS,IACK,GAAKU,EAAUH,UAAWP,KACvCC,EAAQM,UAAWP,GACnBA,GAAS,GAETC,EAAQN,EAGK,QADdQ,EAAOM,EAAOR,IAEb,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,GAAe,YAAVA,EAAsB,CAE1B,GADAK,EAAMC,UAAW,GACF,IAAVP,EAAc,CAMlB,GALKc,EAAsBR,GAC1BD,EAAMC,EACKS,EAAcT,KACzBD,EAAMC,EAAIE,aAEE,IAARH,EACJ,OAAOW,EAAaX,EAAKH,EAAMH,GAEhC,GAAKkB,EAAeX,GACnB,MAAM,IAAIY,MAAON,EAAO,UAEzB,GAAKO,EAAUb,GAAQ,CACtB,IAA6B,IAAxBb,EACJ,MAAM,IAAIkB,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAYP,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLP,EAAYP,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvC,OAvSJ,SAA8BgB,EAAIpB,EAAMH,GACvC,IAAIK,EACAmB,EAKJ,IAFAnB,EAAM,GACNmB,GAAK,GAEAD,EAAGD,OACAG,MAGPD,GAAK,EACLnB,EAAIqB,KAAMvB,EAAKwB,KAAM3B,EAASwB,IAE/B,OAAOnB,CACR,CAuRWuB,CAAqBrB,EAAKJ,EAAMH,EACvC,CACD,MAAM,IAAIY,UAAWC,EAAQ,QAASN,GACzC,CAAS,GAAKW,EAAeX,GAC1B,MAAM,IAAIY,MAAON,EAAO,UAEzB,MAAM,IAAID,UAAWC,EAAQ,QAASN,GACtC,CACD,GAAe,IAAVN,EAEJ,GAAKe,EADLT,EAAMC,UAAW,IAEhBH,EAAM,IAAID,EAAMG,EAAIE,aACd,GAAKS,EAAeX,GAC1BF,EAAM,IAAID,EAAMG,QACV,GAAKQ,EAAsBR,GACjCF,EAAM,IAAID,EAAMG,OACV,KAAKa,EAAUb,GAarB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAZtC,IAA6B,IAAxBb,EACJ,MAAM,IAAIkB,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAYP,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLP,EAAYP,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvCF,EAAM,IAAID,EAAMyB,EAAYtB,GAG5B,MAEDF,EADqB,IAAVJ,EACL,IAAIG,EAAMI,UAAU,GAAIA,UAAU,IAElC,IAAIJ,EAAMI,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKH,EAAII,OAAS,IACZqB,EAAmB5B,IAAW6B,EAAmB7B,GAjTxD,SAA0BG,EAAKF,EAAMH,GACpC,IAAIwB,EACJ,IAAMA,EAAI,EAAGA,EAAInB,EAAII,OAAQe,IAC5BnB,EAAI2B,IAAK7B,EAAKwB,KAAM3B,EAASwB,GAAKA,EAGpC,CA4SGS,CAAiB5B,EAAKF,EAAMH,GAE5BkC,EAAS7B,EAAII,OAAQJ,EAAK,GAe5B,SAAmB8B,EAAOC,GACzB,OAAOjC,EAAKwB,KAAM3B,EAASoC,EAC3B,KAdM/B,CAeR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d115cf0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,192 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -/** -* Create a filled array according to a provided callback function. -* -* @module @stdlib/array-filled-by -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* var arr = filledarrayBy(); -* // returns -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'generic', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( [ 0.5, 0.5 ], clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1; -* } -* -* var arr = filledarrayBy( [ 5, -3 ], 'int32', clbk ); -* // returns [ 1, 1 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk1() { -* return 10; -* } -* -* function clbk2() { -* return 1.0; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, clbk2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk1() { -* return 1.0; -* } -* -* function clbk2() { -* return 2; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, 'uint32', clbk2 ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 'float32', clbk ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, clbk ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, 'int32', clbk ); -* // returns [ 1, 1 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 32b6545..0000000 --- a/lib/main.js +++ /dev/null @@ -1,416 +0,0 @@ -/** -* @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 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' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var ctors = require( '@stdlib/array-ctors' ); -var gfillBy = require( '@stdlib/blas-ext-base-gfill-by' ); -var filledArray = require( '@stdlib/array-base-filled-by' ); -var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var iterLength = require( '@stdlib/iter-length' ); -var defaults = require( '@stdlib/array-defaults' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport(); -var DEFAULT_DTYPE = defaults.get( 'dtypes.default' ); - - -// FUNCTIONS // - -/** -* Creates a filled "generic" array from an iterator. -* -* @private -* @param {Iterable} it - iterator -* @param {Callback} clbk - callback function -* @param {*} thisArg - callback function execution context -* @returns {Array} filled array -*/ -function filledArrayIterator( it, clbk, thisArg ) { - var arr; - var i; - var v; - - arr = []; - i = -1; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - i += 1; - arr.push( clbk.call( thisArg, i ) ); - } - return arr; -} - -/** -* Fills an array exposing accessors for getting and setting array elements. -* -* @private -* @param {Collection} arr - input array -* @param {Callback} clbk - callback function -* @param {*} thisArg - callback function execution context -* @returns {Collection} input array -*/ -function filledAccessors( arr, clbk, thisArg ) { - var i; - for ( i = 0; i < arr.length; i++ ) { - arr.set( clbk.call( thisArg, i ), i ); - } - return arr; -} - - -// MAIN // - -/** -* Creates a filled array according to a provided callback function. -* -* @param {(NonNegativeInteger|TypedArray|ArrayLikeObject|ArrayBuffer|Iterable)} [arg] - a length, typed array, array-like object, buffer, or iterable -* @param {NonNegativeInteger} [byteOffset=0] - byte offset -* @param {NonNegativeInteger} [length] - view length -* @param {string} [dtype="float64"] - data type -* @param {Callback} [clbk] - callback to invoke -* @param {*} [thisArg] - callback execution context -* @throws {TypeError} must provide a recognized data type -* @throws {TypeError} must provide a length, typed array, array-like object, buffer, or iterable -* @throws {TypeError} callback argument must be a function. -* @throws {Error} creating a generic array from an `ArrayBuffer` is not supported -* @returns {(TypedArray|Array)} array or typed array -* -* @example -* var arr = filledarrayBy(); -* // returns -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'generic', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( [ 0.5, 0.5 ], clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1; -* } -* -* var arr = filledarrayBy( [ 5, -3 ], 'int32', clbk ); -* // returns [ 1, 1 ] -* -* @example -* function clbk1() { -* return 10; -* } -* -* function clbk2() { -* return 1.0; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, clbk2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk1() { -* return 1.0; -* } -* -* function clbk2() { -* return 2; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, 'uint32', clbk2 ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 'float32', clbk ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, clbk ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, 'int32', clbk ); -* // returns [ 1, 1 ] -*/ -function filledarrayBy() { - var thisArg; - var nargs; - var dtype; - var clbk; - var ctor; - var arr; - var len; - var arg; - - nargs = arguments.length; - - // If we weren't provided any arguments, return an empty array... - if ( nargs === 0 ) { - ctor = ctors( DEFAULT_DTYPE ); - return new ctor( 0 ); - } - // Check if we were provided a dtype as the first argument... - dtype = arguments[ 0 ]; - if ( isString( dtype ) ) { - // Invoking this function with arguments `f( dtype, clbk[, thisArg] )` is not allowed (otherwise, we'd need to also allow `f( clbk[, thisArg] )`)... - if ( nargs > 1 ) { - throw new TypeError( format('00h05') ); - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '00h2Y', dtype ) ); - } - // Return an empty array having the specified dtype: - return new ctor( 0 ); - } - // For all other supported invocations, we need at least two arguments... - if ( nargs < 2 ) { - throw new TypeError( format('00h05') ); - } - // At this point, we need to do some argument juggling... - nargs -= 1; // henceforth, the number of available arguments is `nargs+1` - - // Determine whether the last argument is a callback or "this" context... - if ( isFunction( arguments[ nargs ] ) ) { - // 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... - if ( isFunction( arguments[ nargs-1 ] ) ) { - thisArg = arguments[ nargs ]; - nargs -= 1; - clbk = arguments[ nargs ]; - - // Check if we were provided only a callback and a "this" context.. - if ( nargs === 0 ) { - throw new TypeError( format('00h05') ); - } - } else { - // "this" context is left undefined... - clbk = arguments[ nargs ]; - } - } - // 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... - else if ( nargs >= 2 ) { - thisArg = arguments[ nargs ]; - nargs -= 1; - clbk = arguments[ nargs ]; - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '00h2b', clbk ) ); - } - } - // If we were only provided 2 arguments and the last argument was not a function, we've been provided an insufficient number of arguments... - else { - throw new TypeError( format('00h05') ); - } - // Now that we've processed the callback arguments, let's continue working backward to see if we've been provided a `dtype` argument... - nargs -= 1; - if ( nargs >= 0 && isString( arguments[ nargs ] ) ) { - dtype = arguments[ nargs ]; - nargs -= 1; - } else { - dtype = DEFAULT_DTYPE; - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '00h2Y', dtype ) ); - } - // At this point, we've resolved the output array data type, and now we can actually create the output array... - if ( dtype === 'generic' ) { - arg = arguments[ 0 ]; - if ( nargs === 0 ) { - if ( isNonNegativeInteger( arg ) ) { - len = arg; - } else if ( isCollection( arg ) ) { - len = arg.length; - } - if ( len !== void 0 ) { - return filledArray( len, clbk, thisArg ); - } - if ( isArrayBuffer( arg ) ) { - throw new Error( format('00h04') ); - } - if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( '00h2Z', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00h2a', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00h2a', arg ) ); - } - return filledArrayIterator( arg, clbk, thisArg ); - } - throw new TypeError( format( '00h2a', arg ) ); - } else if ( isArrayBuffer( arg ) ) { - throw new Error( format('00h04') ); - } - throw new TypeError( format( '00h2a', arg ) ); - } - if ( nargs === 0 ) { // length || array-like || ArrayBuffer || iterable - arg = arguments[ 0 ]; - if ( isCollection( arg ) ) { - arr = new ctor( arg.length ); - } else if ( isArrayBuffer( arg ) ) { - arr = new ctor( arg ); - } else if ( isNonNegativeInteger( arg ) ) { - arr = new ctor( arg ); - } else if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( '00h2Z', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00h2a', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00h2a', arg ) ); - } - arr = new ctor( iterLength( arg ) ); - } else { - throw new TypeError( format( '00h2a', arg ) ); - } - } else if ( nargs === 1 ) { - arr = new ctor( arguments[0], arguments[1] ); // (ArrayBuffer, byteOffset) - } else { - arr = new ctor( arguments[0], arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset, length) - } - if ( arr.length > 0 ) { - if ( isComplexDataType( dtype ) || isBooleanDataType( dtype ) ) { - filledAccessors( arr, clbk, thisArg ); - } else { - gfillBy( arr.length, arr, 1, callback ); - } - } - return arr; - - /** - * Callback which wraps a provided callback and is invoked for each array element. - * - * @private - * @param {*} value - element value - * @param {NonNegativeInteger} aidx - array index - * @param {NonNegativeInteger} sidx - strided index - * @param {Collection} array - input array/collection - * @returns {*} callback return value - */ - function callback( value, aidx ) { - return clbk.call( thisArg, aidx ); - } -} - - -// EXPORTS // - -module.exports = filledarrayBy; diff --git a/package.json b/package.json index a1a5078..026d062 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.3.1", "description": "Create a filled array according to a provided callback function.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,75 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-assert-is-boolean-data-type": "^0.0.2", - "@stdlib/array-base-assert-is-complex-floating-point-data-type": "^0.2.2", - "@stdlib/array-base-filled-by": "^0.2.3", - "@stdlib/array-ctors": "^0.3.1", - "@stdlib/array-defaults": "^0.4.1", - "@stdlib/assert-has-iterator-symbol-support": "^0.2.3", - "@stdlib/assert-is-arraybuffer": "^0.2.3", - "@stdlib/assert-is-collection": "^0.2.3", - "@stdlib/assert-is-function": "^0.2.3", - "@stdlib/assert-is-nonnegative-integer": "^0.2.3", - "@stdlib/assert-is-object": "^0.2.3", - "@stdlib/assert-is-string": "^0.2.3", - "@stdlib/blas-ext-base-gfill-by": "^0.2.3", - "@stdlib/iter-length": "^0.2.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3", - "@stdlib/symbol-iterator": "^0.2.3", - "@stdlib/types": "^0.5.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3" - }, - "devDependencies": { - "@stdlib/array-bool": "^0.1.2", - "@stdlib/array-buffer": "^0.2.3", - "@stdlib/array-complex128": "^0.3.2", - "@stdlib/array-complex64": "^0.3.2", - "@stdlib/array-float32": "^0.2.3", - "@stdlib/array-float64": "^0.2.3", - "@stdlib/array-int16": "^0.2.3", - "@stdlib/array-int32": "^0.2.3", - "@stdlib/array-int8": "^0.2.3", - "@stdlib/array-typed-real-dtypes": "^0.2.3", - "@stdlib/array-uint16": "^0.2.3", - "@stdlib/array-uint32": "^0.2.3", - "@stdlib/array-uint8": "^0.2.3", - "@stdlib/array-uint8c": "^0.2.3", - "@stdlib/assert-instance-of": "^0.3.1", - "@stdlib/assert-is-array": "^0.2.3", - "@stdlib/assert-is-typed-array": "^0.2.3", - "@stdlib/assert-is-typed-array-like": "^0.2.3", - "@stdlib/complex-float32-ctor": "^0.1.1", - "@stdlib/complex-float64-ctor": "^0.1.2", - "@stdlib/iter-constant": "^0.2.3", - "@stdlib/math-base-special-pow": "^0.3.1", - "@stdlib/random-base-discrete-uniform": "^0.2.2", - "@stdlib/strided-base-reinterpret-boolean": "^0.0.3", - "@stdlib/strided-base-reinterpret-complex128": "^0.2.3", - "@stdlib/strided-base-reinterpret-complex64": "^0.2.2", - "@stdlib/utils-constant-function": "^0.2.3", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.3" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..dabf69c --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index ca0cf25..0000000 --- a/test/test.js +++ /dev/null @@ -1,4397 +0,0 @@ -/** -* @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. -*/ - -/* eslint-disable max-len */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -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' ); -var iterConstant = require( '@stdlib/iter-constant' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var filledarrayBy = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': !hasIteratorSymbolSupport() -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof filledarrayBy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if only provided callback arguments', function test( t ) { - t.throws( clbk1, TypeError, 'throws an error' ); - t.throws( clbk2, TypeError, 'throws an error' ); - t.throws( clbk3, TypeError, 'throws an error' ); - t.end(); - - function clbk1() { - filledarrayBy( constantFunction( 1.0 ) ); - } - - function clbk2() { - filledarrayBy( constantFunction( 1.0 ), {} ); - } - - function clbk3() { - filledarrayBy( constantFunction( 1.0 ), constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (only argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (typed array; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (array-like object)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (array-like object; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 8 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 8 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, 1, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (iterator)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( iterConstant( 1.0 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (iterator; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( iterConstant( 1.0 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if only provided data type and callback arguments', function test( t ) { - t.throws( clbk1, TypeError, 'throws an error' ); - t.throws( clbk2, TypeError, 'throws an error' ); - t.throws( clbk3, TypeError, 'throws an error' ); - t.end(); - - function clbk1() { - filledarrayBy( 'float64', constantFunction( 1.0 ) ); - } - - function clbk2() { - filledarrayBy( 'float64', constantFunction( 1.0 ), {} ); - } - - function clbk3() { - filledarrayBy( 'float64', constantFunction( 1.0 ), constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (array-like object)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (array-like object; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, 1, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, 1, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (no iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (no iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (non-function iterator symbol property)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (non-function iterator symbol property; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (`next` property is not a function)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ) ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (`next` property is not a function; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ), {} ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (no iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (no iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (non-function iterator symbol property)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (non-function iterator symbol property; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (`next` property is not a function)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ) ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (`next` property is not a function; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ), {} ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 1, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 1, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function returns a filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - arr = filledarrayBy(); - - t.strictEqual( instanceOf( arr, Float64Array ), 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=float64)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - arr = filledarrayBy( 'float64' ); - - t.strictEqual( instanceOf( arr, Float64Array ), 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=float32)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( 0 ); - arr = filledarrayBy( 'float32' ); - - t.strictEqual( instanceOf( arr, Float32Array ), 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=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; - - expected = new Complex128Array( 0 ); - arr = filledarrayBy( 'complex128' ); - - t.strictEqual( instanceOf( arr, Complex128Array ), 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=complex64)', function test( t ) { - var expected; - var arr; - - expected = new Complex64Array( 0 ); - arr = filledarrayBy( 'complex64' ); - - t.strictEqual( instanceOf( arr, Complex64Array ), 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=int32)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( 0 ); - arr = filledarrayBy( 'int32' ); - - t.strictEqual( instanceOf( arr, Int32Array ), 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=uint32)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( 0 ); - arr = filledarrayBy( 'uint32' ); - - t.strictEqual( instanceOf( arr, Uint32Array ), 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=int16)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( 0 ); - arr = filledarrayBy( 'int16' ); - - t.strictEqual( instanceOf( arr, Int16Array ), 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=uint16)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( 0 ); - arr = filledarrayBy( 'uint16' ); - - t.strictEqual( instanceOf( arr, Uint16Array ), 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=int8)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( 0 ); - arr = filledarrayBy( 'int8' ); - - t.strictEqual( instanceOf( arr, Int8Array ), 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=uint8)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( 0 ); - arr = filledarrayBy( 'uint8' ); - - t.strictEqual( instanceOf( arr, Uint8Array ), 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=uint8c)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( 0 ); - arr = filledarrayBy( 'uint8c' ); - - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), 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=generic)', function test( t ) { - var expected; - var arr; - - expected = []; - arr = filledarrayBy( 'generic' ); - - t.strictEqual( instanceOf( arr, Array ), 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 (default, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, length=0)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array(); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 0, clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, clbk, ctx ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (default, length; thisArg=function)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, clbk, context ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this(); // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } - - function context() { - ctx.count += 1; - } -}); - -tape( 'the function returns a filled array (dtype=float64, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, 'float64', clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, length; thisArg=function)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, 'float64', clbk, context ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this(); // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } - - function context() { - ctx.count += 1; - } -}); - -tape( 'the function returns a filled array (dtype=float32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, 'float32', clbk ); - - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - 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; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = filledarrayBy( 5, 'complex128', clbk ); - - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = filledarrayBy( 5, 'complex64', clbk ); - - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int32Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int32', clbk ); - - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint32Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint32', clbk ); - - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int16Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int16', clbk ); - - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint16', clbk ); - - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int8Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int8', clbk ); - - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint8', clbk ); - - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint8c', clbk ); - - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = [ 1, 1, 1, 1, 1 ]; - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'generic', clbk ); - - t.strictEqual( instanceOf( arr, Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - 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; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = [ 1.0, 2.0 ]; - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = [ 1.0, 2.0 ]; - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int32', clbk ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, typed array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, typed array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - 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; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = new Float64Array( [ 1.0, 2.0 ] ); - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = new Float64Array( [ 1.0, 2.0 ] ); - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (default, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - 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; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer, byteoffset; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer, byteoffset; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - 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; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 48 ); - out = filledarrayBy( buf, 16, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 24 ); - out = filledarrayBy( buf, 8, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int32', clbk ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint8c', clbk ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - 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; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 64 ); - out = filledarrayBy( buf, 16, 2, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset, length)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 1, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 1, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled array (default, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, iterator; thisArg)', opts, function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - ctx = { - 'count': 0 - }; - indices = []; - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, iterator; thisArg)', opts, function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - ctx = { - 'count': 0 - }; - indices = []; - out = filledarrayBy( arr, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - 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; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = iterConstant( new Complex128( 3.0, 3.0 ), { - 'iter': 2 - }); - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = iterConstant( new Complex64( 3.0, 3.0 ), { - 'iter': 2 - }); - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); From 02611f76f69a9ce87835f0824d54b1a25fb3a82e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 15 Aug 2026 02:59:42 +0000 Subject: [PATCH 115/117] Transform error messages --- lib/main.js | 38 +++++++++++++++++++------------------- package.json | 2 +- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/lib/main.js b/lib/main.js index d2128f5..32b6545 100644 --- a/lib/main.js +++ b/lib/main.js @@ -35,7 +35,7 @@ var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-supp var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); var iterLength = require( '@stdlib/iter-length' ); var defaults = require( '@stdlib/array-defaults' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -266,18 +266,18 @@ function filledarrayBy() { if ( isString( dtype ) ) { // Invoking this function with arguments `f( dtype, clbk[, thisArg] )` is not allowed (otherwise, we'd need to also allow `f( clbk[, thisArg] )`)... if ( nargs > 1 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format('00h05') ); } ctor = ctors( dtype ); if ( ctor === null ) { - throw new TypeError( format( 'invalid argument. Must provide a recognized data type. Value: `%s`.', dtype ) ); + throw new TypeError( format( '00h2Y', dtype ) ); } // Return an empty array having the specified dtype: return new ctor( 0 ); } // For all other supported invocations, we need at least two arguments... if ( nargs < 2 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format('00h05') ); } // At this point, we need to do some argument juggling... nargs -= 1; // henceforth, the number of available arguments is `nargs+1` @@ -292,7 +292,7 @@ function filledarrayBy() { // Check if we were provided only a callback and a "this" context.. if ( nargs === 0 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format('00h05') ); } } else { // "this" context is left undefined... @@ -305,12 +305,12 @@ function filledarrayBy() { nargs -= 1; clbk = arguments[ nargs ]; if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '00h2b', clbk ) ); } } // If we were only provided 2 arguments and the last argument was not a function, we've been provided an insufficient number of arguments... else { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); + throw new TypeError( format('00h05') ); } // Now that we've processed the callback arguments, let's continue working backward to see if we've been provided a `dtype` argument... nargs -= 1; @@ -322,7 +322,7 @@ function filledarrayBy() { } ctor = ctors( dtype ); if ( ctor === null ) { - throw new TypeError( format( 'invalid argument. Must provide a recognized data type. Value: `%s`.', dtype ) ); + throw new TypeError( format( '00h2Y', dtype ) ); } // At this point, we've resolved the output array data type, and now we can actually create the output array... if ( dtype === 'generic' ) { @@ -337,26 +337,26 @@ function filledarrayBy() { return filledArray( len, clbk, thisArg ); } if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format('00h04') ); } if ( isObject( arg ) ) { if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2Z', arg ) ); } if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } arg = arg[ ITERATOR_SYMBOL ](); if ( !isFunction( arg.next ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } return filledArrayIterator( arg, clbk, thisArg ); } - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } else if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format('00h04') ); } - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } if ( nargs === 0 ) { // length || array-like || ArrayBuffer || iterable arg = arguments[ 0 ]; @@ -368,18 +368,18 @@ function filledarrayBy() { arr = new ctor( arg ); } else if ( isObject( arg ) ) { if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2Z', arg ) ); } if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } arg = arg[ ITERATOR_SYMBOL ](); if ( !isFunction( arg.next ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } arr = new ctor( iterLength( arg ) ); } else { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( '00h2a', arg ) ); } } else if ( nargs === 1 ) { arr = new ctor( arguments[0], arguments[1] ); // (ArrayBuffer, byteOffset) diff --git a/package.json b/package.json index b1d16c6..a1a5078 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "@stdlib/assert-is-string": "^0.2.3", "@stdlib/blas-ext-base-gfill-by": "^0.2.3", "@stdlib/iter-length": "^0.2.3", - "@stdlib/string-format": "^0.2.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.3", "@stdlib/symbol-iterator": "^0.2.3", "@stdlib/types": "^0.5.1", "@stdlib/error-tools-fmtprodmsg": "^0.2.3" From b0505d6df55e4f66e5c694addefbdef5e479a0ca Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 15 Aug 2026 03:42:26 +0000 Subject: [PATCH 116/117] Remove files --- index.d.ts | 322 ---- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5169 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index fde6688..0000000 --- a/index.d.ts +++ /dev/null @@ -1,322 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, RealOrComplexTypedArray, BooleanArray, DataType } from '@stdlib/types/array'; -import { IterableIterator } from '@stdlib/types/iter'; - -/** -* Array or typed array. -*/ -type ArrayOrTypedArray = Array | RealOrComplexTypedArray | BooleanArray; - -/** -* Nullary callback function. -* -* @returns fill value -*/ -type Nullary = () => any; - -/** -* Unary callback function. -* -* @param i - current array index -* @returns fill value -*/ -type Unary = ( i: number ) => any; - -/** -* Callback function. -* -* @param i - current array index -* @returns fill value -*/ -type Callback = Nullary | Unary; - -/** -* Creates a filled array having a specified data type. -* -* @param dtype - data type -* @returns filled array -* -* @example -* var arr = filledarrayBy(); -* // returns -* -* @example -* var arr = filledarrayBy( 'float32' ); -* // returns -*/ -declare function filledarrayBy( dtype?: DataType ): ArrayOrTypedArray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Creates a filled array according to a provided callback function and having a specified `length`. -* -* @param length - array length -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* -* var arr = filledarrayBy( 5, constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( length: number, clbk: Callback, thisArg?: any ): ArrayOrTypedArray; - -/** -* Creates a filled array according to a provided callback function and having a specified `length`. -* -* @param length - array length -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* -* var arr = filledarrayBy( 5, 'float64', constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( length: number, dtype: DataType, clbk: Callback, thisArg?: any ): ArrayOrTypedArray; - -/** -* Creates a filled array from another `array` according to a provided callback function. -* -* @param array - typed array or array-like object -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* -* 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; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Creates a filled array from another `array` according to a provided callback function. -* -* @param array - typed array or array-like object -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* -* 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; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Creates a filled array from an iterable according to a callback function. -* -* @param iterable - iterable -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var iterConstant = require( '@stdlib/iter-constant' ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarrayBy( it, constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( iterable: IterableIterator, clbk: Callback, thisArg?: any ): ArrayOrTypedArray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Creates a filled array from an iterable according to a callback function. -* -* @param iterable - iterable -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var iterConstant = require( '@stdlib/iter-constant' ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarrayBy( it, 'float64', constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( iterable: IterableIterator, dtype: DataType, clbk: 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. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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 | BooleanArray; - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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 | BooleanArray; - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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 | BooleanArray; - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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 | BooleanArray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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 | BooleanArray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils-constant-function' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* 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 | BooleanArray; // eslint-disable-line @typescript-eslint/unified-signatures - - -// EXPORTS // - -export = filledarrayBy; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 6f157fa..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.3-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.3-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@v0.0.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.3-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.3-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.3-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-ctors@v0.3.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill-by@v0.2.3-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled-by@v0.2.3-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.2.3-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.3-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@v0.2.3-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.4.1-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";var v=f(),g=j.get("dtypes.default");function c(){var f,j,c,b,y,x,u,E;if(0===(j=arguments.length))return new(y=d(g))(0);if(r(c=arguments[0])){if(j>1)throw new TypeError(w("00h05"));if(null===(y=d(c)))throw new TypeError(w("00h2Y",c));return new y(0)}if(j<2)throw new TypeError(w("00h05"));if(h(arguments[j-=1]))if(h(arguments[j-1])){if(f=arguments[j],b=arguments[j-=1],0===j)throw new TypeError(w("00h05"))}else b=arguments[j];else{if(!(j>=2))throw new TypeError(w("00h05"));if(f=arguments[j],!h(b=arguments[j-=1]))throw new TypeError(w("00h2b",b))}if((j-=1)>=0&&r(arguments[j])?(c=arguments[j],j-=1):c=g,null===(y=d(c)))throw new TypeError(w("00h2Y",c));if("generic"===c){if(E=arguments[0],0===j){if(e(E)?u=E:i(E)&&(u=E.length),void 0!==u)return m(u,b,f);if(n(E))throw new Error(w("00h04"));if(o(E)){if(!1===v)throw new TypeError(w("00h2Z",E));if(!h(E[p]))throw new TypeError(w("00h2a",E));if(E=E[p](),!h(E.next))throw new TypeError(w("00h2a",E));return function(r,e,t){var s,i;for(s=[],i=-1;!r.next().done;)i+=1,s.push(e.call(t,i));return s}(E,b,f)}throw new TypeError(w("00h2a",E))}if(n(E))throw new Error(w("00h04"));throw new TypeError(w("00h2a",E))}if(0===j)if(i(E=arguments[0]))x=new y(E.length);else if(n(E))x=new y(E);else if(e(E))x=new y(E);else{if(!o(E))throw new TypeError(w("00h2a",E));if(!1===v)throw new TypeError(w("00h2Z",E));if(!h(E[p]))throw new TypeError(w("00h2a",E));if(E=E[p](),!h(E.next))throw new TypeError(w("00h2a",E));x=new y(a(E))}else x=1===j?new y(arguments[0],arguments[1]):new y(arguments[0],arguments[1],arguments[2]);return x.length>0&&(t(c)||s(c)?function(r,e,t){var s;for(s=0;s\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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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( format('00h05') );\n\t\t}\n\t\tctor = ctors( dtype );\n\t\tif ( ctor === null ) {\n\t\t\tthrow new TypeError( format( '00h2Y', 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( format('00h05') );\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( format('00h05') );\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( '00h2b', clbk ) );\n\t\t}\n\t}\n\t// If we 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( format('00h05') );\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( '00h2Y', 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( format('00h04') );\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( '00h2Z', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00h2a', 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( '00h2a', 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( '00h2a', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format('00h04') );\n\t\t}\n\t\tthrow new TypeError( format( '00h2a', 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( '00h2Z', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00h2a', 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( '00h2a', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00h2a', 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\nexport default filledarrayBy;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","DEFAULT_DTYPE","defaults","get","filledarrayBy","thisArg","nargs","dtype","clbk","ctor","arr","len","arg","arguments","length","ctors","isString","TypeError","format","isFunction","isNonNegativeInteger","isCollection","filledArray","isArrayBuffer","Error","isObject","ITERATOR_SYMBOL","next","it","i","done","push","call","filledArrayIterator","iterLength","isComplexDataType","isBooleanDataType","set","filledAccessors","gfillBy","value","aidx"],"mappings":";;sjDA0CA,IAAIA,EAAsBC,IACtBC,EAAgBC,EAASC,IAAK,kBA2MlC,SAASC,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAKJ,GAAe,KAHfN,EAAQO,UAAUC,QAKjB,OAAO,IADPL,EAAOM,EAAOd,IACG,GAIlB,GAAKe,EADLT,EAAQM,UAAW,IACM,CAExB,GAAKP,EAAQ,EACZ,MAAM,IAAIW,UAAWC,EAAO,UAG7B,GAAc,QADdT,EAAOM,EAAOR,IAEb,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,OAAO,IAAIE,EAAM,EACjB,CAED,GAAKH,EAAQ,EACZ,MAAM,IAAIW,UAAWC,EAAO,UAM7B,GAAKC,EAAYN,UAHjBP,GAAS,IAKR,GAAKa,EAAYN,UAAWP,EAAM,KAMjC,GALAD,EAAUQ,UAAWP,GAErBE,EAAOK,UADPP,GAAS,GAIM,IAAVA,EACJ,MAAM,IAAIW,UAAWC,EAAO,eAI7BV,EAAOK,UAAWP,OAIf,MAAKA,GAAS,GAUlB,MAAM,IAAIW,UAAWC,EAAO,UAN5B,GAHAb,EAAUQ,UAAWP,IAGfa,EADNX,EAAOK,UADPP,GAAS,IAGR,MAAM,IAAIW,UAAWC,EAAQ,QAASV,GAMvC,CAUD,IARAF,GAAS,IACK,GAAKU,EAAUH,UAAWP,KACvCC,EAAQM,UAAWP,GACnBA,GAAS,GAETC,EAAQN,EAGK,QADdQ,EAAOM,EAAOR,IAEb,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,GAAe,YAAVA,EAAsB,CAE1B,GADAK,EAAMC,UAAW,GACF,IAAVP,EAAc,CAMlB,GALKc,EAAsBR,GAC1BD,EAAMC,EACKS,EAAcT,KACzBD,EAAMC,EAAIE,aAEE,IAARH,EACJ,OAAOW,EAAaX,EAAKH,EAAMH,GAEhC,GAAKkB,EAAeX,GACnB,MAAM,IAAIY,MAAON,EAAO,UAEzB,GAAKO,EAAUb,GAAQ,CACtB,IAA6B,IAAxBb,EACJ,MAAM,IAAIkB,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAYP,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLP,EAAYP,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvC,OAvSJ,SAA8BgB,EAAIpB,EAAMH,GACvC,IAAIK,EACAmB,EAKJ,IAFAnB,EAAM,GACNmB,GAAK,GAEAD,EAAGD,OACAG,MAGPD,GAAK,EACLnB,EAAIqB,KAAMvB,EAAKwB,KAAM3B,EAASwB,IAE/B,OAAOnB,CACR,CAuRWuB,CAAqBrB,EAAKJ,EAAMH,EACvC,CACD,MAAM,IAAIY,UAAWC,EAAQ,QAASN,GACzC,CAAS,GAAKW,EAAeX,GAC1B,MAAM,IAAIY,MAAON,EAAO,UAEzB,MAAM,IAAID,UAAWC,EAAQ,QAASN,GACtC,CACD,GAAe,IAAVN,EAEJ,GAAKe,EADLT,EAAMC,UAAW,IAEhBH,EAAM,IAAID,EAAMG,EAAIE,aACd,GAAKS,EAAeX,GAC1BF,EAAM,IAAID,EAAMG,QACV,GAAKQ,EAAsBR,GACjCF,EAAM,IAAID,EAAMG,OACV,KAAKa,EAAUb,GAarB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAZtC,IAA6B,IAAxBb,EACJ,MAAM,IAAIkB,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAYP,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLP,EAAYP,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvCF,EAAM,IAAID,EAAMyB,EAAYtB,GAG5B,MAEDF,EADqB,IAAVJ,EACL,IAAIG,EAAMI,UAAU,GAAIA,UAAU,IAElC,IAAIJ,EAAMI,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKH,EAAII,OAAS,IACZqB,EAAmB5B,IAAW6B,EAAmB7B,GAjTxD,SAA0BG,EAAKF,EAAMH,GACpC,IAAIwB,EACJ,IAAMA,EAAI,EAAGA,EAAInB,EAAII,OAAQe,IAC5BnB,EAAI2B,IAAK7B,EAAKwB,KAAM3B,EAASwB,GAAKA,EAGpC,CA4SGS,CAAiB5B,EAAKF,EAAMH,GAE5BkC,EAAS7B,EAAII,OAAQJ,EAAK,GAe5B,SAAmB8B,EAAOC,GACzB,OAAOjC,EAAKwB,KAAM3B,EAASoC,EAC3B,KAdM/B,CAeR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index dabf69c..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 9f61d5eb2119c83d3ebea3eb7c565a9aa0b701b6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 15 Aug 2026 03:42:50 +0000 Subject: [PATCH 117/117] Auto-generated commit --- .editorconfig | 189 - .eslintrc.js | 1 - .gitattributes | 68 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 101 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 205 - .npmignore | 229 - .npmrc | 44 - CHANGELOG.md | 239 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 49 +- SECURITY.md | 5 - benchmark/benchmark.js | 342 -- benchmark/benchmark.length.bool.js | 98 - benchmark/benchmark.length.complex128.js | 99 - benchmark/benchmark.length.complex64.js | 99 - benchmark/benchmark.length.float32.js | 98 - benchmark/benchmark.length.float64.js | 98 - benchmark/benchmark.length.generic.js | 98 - benchmark/benchmark.length.int16.js | 98 - benchmark/benchmark.length.int32.js | 98 - benchmark/benchmark.length.int8.js | 98 - benchmark/benchmark.length.uint16.js | 98 - benchmark/benchmark.length.uint32.js | 98 - benchmark/benchmark.length.uint8.js | 98 - benchmark/benchmark.length.uint8c.js | 98 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 36 - dist/index.js.map | 7 - docs/repl.txt | 157 - docs/types/test.ts | 606 --- examples/index.js | 37 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 192 - lib/main.js | 416 -- package.json | 96 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 4397 ---------------- 57 files changed, 4870 insertions(+), 11338 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.length.bool.js delete mode 100644 benchmark/benchmark.length.complex128.js delete mode 100644 benchmark/benchmark.length.complex64.js delete mode 100644 benchmark/benchmark.length.float32.js delete mode 100644 benchmark/benchmark.length.float64.js delete mode 100644 benchmark/benchmark.length.generic.js delete mode 100644 benchmark/benchmark.length.int16.js delete mode 100644 benchmark/benchmark.length.int32.js delete mode 100644 benchmark/benchmark.length.int8.js delete mode 100644 benchmark/benchmark.length.uint16.js delete mode 100644 benchmark/benchmark.length.uint32.js delete mode 100644 benchmark/benchmark.length.uint8.js delete mode 100644 benchmark/benchmark.length.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 80f3fca..0000000 --- a/.editorconfig +++ /dev/null @@ -1,189 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Ignore generated lock files for GitHub Agentic Workflows: -[*.lock.yml] -charset = unset -end_of_line = unset -indent_style = unset -indent_size = unset -trim_trailing_whitespace = unset -insert_final_newline = unset - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 24b327f..0000000 --- a/.gitattributes +++ /dev/null @@ -1,68 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation - -.github/workflows/*.lock.yml linguist-generated=true merge=ours diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 8b62833..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2026-08-15T02:43:10.800Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 2d6aaee..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/contributing/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index f988046..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index b2c1f9c..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '42 6 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 83d50c4..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,821 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send notification to Zulip if job fails: - - name: 'Send notification to Zulip in case of failure' - # Pin action to full length commit SHA - uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 - if: failure() - with: - api-key: ${{ secrets.ZULIP_API_KEY }} - email: 'github-actions-bot@stdlib.zulipchat.com' - organization-url: 'https://stdlib.zulipchat.com' - to: 'workflows-standalone' - type: 'stream' - topic: ${{ github.event.repository.name }} - content: | - :cross_mark: **${{ github.workflow }}** workflow failed - - **Repository:** [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) - **Run:** [View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -278,7 +269,7 @@ for ( i = 0; i < dt.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -347,13 +338,13 @@ Copyright © 2016-2026. 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/dtypes]: https://github.com/stdlib-js/array-dtypes/tree/esm -[@stdlib/array/filled]: https://github.com/stdlib-js/array-filled +[@stdlib/array/filled]: https://github.com/stdlib-js/array-filled/tree/esm -[@stdlib/array/typed]: https://github.com/stdlib-js/array-typed +[@stdlib/array/typed]: https://github.com/stdlib-js/array-typed/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 6fba606..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,342 +0,0 @@ -/** -* @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 isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); -var isArray = require( '@stdlib/assert-is-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var Complex64 = require( '@stdlib/complex-float32-ctor' ); -var Complex128 = require( '@stdlib/complex-float64-ctor' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var filledarrayBy = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 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( format( '%s:dtype=float64', pkg ), function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'float64', 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( format( '%s:dtype=float32', pkg ), function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'float32', 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( format( '%s:dtype=bool', pkg ), 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( format( '%s:dtype=complex128', pkg ), function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( new Complex128( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'complex128', 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( format( '%s:dtype=complex64', pkg ), function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( new Complex64( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'complex64', 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( format( '%s:dtype=int32', pkg ), function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int32', 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( format( '%s:dtype=uint32', pkg ), function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint32', 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( format( '%s:dtype=int16', pkg ), function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int16', 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( format( '%s:dtype=uint16', pkg ), function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint16', 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( format( '%s:dtype=int8', pkg ), function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int8', 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( format( '%s:dtype=uint8', pkg ), function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint8', 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( format( '%s:dtype=uint8c', pkg ), function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint8c', 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( format( '%s:dtype=generic', pkg ), function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'generic', clbk ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.length.bool.js b/benchmark/benchmark.length.bool.js deleted file mode 100644 index 52b3237..0000000 --- a/benchmark/benchmark.length.bool.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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 format = require( '@stdlib/string-format' ); -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( format( '%s:dtype=bool,len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.complex128.js b/benchmark/benchmark.length.complex128.js deleted file mode 100644 index 63c0843..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,99 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 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 Complex128 = require( '@stdlib/complex-float64-ctor' ); -var format = require( '@stdlib/string-format' ); -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( new Complex128( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'complex128', 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( format( '%s:dtype=complex128,len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.complex64.js b/benchmark/benchmark.length.complex64.js deleted file mode 100644 index 186f811..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,99 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 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 Complex64 = require( '@stdlib/complex-float32-ctor' ); -var format = require( '@stdlib/string-format' ); -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( new Complex64( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'complex64', 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( format( '%s:dtype=complex64,len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.float32.js b/benchmark/benchmark.length.float32.js deleted file mode 100644 index 5ba3130..0000000 --- a/benchmark/benchmark.length.float32.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/string-format' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'float32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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( format( '%s:dtype=float32,len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.float64.js b/benchmark/benchmark.length.float64.js deleted file mode 100644 index 4a2be6c..0000000 --- a/benchmark/benchmark.length.float64.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/string-format' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'float64', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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( format( '%s:dtype=float64,len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.generic.js b/benchmark/benchmark.length.generic.js deleted file mode 100644 index 6522748..0000000 --- a/benchmark/benchmark.length.generic.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isArray = require( '@stdlib/assert-is-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/string-format' ); -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( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'generic', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isArray( 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( format( '%s:dtype=generic,len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int16.js b/benchmark/benchmark.length.int16.js deleted file mode 100644 index 9ac94e9..0000000 --- a/benchmark/benchmark.length.int16.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/string-format' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int16', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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( format( '%s:dtype=int16,len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int32.js b/benchmark/benchmark.length.int32.js deleted file mode 100644 index a5ce4d0..0000000 --- a/benchmark/benchmark.length.int32.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/string-format' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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( format( '%s:dtype=int32,len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.int8.js b/benchmark/benchmark.length.int8.js deleted file mode 100644 index 6104616..0000000 --- a/benchmark/benchmark.length.int8.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/string-format' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int8', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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( format( '%s:dtype=int8,len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint16.js b/benchmark/benchmark.length.uint16.js deleted file mode 100644 index 3108633..0000000 --- a/benchmark/benchmark.length.uint16.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/string-format' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint16', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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( format( '%s:dtype=uint16,len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint32.js b/benchmark/benchmark.length.uint32.js deleted file mode 100644 index 602e232..0000000 --- a/benchmark/benchmark.length.uint32.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/string-format' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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( format( '%s:dtype=uint32,len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint8.js b/benchmark/benchmark.length.uint8.js deleted file mode 100644 index 8664da3..0000000 --- a/benchmark/benchmark.length.uint8.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/string-format' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint8', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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( format( '%s:dtype=uint8,len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.uint8c.js b/benchmark/benchmark.length.uint8c.js deleted file mode 100644 index 76645b9..0000000 --- a/benchmark/benchmark.length.uint8c.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var format = require( '@stdlib/string-format' ); -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( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint8c', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( 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( format( '%s:dtype=uint8c,len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index c138144..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by" -%% click B href "https://github.com/stdlib-js/array-filled-by/tree/main" -%% click C href "https://github.com/stdlib-js/array-filled-by/tree/production" -%% click D href "https://github.com/stdlib-js/array-filled-by/tree/esm" -%% click E href "https://github.com/stdlib-js/array-filled-by/tree/deno" -%% click F href "https://github.com/stdlib-js/array-filled-by/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by -[production-url]: https://github.com/stdlib-js/array-filled-by/tree/production -[deno-url]: https://github.com/stdlib-js/array-filled-by/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-filled-by/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-filled-by/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-filled-by/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-filled-by/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-filled-by/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 188fc9b..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import filledarrayBy from '../docs/types/index'; -export = filledarrayBy; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 4049a13..0000000 --- a/dist/index.js +++ /dev/null @@ -1,36 +0,0 @@ -"use strict";var k=function(n,e){return function(){try{return e||n((e={exports:{}}).exports,e),e.exports}catch(t){throw e=0,t}}};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,t){var a,i,l;for(a=[],i=-1;l=n.next(),!l.done;)i+=1,a.push(e.call(t,i));return a}function C(n,e,t){var a;for(a=0;a1)throw new TypeError("invalid arguments. Must provide a length, typed array, array-like object, or an iterable.");if(i=v(t),i===null)throw new TypeError(o("invalid argument. Must provide a recognized data type. Value: `%s`.",t));return new i(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])?(t=arguments[e],e-=1):t=h,i=v(t),i===null)throw new TypeError(o("invalid argument. Must provide a recognized data type. Value: `%s`.",t));if(t==="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 i(r.length);else if(g(r))l=new i(r);else if(d(r))l=new i(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 i(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 i(arguments[0],arguments[1]):l=new i(arguments[0],arguments[1],arguments[2]);return l.length>0&&(q(t)||M(t)?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 deleted file mode 100644 index 8a898ec..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "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 we 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": "iIAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAuB,QAAS,uCAAwC,EAAE,YAC1EC,EAAoB,QAAS,+DAAgE,EAC7FC,EAAoB,QAAS,gDAAiD,EAC9EC,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,EACA,EACAC,EAIJ,IAFAD,EAAM,CAAC,EACP,EAAI,GAEHC,EAAIJ,EAAG,KAAK,EACP,CAAAI,EAAE,MAGP,GAAK,EACLD,EAAI,KAAMF,EAAK,KAAMC,EAAS,CAAE,CAAE,EAEnC,OAAOC,CACR,CAWA,SAASE,EAAiBF,EAAKF,EAAMC,EAAU,CAC9C,IAAII,EACJ,IAAMA,EAAI,EAAGA,EAAIH,EAAI,OAAQG,IAC5BH,EAAI,IAAKF,EAAK,KAAMC,EAASI,CAAE,EAAGA,CAAE,EAErC,OAAOH,CACR,CA4JA,SAASI,GAAgB,CACxB,IAAIL,EACAM,EACAC,EACAR,EACAS,EACAP,EACAQ,EACAC,EAKJ,GAHAJ,EAAQ,UAAU,OAGbA,IAAU,EACd,OAAAE,EAAOrB,EAAOS,CAAc,EACrB,IAAIY,EAAM,CAAE,EAIpB,GADAD,EAAQ,UAAW,CAAE,EAChB5B,EAAU4B,CAAM,EAAI,CAExB,GAAKD,EAAQ,EACZ,MAAM,IAAI,UAAW,2FAA4F,EAGlH,GADAE,EAAOrB,EAAOoB,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWd,EAAQ,sEAAuEa,CAAM,CAAE,EAG7G,OAAO,IAAIC,EAAM,CAAE,CACpB,CAEA,GAAKF,EAAQ,EACZ,MAAM,IAAI,UAAW,2FAA4F,EAMlH,GAHAA,GAAS,EAGJpB,EAAY,UAAWoB,CAAM,CAAE,EAEnC,GAAKpB,EAAY,UAAWoB,EAAM,CAAE,CAAE,GAMrC,GALAN,EAAU,UAAWM,CAAM,EAC3BA,GAAS,EACTP,EAAO,UAAWO,CAAM,EAGnBA,IAAU,EACd,MAAM,IAAI,UAAW,2FAA4F,OAIlHP,EAAO,UAAWO,CAAM,UAIhBA,GAAS,GAIlB,GAHAN,EAAU,UAAWM,CAAM,EAC3BA,GAAS,EACTP,EAAO,UAAWO,CAAM,EACnB,CAACpB,EAAYa,CAAK,EACtB,MAAM,IAAI,UAAWL,EAAQ,uEAAwEK,CAAK,CAAE,MAK7G,OAAM,IAAI,UAAW,2FAA4F,EAWlH,GARAO,GAAS,EACJA,GAAS,GAAK3B,EAAU,UAAW2B,CAAM,CAAE,GAC/CC,EAAQ,UAAWD,CAAM,EACzBA,GAAS,GAETC,EAAQX,EAETY,EAAOrB,EAAOoB,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWd,EAAQ,sEAAuEa,CAAM,CAAE,EAG7G,GAAKA,IAAU,UAAY,CAE1B,GADAG,EAAM,UAAW,CAAE,EACdJ,IAAU,EAAI,CAMlB,GALK1B,EAAsB8B,CAAI,EAC9BD,EAAMC,EACK3B,EAAc2B,CAAI,IAC7BD,EAAMC,EAAI,QAEND,IAAQ,OACZ,OAAOpB,EAAaoB,EAAKV,EAAMC,CAAQ,EAExC,GAAKhB,EAAe0B,CAAI,EACvB,MAAM,IAAI,MAAO,mFAAoF,EAEtG,GAAKzB,EAAUyB,CAAI,EAAI,CACtB,GAAKf,IAAwB,GAC5B,MAAM,IAAI,UAAWD,EAAQ,sIAAuIgB,CAAI,CAAE,EAE3K,GAAK,CAACxB,EAAYwB,EAAKnB,CAAgB,CAAE,EACxC,MAAM,IAAI,UAAWG,EAAQ,wGAAyGgB,CAAI,CAAE,EAG7I,GADAA,EAAMA,EAAKnB,CAAgB,EAAE,EACxB,CAACL,EAAYwB,EAAI,IAAK,EAC1B,MAAM,IAAI,UAAWhB,EAAQ,wGAAyGgB,CAAI,CAAE,EAE7I,OAAOb,EAAqBa,EAAKX,EAAMC,CAAQ,CAChD,CACA,MAAM,IAAI,UAAWN,EAAQ,wGAAyGgB,CAAI,CAAE,CAC7I,SAAY1B,EAAe0B,CAAI,EAC9B,MAAM,IAAI,MAAO,mFAAoF,EAEtG,MAAM,IAAI,UAAWhB,EAAQ,wGAAyGgB,CAAI,CAAE,CAC7I,CACA,GAAKJ,IAAU,EAEd,GADAI,EAAM,UAAW,CAAE,EACd3B,EAAc2B,CAAI,EACtBT,EAAM,IAAIO,EAAME,EAAI,MAAO,UAChB1B,EAAe0B,CAAI,EAC9BT,EAAM,IAAIO,EAAME,CAAI,UACT9B,EAAsB8B,CAAI,EACrCT,EAAM,IAAIO,EAAME,CAAI,UACTzB,EAAUyB,CAAI,EAAI,CAC7B,GAAKf,IAAwB,GAC5B,MAAM,IAAI,UAAWD,EAAQ,sIAAuIgB,CAAI,CAAE,EAE3K,GAAK,CAACxB,EAAYwB,EAAKnB,CAAgB,CAAE,EACxC,MAAM,IAAI,UAAWG,EAAQ,wGAAyGgB,CAAI,CAAE,EAG7I,GADAA,EAAMA,EAAKnB,CAAgB,EAAE,EACxB,CAACL,EAAYwB,EAAI,IAAK,EAC1B,MAAM,IAAI,UAAWhB,EAAQ,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,IACZpB,EAAmB0B,CAAM,GAAKzB,EAAmByB,CAAM,EAC3DJ,EAAiBF,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", "v", "filledAccessors", "i", "filledarrayBy", "nargs", "dtype", "ctor", "len", "arg", "callback", "value", "aidx", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 06f3146..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,157 +0,0 @@ - -{{alias}}( [dtype] ) - Creates a filled array. - - Parameters - ---------- - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr = {{alias}}() - - > arr = {{alias}}( 'float32' ) - - - -{{alias}}( length[, dtype], clbk[, thisArg] ) - Returns a filled array according to a provided callback function and having - a specified length. - - Parameters - ---------- - length: integer - Array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > function clbk() { return 1.0; }; - > var arr = {{alias}}( 5, clbk ) - [ 1.0, 1.0, 1.0, 1.0, 1.0 ] - > arr = {{alias}}( 5, 'int32', clbk ) - [ 1, 1, 1, 1, 1 ] - - -{{alias}}( array[, dtype], clbk[, thisArg] ) - Creates a filled array from another array (or array-like object) according - to a provided callback function. - - Parameters - ---------- - array: ArrayLikeObject - Array from which to generate another array. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias}}( [ 0.5, 0.5, 0.5 ], {{alias:@stdlib/utils/constant-function}}( 2.0 ) ) - [ 2.0, 2.0, 2.0 ] - > var arr2 = {{alias}}( arr1, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( iterable[, dtype], clbk[, thisArg] ) - Creates a filled array from an iterable according to a provided callback - function. - - Parameters - ---------- - iterable: Iterable - Iterable from which to generate an array. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias:@stdlib/iter/constant}}( 3.0, {'iter': 3} ); - > var arr2 = {{alias}}( arr1, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( buffer[, byteOffset[, length]][, dtype], clbk[, thisArg] ) - Returns a filled typed array view of an ArrayBuffer according to a provided - callback function. - - The 'generic' array data type is *not* supported. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( buf, 0, 4, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0, 1.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index bb876ed..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,606 +0,0 @@ -/* -* @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. -*/ - -/// - -import { IterableIterator } from '@stdlib/types/iter'; -import filledarrayBy = require( './index' ); - - -/** -* Returns an iterator protocol-compliant object. -* -* @returns iterator protocol-compliant object -*/ -function iterator(): IterableIterator { - const obj: IterableIterator = { - [Symbol.iterator]: iterator, - 'next': next - }; - return obj; -} - -/** -* Implements the iterator protocol `next` method. -* -* @returns iterator protocol-compliant object -*/ -function next(): any { - return { - 'value': 1.0, - 'done': false - }; -} - -/** -* Callback function. -* -* @param i - current array index -* @returns return value -*/ -function clbk( i: number ): number { - return i; -} - - -// TESTS // - -// The function returns an array or typed array... -{ - filledarrayBy(); // $ExpectType ArrayOrTypedArray - filledarrayBy( 'float32' ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( 10, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( 10, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( 10, 'int32', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( 10, 'int32', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const x = new Float64Array( 10 ); - filledarrayBy( x, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( x, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( x, 'uint8', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( x, 'uint8', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const y = [ 2.0, 2.0, 2.0 ]; - filledarrayBy( y, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( y, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( y, 'float64', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( y, 'float64', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const it = iterator(); - filledarrayBy( it, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( it, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( it, 'uint8c', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( it, 'uint8c', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const buf = new ArrayBuffer( 32 ); - filledarrayBy( buf, clbk ); // $ExpectType RealOrComplexTypedArray | BooleanArray - filledarrayBy( buf, clbk, {} ); // $ExpectType RealOrComplexTypedArray | BooleanArray - - filledarrayBy( buf, 'uint32', clbk ); // $ExpectType RealOrComplexTypedArray | BooleanArray - filledarrayBy( buf, 'uint32', clbk, {} ); // $ExpectType RealOrComplexTypedArray | BooleanArray - - filledarrayBy( buf, 8, clbk ); // $ExpectType RealOrComplexTypedArray | BooleanArray - filledarrayBy( buf, 8, clbk, {} ); // $ExpectType RealOrComplexTypedArray | BooleanArray - - filledarrayBy( buf, 8, 'uint16', clbk ); // $ExpectType RealOrComplexTypedArray | BooleanArray - filledarrayBy( buf, 8, 'uint16', clbk, {} ); // $ExpectType RealOrComplexTypedArray | BooleanArray - - filledarrayBy( buf, 8, 2, clbk ); // $ExpectType RealOrComplexTypedArray | BooleanArray - filledarrayBy( buf, 8, 2, clbk, {} ); // $ExpectType RealOrComplexTypedArray | BooleanArray - - filledarrayBy( buf, 8, 2, 'int16', clbk ); // $ExpectType RealOrComplexTypedArray | BooleanArray - filledarrayBy( buf, 8, 2, 'int16', clbk, {} ); // $ExpectType RealOrComplexTypedArray | BooleanArray -} - -// The compiler throws an error if a callback function argument is not a function... -{ - filledarrayBy( 'float64', '5' ); // $ExpectError - filledarrayBy( 'float64', 1.0 ); // $ExpectError - filledarrayBy( 'float64', false ); // $ExpectError - filledarrayBy( 'float64', true ); // $ExpectError - filledarrayBy( 'float64', null ); // $ExpectError - filledarrayBy( 'float64', undefined ); // $ExpectError - filledarrayBy( 'float64', [] ); // $ExpectError - filledarrayBy( 'float64', {} ); // $ExpectError - - filledarrayBy( 'float64', '5', {} ); // $ExpectError - filledarrayBy( 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( 'float64', false, {} ); // $ExpectError - filledarrayBy( 'float64', true, {} ); // $ExpectError - filledarrayBy( 'float64', null, {} ); // $ExpectError - filledarrayBy( 'float64', undefined, {} ); // $ExpectError - filledarrayBy( 'float64', [], {} ); // $ExpectError - filledarrayBy( 'float64', {}, {} ); // $ExpectError - - filledarrayBy( 10, '5' ); // $ExpectError - filledarrayBy( 10, 1.0 ); // $ExpectError - filledarrayBy( 10, false ); // $ExpectError - filledarrayBy( 10, true ); // $ExpectError - filledarrayBy( 10, null ); // $ExpectError - filledarrayBy( 10, undefined ); // $ExpectError - filledarrayBy( 10, [] ); // $ExpectError - filledarrayBy( 10, {} ); // $ExpectError - - filledarrayBy( 10, '5', {} ); // $ExpectError - filledarrayBy( 10, 1.0, {} ); // $ExpectError - filledarrayBy( 10, false, {} ); // $ExpectError - filledarrayBy( 10, true, {} ); // $ExpectError - filledarrayBy( 10, null, {} ); // $ExpectError - filledarrayBy( 10, undefined, {} ); // $ExpectError - filledarrayBy( 10, [], {} ); // $ExpectError - filledarrayBy( 10, {}, {} ); // $ExpectError - - filledarrayBy( 10, 'float64', '5' ); // $ExpectError - filledarrayBy( 10, 'float64', 1.0 ); // $ExpectError - filledarrayBy( 10, 'float64', false ); // $ExpectError - filledarrayBy( 10, 'float64', true ); // $ExpectError - filledarrayBy( 10, 'float64', null ); // $ExpectError - filledarrayBy( 10, 'float64', undefined ); // $ExpectError - filledarrayBy( 10, 'float64', [] ); // $ExpectError - filledarrayBy( 10, 'float64', {} ); // $ExpectError - - filledarrayBy( 10, 'float64', '5', {} ); // $ExpectError - filledarrayBy( 10, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( 10, 'float64', false, {} ); // $ExpectError - filledarrayBy( 10, 'float64', true, {} ); // $ExpectError - filledarrayBy( 10, 'float64', null, {} ); // $ExpectError - filledarrayBy( 10, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( 10, 'float64', [], {} ); // $ExpectError - filledarrayBy( 10, 'float64', {}, {} ); // $ExpectError - - const x = new Float64Array( 10 ); - filledarrayBy( x, '5' ); // $ExpectError - filledarrayBy( x, 1.0 ); // $ExpectError - filledarrayBy( x, false ); // $ExpectError - filledarrayBy( x, true ); // $ExpectError - filledarrayBy( x, null ); // $ExpectError - filledarrayBy( x, undefined ); // $ExpectError - filledarrayBy( x, [] ); // $ExpectError - filledarrayBy( x, {} ); // $ExpectError - - filledarrayBy( x, '5', {} ); // $ExpectError - filledarrayBy( x, 1.0, {} ); // $ExpectError - filledarrayBy( x, false, {} ); // $ExpectError - filledarrayBy( x, true, {} ); // $ExpectError - filledarrayBy( x, null, {} ); // $ExpectError - filledarrayBy( x, undefined, {} ); // $ExpectError - filledarrayBy( x, [], {} ); // $ExpectError - filledarrayBy( x, {}, {} ); // $ExpectError - - filledarrayBy( x, 'float64', '5' ); // $ExpectError - filledarrayBy( x, 'float64', 1.0 ); // $ExpectError - filledarrayBy( x, 'float64', false ); // $ExpectError - filledarrayBy( x, 'float64', true ); // $ExpectError - filledarrayBy( x, 'float64', null ); // $ExpectError - filledarrayBy( x, 'float64', undefined ); // $ExpectError - filledarrayBy( x, 'float64', [] ); // $ExpectError - filledarrayBy( x, 'float64', {} ); // $ExpectError - - filledarrayBy( x, 'float64', '5', {} ); // $ExpectError - filledarrayBy( x, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( x, 'float64', false, {} ); // $ExpectError - filledarrayBy( x, 'float64', true, {} ); // $ExpectError - filledarrayBy( x, 'float64', null, {} ); // $ExpectError - filledarrayBy( x, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( x, 'float64', [], {} ); // $ExpectError - filledarrayBy( x, 'float64', {}, {} ); // $ExpectError - - const y = [ 2.0, 2.0, 2.0 ]; - filledarrayBy( y, '5' ); // $ExpectError - filledarrayBy( y, 1.0 ); // $ExpectError - filledarrayBy( y, false ); // $ExpectError - filledarrayBy( y, true ); // $ExpectError - filledarrayBy( y, null ); // $ExpectError - filledarrayBy( y, undefined ); // $ExpectError - filledarrayBy( y, [] ); // $ExpectError - filledarrayBy( y, {} ); // $ExpectError - - filledarrayBy( y, '5', {} ); // $ExpectError - filledarrayBy( y, 1.0, {} ); // $ExpectError - filledarrayBy( y, false, {} ); // $ExpectError - filledarrayBy( y, true, {} ); // $ExpectError - filledarrayBy( y, null, {} ); // $ExpectError - filledarrayBy( y, undefined, {} ); // $ExpectError - filledarrayBy( y, [], {} ); // $ExpectError - filledarrayBy( y, {}, {} ); // $ExpectError - - filledarrayBy( y, 'float64', '5' ); // $ExpectError - filledarrayBy( y, 'float64', 1.0 ); // $ExpectError - filledarrayBy( y, 'float64', false ); // $ExpectError - filledarrayBy( y, 'float64', true ); // $ExpectError - filledarrayBy( y, 'float64', null ); // $ExpectError - filledarrayBy( y, 'float64', undefined ); // $ExpectError - filledarrayBy( y, 'float64', [] ); // $ExpectError - filledarrayBy( y, 'float64', {} ); // $ExpectError - - filledarrayBy( y, 'float64', '5', {} ); // $ExpectError - filledarrayBy( y, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( y, 'float64', false, {} ); // $ExpectError - filledarrayBy( y, 'float64', true, {} ); // $ExpectError - filledarrayBy( y, 'float64', null, {} ); // $ExpectError - filledarrayBy( y, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( y, 'float64', [], {} ); // $ExpectError - filledarrayBy( y, 'float64', {}, {} ); // $ExpectError - - const it = iterator(); - filledarrayBy( it, '5' ); // $ExpectError - filledarrayBy( it, 1.0 ); // $ExpectError - filledarrayBy( it, false ); // $ExpectError - filledarrayBy( it, true ); // $ExpectError - filledarrayBy( it, null ); // $ExpectError - filledarrayBy( it, undefined ); // $ExpectError - filledarrayBy( it, [] ); // $ExpectError - filledarrayBy( it, {} ); // $ExpectError - - filledarrayBy( it, '5', {} ); // $ExpectError - filledarrayBy( it, 1.0, {} ); // $ExpectError - filledarrayBy( it, false, {} ); // $ExpectError - filledarrayBy( it, true, {} ); // $ExpectError - filledarrayBy( it, null, {} ); // $ExpectError - filledarrayBy( it, undefined, {} ); // $ExpectError - filledarrayBy( it, [], {} ); // $ExpectError - filledarrayBy( it, {}, {} ); // $ExpectError - - filledarrayBy( it, 'float64', '5' ); // $ExpectError - filledarrayBy( it, 'float64', 1.0 ); // $ExpectError - filledarrayBy( it, 'float64', false ); // $ExpectError - filledarrayBy( it, 'float64', true ); // $ExpectError - filledarrayBy( it, 'float64', null ); // $ExpectError - filledarrayBy( it, 'float64', undefined ); // $ExpectError - filledarrayBy( it, 'float64', [] ); // $ExpectError - filledarrayBy( it, 'float64', {} ); // $ExpectError - - filledarrayBy( it, 'float64', '5', {} ); // $ExpectError - filledarrayBy( it, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( it, 'float64', false, {} ); // $ExpectError - filledarrayBy( it, 'float64', true, {} ); // $ExpectError - filledarrayBy( it, 'float64', null, {} ); // $ExpectError - filledarrayBy( it, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( it, 'float64', [], {} ); // $ExpectError - filledarrayBy( it, 'float64', {}, {} ); // $ExpectError - - const buf = new ArrayBuffer( 32 ); - filledarrayBy( buf, '5' ); // $ExpectError - filledarrayBy( buf, 1.0 ); // $ExpectError - filledarrayBy( buf, false ); // $ExpectError - filledarrayBy( buf, true ); // $ExpectError - filledarrayBy( buf, null ); // $ExpectError - filledarrayBy( buf, undefined ); // $ExpectError - filledarrayBy( buf, [] ); // $ExpectError - filledarrayBy( buf, {} ); // $ExpectError - - filledarrayBy( buf, '5', {} ); // $ExpectError - filledarrayBy( buf, 1.0, {} ); // $ExpectError - filledarrayBy( buf, false, {} ); // $ExpectError - filledarrayBy( buf, true, {} ); // $ExpectError - filledarrayBy( buf, null, {} ); // $ExpectError - filledarrayBy( buf, undefined, {} ); // $ExpectError - filledarrayBy( buf, [], {} ); // $ExpectError - filledarrayBy( buf, {}, {} ); // $ExpectError - - filledarrayBy( buf, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 'float64', false ); // $ExpectError - filledarrayBy( buf, 'float64', true ); // $ExpectError - filledarrayBy( buf, 'float64', null ); // $ExpectError - filledarrayBy( buf, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 'float64', {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5' ); // $ExpectError - filledarrayBy( buf, 8, 1.0 ); // $ExpectError - filledarrayBy( buf, 8, false ); // $ExpectError - filledarrayBy( buf, 8, true ); // $ExpectError - filledarrayBy( buf, 8, null ); // $ExpectError - filledarrayBy( buf, 8, undefined ); // $ExpectError - filledarrayBy( buf, 8, [] ); // $ExpectError - filledarrayBy( buf, 8, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, false, {} ); // $ExpectError - filledarrayBy( buf, 8, true, {} ); // $ExpectError - filledarrayBy( buf, 8, null, {} ); // $ExpectError - filledarrayBy( buf, 8, undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, [], {} ); // $ExpectError - filledarrayBy( buf, 8, {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 8, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 'float64', false ); // $ExpectError - filledarrayBy( buf, 8, 'float64', true ); // $ExpectError - filledarrayBy( buf, 8, 'float64', null ); // $ExpectError - filledarrayBy( buf, 8, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 8, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 8, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 8, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, '5' ); // $ExpectError - filledarrayBy( buf, 8, 2, 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 2, false ); // $ExpectError - filledarrayBy( buf, 8, 2, true ); // $ExpectError - filledarrayBy( buf, 8, 2, null ); // $ExpectError - filledarrayBy( buf, 8, 2, undefined ); // $ExpectError - filledarrayBy( buf, 8, 2, [] ); // $ExpectError - filledarrayBy( buf, 8, 2, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, false, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, true, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, null, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, [], {} ); // $ExpectError - filledarrayBy( buf, 8, 2, {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', false ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', true ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', null ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', {}, {} ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid length, typed array, array-like object, `ArrayBuffer`, or iterable argument... -{ - filledarrayBy( false, clbk ); // $ExpectError - filledarrayBy( true, clbk ); // $ExpectError - filledarrayBy( null, clbk ); // $ExpectError - filledarrayBy( {}, clbk ); // $ExpectError - - filledarrayBy( false, clbk, {} ); // $ExpectError - filledarrayBy( true, clbk, {} ); // $ExpectError - filledarrayBy( null, clbk, {} ); // $ExpectError - filledarrayBy( {}, clbk, {} ); // $ExpectError - - filledarrayBy( false, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 'float64', clbk ); // $ExpectError - - filledarrayBy( false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, clbk ); // $ExpectError - filledarrayBy( 1.0, 8, clbk ); // $ExpectError - filledarrayBy( false, 8, clbk ); // $ExpectError - filledarrayBy( true, 8, clbk ); // $ExpectError - filledarrayBy( null, 8, clbk ); // $ExpectError - filledarrayBy( undefined, 8, clbk ); // $ExpectError - filledarrayBy( [], 8, clbk ); // $ExpectError - filledarrayBy( {}, 8, clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, clbk ); // $ExpectError - - filledarrayBy( '5', 8, clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, clbk, {} ); // $ExpectError - filledarrayBy( false, 8, clbk, {} ); // $ExpectError - filledarrayBy( true, 8, clbk, {} ); // $ExpectError - filledarrayBy( null, 8, clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, clbk, {} ); // $ExpectError - filledarrayBy( [], 8, clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 'float64', clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( false, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( [], 8, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 'float64', clbk ); // $ExpectError - - filledarrayBy( '5', 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 2, clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 2, clbk ); // $ExpectError - filledarrayBy( false, 8, 2, clbk ); // $ExpectError - filledarrayBy( true, 8, 2, clbk ); // $ExpectError - filledarrayBy( null, 8, 2, clbk ); // $ExpectError - filledarrayBy( undefined, 8, 2, clbk ); // $ExpectError - filledarrayBy( [], 8, 2, clbk ); // $ExpectError - filledarrayBy( {}, 8, 2, clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, clbk ); // $ExpectError - - filledarrayBy( '5', 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( false, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( [], 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, 'float64', clbk ); // $ExpectError - - filledarrayBy( '5', 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a byte offset argument which is not a number... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, false, clbk ); // $ExpectError - filledarrayBy( buf, true, clbk ); // $ExpectError - filledarrayBy( buf, null, clbk ); // $ExpectError - filledarrayBy( buf, [], clbk ); // $ExpectError - filledarrayBy( buf, {}, clbk ); // $ExpectError - - filledarrayBy( buf, false, clbk, {} ); // $ExpectError - filledarrayBy( buf, true, clbk, {} ); // $ExpectError - filledarrayBy( buf, null, clbk, {} ); // $ExpectError - filledarrayBy( buf, [], clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, clbk, {} ); // $ExpectError - - filledarrayBy( buf, '5', 'float64', clbk ); // $ExpectError - filledarrayBy( buf, false, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, true, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, null, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, [], 'float64', clbk ); // $ExpectError - filledarrayBy( buf, {}, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, '5', 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( buf, false, 2, clbk ); // $ExpectError - filledarrayBy( buf, true, 2, clbk ); // $ExpectError - filledarrayBy( buf, null, 2, clbk ); // $ExpectError - filledarrayBy( buf, [], 2, clbk ); // $ExpectError - filledarrayBy( buf, {}, 2, clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, clbk ); // $ExpectError - - filledarrayBy( buf, false, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, clbk, {} ); // $ExpectError - - filledarrayBy( buf, '5', 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, false, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, true, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, null, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, undefined, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, [], 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, {}, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, '5', 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, false, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, undefined, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a view length argument which is not a number... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, 8, false, clbk ); // $ExpectError - filledarrayBy( buf, 8, true, clbk ); // $ExpectError - filledarrayBy( buf, 8, null, clbk ); // $ExpectError - filledarrayBy( buf, 8, [], clbk ); // $ExpectError - filledarrayBy( buf, 8, {}, clbk ); // $ExpectError - - filledarrayBy( buf, 8, false, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, true, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, null, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, [], clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, {}, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, clbk, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5', 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, false, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, true, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, null, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, [], 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, {}, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, 8, '5', 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, [], 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, {}, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided too many arguments... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, 8, 2, 'float64', 1, clbk, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 997a381..0000000 --- a/examples/index.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ).factory; -var dtypes = require( '@stdlib/array-typed-real-dtypes' ); -var filledarrayBy = require( './../lib' ); - -// Create a pseudorandom number generator: -var rand = discreteUniform( 0, 100 ); - -// Get a list of array data types: -var dt = dtypes(); - -// Generate filled arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = filledarrayBy( 10, dt[ i ], rand ); - console.log( arr ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 606ef7c..fde6688 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, RealOrComplexTypedArray, BooleanArray, DataType } from '@stdlib/types/array'; import { IterableIterator } from '@stdlib/types/iter'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..6f157fa --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.3-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.3-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@v0.0.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.3-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.3-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.3-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-ctors@v0.3.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill-by@v0.2.3-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled-by@v0.2.3-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.2.3-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.3-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@v0.2.3-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.4.1-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";var v=f(),g=j.get("dtypes.default");function c(){var f,j,c,b,y,x,u,E;if(0===(j=arguments.length))return new(y=d(g))(0);if(r(c=arguments[0])){if(j>1)throw new TypeError(w("00h05"));if(null===(y=d(c)))throw new TypeError(w("00h2Y",c));return new y(0)}if(j<2)throw new TypeError(w("00h05"));if(h(arguments[j-=1]))if(h(arguments[j-1])){if(f=arguments[j],b=arguments[j-=1],0===j)throw new TypeError(w("00h05"))}else b=arguments[j];else{if(!(j>=2))throw new TypeError(w("00h05"));if(f=arguments[j],!h(b=arguments[j-=1]))throw new TypeError(w("00h2b",b))}if((j-=1)>=0&&r(arguments[j])?(c=arguments[j],j-=1):c=g,null===(y=d(c)))throw new TypeError(w("00h2Y",c));if("generic"===c){if(E=arguments[0],0===j){if(e(E)?u=E:i(E)&&(u=E.length),void 0!==u)return m(u,b,f);if(n(E))throw new Error(w("00h04"));if(o(E)){if(!1===v)throw new TypeError(w("00h2Z",E));if(!h(E[p]))throw new TypeError(w("00h2a",E));if(E=E[p](),!h(E.next))throw new TypeError(w("00h2a",E));return function(r,e,t){var s,i;for(s=[],i=-1;!r.next().done;)i+=1,s.push(e.call(t,i));return s}(E,b,f)}throw new TypeError(w("00h2a",E))}if(n(E))throw new Error(w("00h04"));throw new TypeError(w("00h2a",E))}if(0===j)if(i(E=arguments[0]))x=new y(E.length);else if(n(E))x=new y(E);else if(e(E))x=new y(E);else{if(!o(E))throw new TypeError(w("00h2a",E));if(!1===v)throw new TypeError(w("00h2Z",E));if(!h(E[p]))throw new TypeError(w("00h2a",E));if(E=E[p](),!h(E.next))throw new TypeError(w("00h2a",E));x=new y(a(E))}else x=1===j?new y(arguments[0],arguments[1]):new y(arguments[0],arguments[1],arguments[2]);return x.length>0&&(t(c)||s(c)?function(r,e,t){var s;for(s=0;s\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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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* import ArrayBuffer from '@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( format('00h05') );\n\t\t}\n\t\tctor = ctors( dtype );\n\t\tif ( ctor === null ) {\n\t\t\tthrow new TypeError( format( '00h2Y', 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( format('00h05') );\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( format('00h05') );\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( '00h2b', clbk ) );\n\t\t}\n\t}\n\t// If we 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( format('00h05') );\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( '00h2Y', 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( format('00h04') );\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( '00h2Z', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00h2a', 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( '00h2a', 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( '00h2a', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format('00h04') );\n\t\t}\n\t\tthrow new TypeError( format( '00h2a', 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( '00h2Z', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00h2a', 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( '00h2a', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00h2a', 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\nexport default filledarrayBy;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","DEFAULT_DTYPE","defaults","get","filledarrayBy","thisArg","nargs","dtype","clbk","ctor","arr","len","arg","arguments","length","ctors","isString","TypeError","format","isFunction","isNonNegativeInteger","isCollection","filledArray","isArrayBuffer","Error","isObject","ITERATOR_SYMBOL","next","it","i","done","push","call","filledArrayIterator","iterLength","isComplexDataType","isBooleanDataType","set","filledAccessors","gfillBy","value","aidx"],"mappings":";;sjDA0CA,IAAIA,EAAsBC,IACtBC,EAAgBC,EAASC,IAAK,kBA2MlC,SAASC,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAKJ,GAAe,KAHfN,EAAQO,UAAUC,QAKjB,OAAO,IADPL,EAAOM,EAAOd,IACG,GAIlB,GAAKe,EADLT,EAAQM,UAAW,IACM,CAExB,GAAKP,EAAQ,EACZ,MAAM,IAAIW,UAAWC,EAAO,UAG7B,GAAc,QADdT,EAAOM,EAAOR,IAEb,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,OAAO,IAAIE,EAAM,EACjB,CAED,GAAKH,EAAQ,EACZ,MAAM,IAAIW,UAAWC,EAAO,UAM7B,GAAKC,EAAYN,UAHjBP,GAAS,IAKR,GAAKa,EAAYN,UAAWP,EAAM,KAMjC,GALAD,EAAUQ,UAAWP,GAErBE,EAAOK,UADPP,GAAS,GAIM,IAAVA,EACJ,MAAM,IAAIW,UAAWC,EAAO,eAI7BV,EAAOK,UAAWP,OAIf,MAAKA,GAAS,GAUlB,MAAM,IAAIW,UAAWC,EAAO,UAN5B,GAHAb,EAAUQ,UAAWP,IAGfa,EADNX,EAAOK,UADPP,GAAS,IAGR,MAAM,IAAIW,UAAWC,EAAQ,QAASV,GAMvC,CAUD,IARAF,GAAS,IACK,GAAKU,EAAUH,UAAWP,KACvCC,EAAQM,UAAWP,GACnBA,GAAS,GAETC,EAAQN,EAGK,QADdQ,EAAOM,EAAOR,IAEb,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,GAAe,YAAVA,EAAsB,CAE1B,GADAK,EAAMC,UAAW,GACF,IAAVP,EAAc,CAMlB,GALKc,EAAsBR,GAC1BD,EAAMC,EACKS,EAAcT,KACzBD,EAAMC,EAAIE,aAEE,IAARH,EACJ,OAAOW,EAAaX,EAAKH,EAAMH,GAEhC,GAAKkB,EAAeX,GACnB,MAAM,IAAIY,MAAON,EAAO,UAEzB,GAAKO,EAAUb,GAAQ,CACtB,IAA6B,IAAxBb,EACJ,MAAM,IAAIkB,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAYP,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLP,EAAYP,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvC,OAvSJ,SAA8BgB,EAAIpB,EAAMH,GACvC,IAAIK,EACAmB,EAKJ,IAFAnB,EAAM,GACNmB,GAAK,GAEAD,EAAGD,OACAG,MAGPD,GAAK,EACLnB,EAAIqB,KAAMvB,EAAKwB,KAAM3B,EAASwB,IAE/B,OAAOnB,CACR,CAuRWuB,CAAqBrB,EAAKJ,EAAMH,EACvC,CACD,MAAM,IAAIY,UAAWC,EAAQ,QAASN,GACzC,CAAS,GAAKW,EAAeX,GAC1B,MAAM,IAAIY,MAAON,EAAO,UAEzB,MAAM,IAAID,UAAWC,EAAQ,QAASN,GACtC,CACD,GAAe,IAAVN,EAEJ,GAAKe,EADLT,EAAMC,UAAW,IAEhBH,EAAM,IAAID,EAAMG,EAAIE,aACd,GAAKS,EAAeX,GAC1BF,EAAM,IAAID,EAAMG,QACV,GAAKQ,EAAsBR,GACjCF,EAAM,IAAID,EAAMG,OACV,KAAKa,EAAUb,GAarB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAZtC,IAA6B,IAAxBb,EACJ,MAAM,IAAIkB,UAAWC,EAAQ,QAASN,IAEvC,IAAMO,EAAYP,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLP,EAAYP,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvCF,EAAM,IAAID,EAAMyB,EAAYtB,GAG5B,MAEDF,EADqB,IAAVJ,EACL,IAAIG,EAAMI,UAAU,GAAIA,UAAU,IAElC,IAAIJ,EAAMI,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKH,EAAII,OAAS,IACZqB,EAAmB5B,IAAW6B,EAAmB7B,GAjTxD,SAA0BG,EAAKF,EAAMH,GACpC,IAAIwB,EACJ,IAAMA,EAAI,EAAGA,EAAInB,EAAII,OAAQe,IAC5BnB,EAAI2B,IAAK7B,EAAKwB,KAAM3B,EAASwB,GAAKA,EAGpC,CA4SGS,CAAiB5B,EAAKF,EAAMH,GAE5BkC,EAAS7B,EAAII,OAAQJ,EAAK,GAe5B,SAAmB8B,EAAOC,GACzB,OAAOjC,EAAKwB,KAAM3B,EAASoC,EAC3B,KAdM/B,CAeR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d115cf0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,192 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -/** -* Create a filled array according to a provided callback function. -* -* @module @stdlib/array-filled-by -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* var arr = filledarrayBy(); -* // returns -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'generic', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( [ 0.5, 0.5 ], clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1; -* } -* -* var arr = filledarrayBy( [ 5, -3 ], 'int32', clbk ); -* // returns [ 1, 1 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk1() { -* return 10; -* } -* -* function clbk2() { -* return 1.0; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, clbk2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk1() { -* return 1.0; -* } -* -* function clbk2() { -* return 2; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, 'uint32', clbk2 ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 'float32', clbk ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, clbk ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarrayBy = require( '@stdlib/array-filled-by' ); -* -* function clbk() { -* return 1; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, 'int32', clbk ); -* // returns [ 1, 1 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 32b6545..0000000 --- a/lib/main.js +++ /dev/null @@ -1,416 +0,0 @@ -/** -* @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 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' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var ctors = require( '@stdlib/array-ctors' ); -var gfillBy = require( '@stdlib/blas-ext-base-gfill-by' ); -var filledArray = require( '@stdlib/array-base-filled-by' ); -var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var iterLength = require( '@stdlib/iter-length' ); -var defaults = require( '@stdlib/array-defaults' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport(); -var DEFAULT_DTYPE = defaults.get( 'dtypes.default' ); - - -// FUNCTIONS // - -/** -* Creates a filled "generic" array from an iterator. -* -* @private -* @param {Iterable} it - iterator -* @param {Callback} clbk - callback function -* @param {*} thisArg - callback function execution context -* @returns {Array} filled array -*/ -function filledArrayIterator( it, clbk, thisArg ) { - var arr; - var i; - var v; - - arr = []; - i = -1; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - i += 1; - arr.push( clbk.call( thisArg, i ) ); - } - return arr; -} - -/** -* Fills an array exposing accessors for getting and setting array elements. -* -* @private -* @param {Collection} arr - input array -* @param {Callback} clbk - callback function -* @param {*} thisArg - callback function execution context -* @returns {Collection} input array -*/ -function filledAccessors( arr, clbk, thisArg ) { - var i; - for ( i = 0; i < arr.length; i++ ) { - arr.set( clbk.call( thisArg, i ), i ); - } - return arr; -} - - -// MAIN // - -/** -* Creates a filled array according to a provided callback function. -* -* @param {(NonNegativeInteger|TypedArray|ArrayLikeObject|ArrayBuffer|Iterable)} [arg] - a length, typed array, array-like object, buffer, or iterable -* @param {NonNegativeInteger} [byteOffset=0] - byte offset -* @param {NonNegativeInteger} [length] - view length -* @param {string} [dtype="float64"] - data type -* @param {Callback} [clbk] - callback to invoke -* @param {*} [thisArg] - callback execution context -* @throws {TypeError} must provide a recognized data type -* @throws {TypeError} must provide a length, typed array, array-like object, buffer, or iterable -* @throws {TypeError} callback argument must be a function. -* @throws {Error} creating a generic array from an `ArrayBuffer` is not supported -* @returns {(TypedArray|Array)} array or typed array -* -* @example -* var arr = filledarrayBy(); -* // returns -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'generic', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( [ 0.5, 0.5 ], clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1; -* } -* -* var arr = filledarrayBy( [ 5, -3 ], 'int32', clbk ); -* // returns [ 1, 1 ] -* -* @example -* function clbk1() { -* return 10; -* } -* -* function clbk2() { -* return 1.0; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, clbk2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk1() { -* return 1.0; -* } -* -* function clbk2() { -* return 2; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, 'uint32', clbk2 ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 'float32', clbk ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, clbk ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* function clbk() { -* return 1; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, 'int32', clbk ); -* // returns [ 1, 1 ] -*/ -function filledarrayBy() { - var thisArg; - var nargs; - var dtype; - var clbk; - var ctor; - var arr; - var len; - var arg; - - nargs = arguments.length; - - // If we weren't provided any arguments, return an empty array... - if ( nargs === 0 ) { - ctor = ctors( DEFAULT_DTYPE ); - return new ctor( 0 ); - } - // Check if we were provided a dtype as the first argument... - dtype = arguments[ 0 ]; - if ( isString( dtype ) ) { - // Invoking this function with arguments `f( dtype, clbk[, thisArg] )` is not allowed (otherwise, we'd need to also allow `f( clbk[, thisArg] )`)... - if ( nargs > 1 ) { - throw new TypeError( format('00h05') ); - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '00h2Y', dtype ) ); - } - // Return an empty array having the specified dtype: - return new ctor( 0 ); - } - // For all other supported invocations, we need at least two arguments... - if ( nargs < 2 ) { - throw new TypeError( format('00h05') ); - } - // At this point, we need to do some argument juggling... - nargs -= 1; // henceforth, the number of available arguments is `nargs+1` - - // Determine whether the last argument is a callback or "this" context... - if ( isFunction( arguments[ nargs ] ) ) { - // 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... - if ( isFunction( arguments[ nargs-1 ] ) ) { - thisArg = arguments[ nargs ]; - nargs -= 1; - clbk = arguments[ nargs ]; - - // Check if we were provided only a callback and a "this" context.. - if ( nargs === 0 ) { - throw new TypeError( format('00h05') ); - } - } else { - // "this" context is left undefined... - clbk = arguments[ nargs ]; - } - } - // 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... - else if ( nargs >= 2 ) { - thisArg = arguments[ nargs ]; - nargs -= 1; - clbk = arguments[ nargs ]; - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '00h2b', clbk ) ); - } - } - // If we were only provided 2 arguments and the last argument was not a function, we've been provided an insufficient number of arguments... - else { - throw new TypeError( format('00h05') ); - } - // Now that we've processed the callback arguments, let's continue working backward to see if we've been provided a `dtype` argument... - nargs -= 1; - if ( nargs >= 0 && isString( arguments[ nargs ] ) ) { - dtype = arguments[ nargs ]; - nargs -= 1; - } else { - dtype = DEFAULT_DTYPE; - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '00h2Y', dtype ) ); - } - // At this point, we've resolved the output array data type, and now we can actually create the output array... - if ( dtype === 'generic' ) { - arg = arguments[ 0 ]; - if ( nargs === 0 ) { - if ( isNonNegativeInteger( arg ) ) { - len = arg; - } else if ( isCollection( arg ) ) { - len = arg.length; - } - if ( len !== void 0 ) { - return filledArray( len, clbk, thisArg ); - } - if ( isArrayBuffer( arg ) ) { - throw new Error( format('00h04') ); - } - if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( '00h2Z', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00h2a', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00h2a', arg ) ); - } - return filledArrayIterator( arg, clbk, thisArg ); - } - throw new TypeError( format( '00h2a', arg ) ); - } else if ( isArrayBuffer( arg ) ) { - throw new Error( format('00h04') ); - } - throw new TypeError( format( '00h2a', arg ) ); - } - if ( nargs === 0 ) { // length || array-like || ArrayBuffer || iterable - arg = arguments[ 0 ]; - if ( isCollection( arg ) ) { - arr = new ctor( arg.length ); - } else if ( isArrayBuffer( arg ) ) { - arr = new ctor( arg ); - } else if ( isNonNegativeInteger( arg ) ) { - arr = new ctor( arg ); - } else if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( '00h2Z', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00h2a', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00h2a', arg ) ); - } - arr = new ctor( iterLength( arg ) ); - } else { - throw new TypeError( format( '00h2a', arg ) ); - } - } else if ( nargs === 1 ) { - arr = new ctor( arguments[0], arguments[1] ); // (ArrayBuffer, byteOffset) - } else { - arr = new ctor( arguments[0], arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset, length) - } - if ( arr.length > 0 ) { - if ( isComplexDataType( dtype ) || isBooleanDataType( dtype ) ) { - filledAccessors( arr, clbk, thisArg ); - } else { - gfillBy( arr.length, arr, 1, callback ); - } - } - return arr; - - /** - * Callback which wraps a provided callback and is invoked for each array element. - * - * @private - * @param {*} value - element value - * @param {NonNegativeInteger} aidx - array index - * @param {NonNegativeInteger} sidx - strided index - * @param {Collection} array - input array/collection - * @returns {*} callback return value - */ - function callback( value, aidx ) { - return clbk.call( thisArg, aidx ); - } -} - - -// EXPORTS // - -module.exports = filledarrayBy; diff --git a/package.json b/package.json index a1a5078..026d062 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.3.1", "description": "Create a filled array according to a provided callback function.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,75 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-assert-is-boolean-data-type": "^0.0.2", - "@stdlib/array-base-assert-is-complex-floating-point-data-type": "^0.2.2", - "@stdlib/array-base-filled-by": "^0.2.3", - "@stdlib/array-ctors": "^0.3.1", - "@stdlib/array-defaults": "^0.4.1", - "@stdlib/assert-has-iterator-symbol-support": "^0.2.3", - "@stdlib/assert-is-arraybuffer": "^0.2.3", - "@stdlib/assert-is-collection": "^0.2.3", - "@stdlib/assert-is-function": "^0.2.3", - "@stdlib/assert-is-nonnegative-integer": "^0.2.3", - "@stdlib/assert-is-object": "^0.2.3", - "@stdlib/assert-is-string": "^0.2.3", - "@stdlib/blas-ext-base-gfill-by": "^0.2.3", - "@stdlib/iter-length": "^0.2.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3", - "@stdlib/symbol-iterator": "^0.2.3", - "@stdlib/types": "^0.5.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3" - }, - "devDependencies": { - "@stdlib/array-bool": "^0.1.2", - "@stdlib/array-buffer": "^0.2.3", - "@stdlib/array-complex128": "^0.3.2", - "@stdlib/array-complex64": "^0.3.2", - "@stdlib/array-float32": "^0.2.3", - "@stdlib/array-float64": "^0.2.3", - "@stdlib/array-int16": "^0.2.3", - "@stdlib/array-int32": "^0.2.3", - "@stdlib/array-int8": "^0.2.3", - "@stdlib/array-typed-real-dtypes": "^0.2.3", - "@stdlib/array-uint16": "^0.2.3", - "@stdlib/array-uint32": "^0.2.3", - "@stdlib/array-uint8": "^0.2.3", - "@stdlib/array-uint8c": "^0.2.3", - "@stdlib/assert-instance-of": "^0.3.1", - "@stdlib/assert-is-array": "^0.2.3", - "@stdlib/assert-is-typed-array": "^0.2.3", - "@stdlib/assert-is-typed-array-like": "^0.2.3", - "@stdlib/complex-float32-ctor": "^0.1.1", - "@stdlib/complex-float64-ctor": "^0.1.2", - "@stdlib/iter-constant": "^0.2.3", - "@stdlib/math-base-special-pow": "^0.3.1", - "@stdlib/random-base-discrete-uniform": "^0.2.2", - "@stdlib/strided-base-reinterpret-boolean": "^0.0.3", - "@stdlib/strided-base-reinterpret-complex128": "^0.2.3", - "@stdlib/strided-base-reinterpret-complex64": "^0.2.2", - "@stdlib/utils-constant-function": "^0.2.3", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.3" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..dabf69c --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index ca0cf25..0000000 --- a/test/test.js +++ /dev/null @@ -1,4397 +0,0 @@ -/** -* @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. -*/ - -/* eslint-disable max-len */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -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' ); -var iterConstant = require( '@stdlib/iter-constant' ); -var constantFunction = require( '@stdlib/utils-constant-function' ); -var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var filledarrayBy = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': !hasIteratorSymbolSupport() -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof filledarrayBy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if only provided callback arguments', function test( t ) { - t.throws( clbk1, TypeError, 'throws an error' ); - t.throws( clbk2, TypeError, 'throws an error' ); - t.throws( clbk3, TypeError, 'throws an error' ); - t.end(); - - function clbk1() { - filledarrayBy( constantFunction( 1.0 ) ); - } - - function clbk2() { - filledarrayBy( constantFunction( 1.0 ), {} ); - } - - function clbk3() { - filledarrayBy( constantFunction( 1.0 ), constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (only argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (typed array; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (array-like object)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (array-like object; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 8 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 8 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, 1, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (iterator)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( iterConstant( 1.0 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (iterator; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( iterConstant( 1.0 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if only provided data type and callback arguments', function test( t ) { - t.throws( clbk1, TypeError, 'throws an error' ); - t.throws( clbk2, TypeError, 'throws an error' ); - t.throws( clbk3, TypeError, 'throws an error' ); - t.end(); - - function clbk1() { - filledarrayBy( 'float64', constantFunction( 1.0 ) ); - } - - function clbk2() { - filledarrayBy( 'float64', constantFunction( 1.0 ), {} ); - } - - function clbk3() { - filledarrayBy( 'float64', constantFunction( 1.0 ), constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (array-like object)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (array-like object; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, 1, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, 1, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (no iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (no iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (non-function iterator symbol property)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (non-function iterator symbol property; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (`next` property is not a function)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ) ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (`next` property is not a function; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ), {} ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (no iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (no iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (non-function iterator symbol property)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (non-function iterator symbol property; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (`next` property is not a function)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ) ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (`next` property is not a function; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ), {} ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 1, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 1, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function returns a filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - arr = filledarrayBy(); - - t.strictEqual( instanceOf( arr, Float64Array ), 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=float64)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - arr = filledarrayBy( 'float64' ); - - t.strictEqual( instanceOf( arr, Float64Array ), 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=float32)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( 0 ); - arr = filledarrayBy( 'float32' ); - - t.strictEqual( instanceOf( arr, Float32Array ), 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=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; - - expected = new Complex128Array( 0 ); - arr = filledarrayBy( 'complex128' ); - - t.strictEqual( instanceOf( arr, Complex128Array ), 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=complex64)', function test( t ) { - var expected; - var arr; - - expected = new Complex64Array( 0 ); - arr = filledarrayBy( 'complex64' ); - - t.strictEqual( instanceOf( arr, Complex64Array ), 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=int32)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( 0 ); - arr = filledarrayBy( 'int32' ); - - t.strictEqual( instanceOf( arr, Int32Array ), 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=uint32)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( 0 ); - arr = filledarrayBy( 'uint32' ); - - t.strictEqual( instanceOf( arr, Uint32Array ), 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=int16)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( 0 ); - arr = filledarrayBy( 'int16' ); - - t.strictEqual( instanceOf( arr, Int16Array ), 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=uint16)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( 0 ); - arr = filledarrayBy( 'uint16' ); - - t.strictEqual( instanceOf( arr, Uint16Array ), 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=int8)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( 0 ); - arr = filledarrayBy( 'int8' ); - - t.strictEqual( instanceOf( arr, Int8Array ), 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=uint8)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( 0 ); - arr = filledarrayBy( 'uint8' ); - - t.strictEqual( instanceOf( arr, Uint8Array ), 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=uint8c)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( 0 ); - arr = filledarrayBy( 'uint8c' ); - - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), 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=generic)', function test( t ) { - var expected; - var arr; - - expected = []; - arr = filledarrayBy( 'generic' ); - - t.strictEqual( instanceOf( arr, Array ), 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 (default, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, length=0)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array(); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 0, clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, clbk, ctx ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (default, length; thisArg=function)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, clbk, context ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this(); // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } - - function context() { - ctx.count += 1; - } -}); - -tape( 'the function returns a filled array (dtype=float64, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, 'float64', clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, length; thisArg=function)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, 'float64', clbk, context ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this(); // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } - - function context() { - ctx.count += 1; - } -}); - -tape( 'the function returns a filled array (dtype=float32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, 'float32', clbk ); - - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - 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; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = filledarrayBy( 5, 'complex128', clbk ); - - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = filledarrayBy( 5, 'complex64', clbk ); - - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int32Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int32', clbk ); - - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint32Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint32', clbk ); - - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int16Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int16', clbk ); - - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint16', clbk ); - - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int8Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int8', clbk ); - - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint8', clbk ); - - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint8c', clbk ); - - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = [ 1, 1, 1, 1, 1 ]; - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'generic', clbk ); - - t.strictEqual( instanceOf( arr, Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - 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; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = [ 1.0, 2.0 ]; - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = [ 1.0, 2.0 ]; - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int32', clbk ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, typed array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, typed array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - 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; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = new Float64Array( [ 1.0, 2.0 ] ); - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = new Float64Array( [ 1.0, 2.0 ] ); - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (default, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - 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; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer, byteoffset; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer, byteoffset; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - 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; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 48 ); - out = filledarrayBy( buf, 16, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 24 ); - out = filledarrayBy( buf, 8, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int32', clbk ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint8c', clbk ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - 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; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 64 ); - out = filledarrayBy( buf, 16, 2, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset, length)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 1, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 1, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled array (default, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, iterator; thisArg)', opts, function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - ctx = { - 'count': 0 - }; - indices = []; - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, iterator; thisArg)', opts, function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - ctx = { - 'count': 0 - }; - indices = []; - out = filledarrayBy( arr, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - 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; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = iterConstant( new Complex128( 3.0, 3.0 ), { - 'iter': 2 - }); - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = iterConstant( new Complex64( 3.0, 3.0 ), { - 'iter': 2 - }); - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -});